0

I am using Formidable Pro as a CRM and one form has a field called cust_id.

Now I want to get all the records stored within that form with a specific cust_id.

I did:

$form_id = 7; $search_id = 300;

$entries = $wpdb->get_col( $wpdb->prepare("SELECT id FROM ". $wpdb->prefix ."frm_items WHERE cust_id = %d AND form_id = %d", $search_id, $form_id) );

But the $entries are empty ??

And there are a few records with the search_id.

Any suggestions on what I am doing wrong ?

0

Try this:

<?php
global $wpdb;
$table_name = $wpdb->prefix.'frm_items';

$row_values = $wpdb->get_results("SELECT * FROM {$table_name} WHERE id = 1");

echo $row_values[0]->cust_id;

?>
| improve this answer | |
  • Thanks for your reply, But maybe my question was not clear enough. What I have is: a form which is form_id 7. Within that form there is a field called cust_id. No I want to retreive all the record ID's when i.e. cust_id = 300 from form_id=7. I will give your suggestion a try anyway... – FredW Oct 29 '19 at 13:46
  • I have updated my answer just now. Maybe you'll need change id for form_id ? – Sam Oct 29 '19 at 13:56
  • Thanks again, but that doesn't do the trick also. – FredW Oct 30 '19 at 6:13
  • Can you please replace: echo $row_values[0]->cust_id; by >>> echo '<pre>'; print_r($row_values); and return me the array here: codepile.net . By the same time, can you please give me what you write in the $wpdb->get_results ? – Sam Oct 30 '19 at 13:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.