son Posted August 24, 2009 Share Posted August 24, 2009 The following query works well in phpMyAdmin: SELECT ageing_id, ageing_name FROM ageing WHERE ageing_id IN (SELECT age_id FROM productAge WHERE product_id = 30) Running same query does not display the select that receives data from this query. The code for this is: if (mysqli_num_rows($ageing_result) > 0) { echo "<select name=\"ageing\" id=\"ageing\">\n"; echo "<option value=\"0\">Please select...</option>"; while ($row = mysqli_fetch_array ($ageing_result, MYSQLI_ASSOC)) { echo "<option value=\"{$row['ageing_id']}\""; echo ">{$row['ageing_name']}</option>\n"; } echo "</select>"; Taking out 'WHERE ageing_id IN (SELECT age_id FROM productAge WHERE product_id = 30)' from query makes it work, but I only want to have options of ages that are for selected product_id appliable (stored in productAge). As it is working without fault in phpMyAdmin (and shows right set of data) am a bit confused now as why it won't work. Any ideas?Son Link to comment Share on other sites More sharing options...
justsomeguy Posted August 24, 2009 Share Posted August 24, 2009 You're probably not running the same query in PHP. If you were running the same query it would return the same results, right? It's not going to return different results just because it was run in PHP (and, also, phpMyAdmin is also written in PHP). Link to comment Share on other sites More sharing options...
son Posted August 24, 2009 Author Share Posted August 24, 2009 You're probably not running the same query in PHP. If you were running the same query it would return the same results, right? It's not going to return different results just because it was run in PHP (and, also, phpMyAdmin is also written in PHP).The query actually uses a variable instead of '30' at the end. Still, when I echo the variable is correctly shows 30 (in line above the display of query result). The query is:SELECT ageing_id, ageing_name FROM ageing WHERE ageing_id IN (SELECT age_id FROM productAge WHERE product_id = $pid Son Link to comment Share on other sites More sharing options...
justsomeguy Posted August 24, 2009 Share Posted August 24, 2009 That query has an error in it, are you checking for errors when you run the query? Link to comment Share on other sites More sharing options...
son Posted August 24, 2009 Author Share Posted August 24, 2009 That query has an error in it, are you checking for errors when you run the query?Sorry, forgot to copy the last closing bracket... Just now have it working. Replaced single quotation marks of query with double marks and works. What do you mean by checking for errors when you run the query? I run it in phpMyAdmin without problem before. Is this what you mean?Son Link to comment Share on other sites More sharing options...
justsomeguy Posted August 24, 2009 Share Posted August 24, 2009 You can check for MySQL errors in PHP and print the error message if there's a problem. Link to comment Share on other sites More sharing options...
son Posted August 25, 2009 Author Share Posted August 25, 2009 You can check for MySQL errors in PHP and print the error message if there's a problem.Now I am with you...Thanks,Son Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.