Jump to content

[SOLVED] Using forms to interrogate MySQL table


EATON106

Recommended Posts

Hi, I have a really basis form:

 

<form action="results.php" method="post">

<input type="checkbox" value="1" name="pizza">Pizza</input><br>

<input type="submit" name="submit" value="Find Food">

</form>

 

I want to find all records where the value of 1 (pizza) is in a table column called TYPES.

 

This is my code in results.php below:

 

<?php

$con = mysql_connect("localhost","username","password");

if (!$con)

 

{

die('Could not connect: ' . mysql_error());

}

 

mysql_select_db("infostore", $con);

$pizza = $_POST["pizza"];

$result = mysql_query("SELECT * FROM storedata WHERE types = .$pizza.");

while($row = mysql_fetch_array($result))

 

However, this doesn't work and I get the following message:

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /var/www/vhosts/findsomefood.co.uk/httpdocs/search/results.php on line 41

 

I assume I have the mysql_query wrong, but I am not certain as this is new to me.

 

Thanks.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.