UnsuitableBadger Posted October 15, 2009 Share Posted October 15, 2009 Hi guys, I'm running joomla and made a module which is using ajax. Basically i just have an html input textbox which i put a SQL statement in and then onblur it does the ajax script which returns the query results. my sql query: "SELECT * FROM jos_users" So, why does this: $result = mysql_query($query); while ($row = mysql_fetch_array($result)) { for ($x=1; $x<=count($row); $x++) { echo $row[$x]."<br />"; } } return this: Administrator admin [email protected] 21232f297a57a5a743894a0e4a801fc3 Super Administrator 0 1 25 2005-09-28 00:00:00 2009-10-14 13:11:45 while this: $result = mysql_query($query); while ($row = mysql_fetch_array($result)) { foreach ($row as $item) { echo $item."<br />"; } } return this: 62 62 Administrator Administrator admin admin [email protected] [email protected] 21232f297a57a5a743894a0e4a801fc3 21232f297a57a5a743894a0e4a801fc3 Super Administrator Super Administrator 0 0 1 1 25 25 2005-09-28 00:00:00 2005-09-28 00:00:00 2009-10-14 13:11:45 2009-10-14 13:11:45 Thanks for any light you can shed. Link to comment https://forums.phpfreaks.com/topic/177759-solved-php-mysql-return-results-issue/ Share on other sites More sharing options...
dymon Posted October 15, 2009 Share Posted October 15, 2009 mysql_fetch_array by default comes with MYSQL_BOTH parameter, which returns both and numeric and associative result. To get just one of these results use one of these: MYSQL_NUM or MYSQL_ASSOC: mysql_fetch_array ($result, MYSQL_NUM) Link to comment https://forums.phpfreaks.com/topic/177759-solved-php-mysql-return-results-issue/#findComment-937293 Share on other sites More sharing options...
ILMV Posted October 15, 2009 Share Posted October 15, 2009 Instead of passing a constant, why not just hit: [pph]mysql_fetch_assoc($result);[/code] Link to comment https://forums.phpfreaks.com/topic/177759-solved-php-mysql-return-results-issue/#findComment-937295 Share on other sites More sharing options...
UnsuitableBadger Posted October 15, 2009 Author Share Posted October 15, 2009 Thanks for the help that worked perfectly! Link to comment https://forums.phpfreaks.com/topic/177759-solved-php-mysql-return-results-issue/#findComment-937298 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.