I am very new to both PHP and MySQL. I have a MySQL database that includes a field called “max_rooms” with the values 1 or 2 set for each row in the database it applies to. In my HTML document, I have a form containing a “Rooms?” question with two choices that are radio buttons. My PHP and MySQL are connected properly; I just don’t know what to write in the Results PHP document so that the values are passed correctly.
Thanks so much for your help so far! I can understand the script you gave me, and I put that in; what do you mean by “from there you can run your insert or update query”? What else do I need in the PHP document?
Below is basically my PHP code so far (I worked with someone and thought I could move on alone, but…); for the radio buttons, would I do something like this: (it didn’t work, but…)
$sqlquery = “SELECT * FROM hallonly”;
$sqlquery .=" where max_rooms = $_POST[‘max_rooms’]";
Thanks so much!
Chava
<?php
//connect to database
$link = mysql_connect('chavad.test.com', '*******', '******');
if (!$link) {die('Could not connect: ' . mysql_error());}
//couple number validation DONT MOVE
if (filter_var($_POST['couple_number'],FILTER_VALIDATE_INT))
{
$couples = $_POST['couple_number'];
}
else
{
$couples = 0; //default number if no number specified or they put in
}
$sqlquery = "SELECT * FROM hallonly";
$sqlquery .= " where couple_min <= $couples and couple_max >= $couples";
//get the list of locations and put into sql query after surrounding with quotes
foreach($_POST['alocation'] as $x) {
$locationlist.="'".$x."',";
}
//information to display on search results
mysql_select_db("wedding_vendors");
$data = mysql_query($sqlquery) or die(mysql_error());
while($info = mysql_fetch_array( $data ))
{
$infotoprint ="