Hello everyone,
I’m practicing PHP by giving myself random assignments to complete. I managed to select and query data from a mysql database table and echo it out into my php page.
My question is: How can I create some logic in my php mysql_query SELECT statement that would allow me to display records that only meet certain criteria. Such as: I have 4 columns (id, itemName, clothingType, quantity, price). I only want to display prices that are between $40 and $70 and exclude any other records.
Here is an example of my current code that displays everything:
[php]
<?php
$con=mysqli_connect(“localhost”,“root”,"",“test”);
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
			$result = mysqli_query($con,"SELECT * FROM clothes");
			
			echo "<div>";
			while($row = mysqli_fetch_array($result))
			  {
			  echo "<ul>";
			  echo "<li>" . "Name: " . $row['itemName'] . "</li>";
			  echo "<li>" . "Type: " . $row['clothingType'] . "</li>";
			  echo "<li>" . "Quantity: " . $row['quantity'] . "</li>";
			  echo "<li>" . "$" . $row['price'] . "</li>";
			  echo "</ul>";
			  }
			echo "</div>";
			mysqli_close($con);
		?>
	</div>
[/php]
Any suggestions would be great!
Thanks