BernieLowmax Posted June 22, 2009 Share Posted June 22, 2009 Hi Everyone, hope everyone had a great weekend. I'm new to php and SQL and have been learning on the side. I've created a simple SQL DB to just learn with. I'm sure this is a simple answer just not knowledgable enough yet and unsure where to look. Here's where my test MySQL/PHP page is located at. It's a very simple database table: http://www.capellnet.com/SQL/cars.php As you can see I created a field that lists the vehicle types. Is there a way to only pass the values of the "trucks" for example or the "cars" that way it only displays the vehicles that are that type in the list. I would assume in this test it would be a "select" statement of some type? Here's what inside the PHP file so far. Thanks again for any help provided. Newbie in training :-) <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>SQL Cars Example</title> </head> <link rel="stylesheet" type="text/css" href="../styles/main.css" /> <body> <div id="wrapper"> <div id="header"></div> <div id="fullcolumn"> <h2>Photos of cars</h2> <?php include ''; include ''; $sql='SELECT * FROM images'; $result=mysql_query($sql) or die(mysql_error()); $numRows=mysql_num_rows($result); ?> <p>A total of <?php echo $numRows; ?> records were found.</p> <table> <tr> <th>image_id</th> <th>filename</th> <th>type</th> </tr> <?php while ($row=mysql_fetch_assoc ($result)) { ?> <tr> <td><?php echo $row ['image_id']; ?></td> <td><img src="images/<?php echo $row ['filename']; ?>" /><br /> <?php echo $row ['caption']; ?></td> <td><?php echo $row ['type']; ?></td> </tr> <?php } ?> </table> </div> <div id="footer"></div> </div> </body> </html> Link to comment https://forums.phpfreaks.com/topic/163191-mysql-statements-help/ Share on other sites More sharing options...
Ken2k7 Posted June 22, 2009 Share Posted June 22, 2009 You mean - SELECT * FROM images WHERE type = 'trucks'; ? Link to comment https://forums.phpfreaks.com/topic/163191-mysql-statements-help/#findComment-861020 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.