sungpeng Posted August 26, 2016 Share Posted August 26, 2016 $sql = mysql_query("SELECT * FROM database where id=$id") while($do=mysql_fetch_array($sql)){ There are many rows that have the same id numbers. I need all to fetch out. Mysql error. Is it possible to echo out all ? Quote Link to comment Share on other sites More sharing options...
Yohanne Posted August 26, 2016 Share Posted August 26, 2016 yes Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted August 26, 2016 Share Posted August 26, 2016 You could give it a shot <?php $sql = mysql_query("SELECT * FROM database where id=$id"); while($do=mysql_fetch_array($sql)){ echo "<div>{$do['id']}</div>"; } ?> Note that I added a semi-colon after the call to mysql_query(). And in case you are not aware, the mysql_* functions have been removed from the newest version of PHP. You need to switch to PDO or MySQLi soon. More information can be found here: http://php.net/manual/en/mysqlinfo.api.choosing.php Quote Link to comment Share on other sites More sharing options...
maxxd Posted August 26, 2016 Share Posted August 26, 2016 I have to assume this query is gibberish pseudo-code. The name of your table isn't 'database', and if you've got duplicate values in the ID column, you're using IDs incorrectly. Give us the actual query and we may be able to help you figure out why you're getting a MySQL error. Quote Link to comment Share on other sites More sharing options...
ginerjm Posted August 26, 2016 Share Posted August 26, 2016 Would have been nice to not just mention the MySQL error, but to show it to us. Plus - is id a numeric value? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.