Query Database trouble
-
Hey,
I’m running a site that has a sections of post, which use custom fields – allowing me to add reference numbers…
Then I have an ecommerce system using those reference numbers, so on my posts I need to say something like “To do this, you need these:”
Then list the name, price and quantity…
So far I have it reading the DB for the custom fields…
$key="Linked Products"; $idcode= get_post_meta($post->ID, $key, true); $array = explode(",",$idcode); $products = array_count_values($array); foreach ($products as $key => $value) { $sql = "SELECT product_id FROM wordpdem_wpsc_productmeta WHERE meta_value = '$key'"; $productid = $wpdb->get_results($sql, ARRAY_N); echo $sql . "<br>"; }
The sql echo works 100%…
So now I add
while($row = mysql_fetch_array($productid)) { echo $row['product_id']; }
and I get a warning about Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in XXXXXwp-content\themes\xx\comments.php on line 18
Any Ideas?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Query Database trouble’ is closed to new replies.