chmpdog Posted August 10, 2009 Share Posted August 10, 2009 Hello, I was wondering if anyone could teach me how to display the following mysql statement: select * where allowed='no'; Normally this would be easy but there are multiple values with no. Thankyou Quote Link to comment https://forums.phpfreaks.com/topic/169544-solved-displaying-mysql-statement/ Share on other sites More sharing options...
BLaZuRE Posted August 10, 2009 Share Posted August 10, 2009 Do you mean you only want to get one result? If so, try using LIMIT: SELECT * FROM `table` WHERE `allowed`='no' LIMIT 1 Quote Link to comment https://forums.phpfreaks.com/topic/169544-solved-displaying-mysql-statement/#findComment-894560 Share on other sites More sharing options...
chmpdog Posted August 10, 2009 Author Share Posted August 10, 2009 no, but thanks. I figured it out <?php $query = "SELECT id FROM table WHERE name = 'some name'"; // and if you wanted no more than 3 rows: // $query = "SELECT id FROM table WHERE name = 'some name' LIMIT 3"; // Perform Query $result = mysql_query($query); // Check result // This shows the actual query sent to MySQL, and the error. Useful for debugging. if (!$result) { $message = 'Invalid query: ' . mysql_error() . "\n"; $message .= 'Whole query: ' . $query; die($message); } // Use result // Attempting to print $result won't allow access to information in the resource // One of the mysql result functions must be used // See also mysql_result(), mysql_fetch_array(), mysql_fetch_row(), etc. while ($row = mysql_fetch_assoc($result)) { echo $row['id']; } // Free the resources associated with the result set // This is done automatically at the end of the script mysql_free_result($result); ?> Quote Link to comment https://forums.phpfreaks.com/topic/169544-solved-displaying-mysql-statement/#findComment-894620 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.