View Single Post
Old Nov 29th, 2007, 9:46 PM   #13
MiKuS
Hobbyist Programmer
 
Join Date: Jun 2007
Posts: 134
Rep Power: 2 MiKuS is on a distinguished road
Re: SELECT statement

I suggest working with this tutorial so you understand the basics of database functionality
http://www.phpfreaks.com/tutorials/142/0.php


php Syntax (Toggle Plain Text)
  1. $dbhost = 'localhost';
  2. $dbuser = 'your_user';
  3. $dbpass = 'user_password';
  4. $conn = mysql_connect($dbhost, $dbuser, $dbpass);
  5. mysql_select_db('your_database');
  6.  
  7. $sql="SELECT name FROM ".$table_name."WHERE gender='male'";
  8. $retval = mysql_query($sql, $conn );
  9. if (! $retval ) {
  10. print_r($sql);
  11. die('Could not get data: ' . mysql_error());
  12. }
  13. if ($row = mysql_fetch_array($retval, MYSQL_ASSOC)) {
  14. echo "<h1>{$row['gender']}</h1> ";
  15. }

I haven't checked the above code but it should work.
MiKuS is offline   Reply With Quote