select variable
Posted: Wed Jun 03, 2009 4:17 am
hello need some help.
i need to parse through a select variable from a select drop down box to run an if else statement on the posted page.
<form action="availiable.php" method="post">
<fieldset>
<select>
<option>Choose A Chalet:</option>
<option value="<?php echo "$caswell" ;?></option>
<option value="<?php echo "$oxwich" ;?></option>
</select>
</fieldset>
<input type="submit" value="Check Availiability" />
</form>
i need to catch whether caswell or oxwich was selected on the availiable.php page to run a query on the database.
availiable.php file.
<?php include("conninfo.php");
$caswell=$_POST['caswell'];
$oxwich=$_POST['oxwich'];
$strDB=mysql_connect($strServer,$strUser,$strPwd)or die("Could not open database");
$database=mysql_select_db("$strDatabase",$strDB);
if (caswell); {
$query=("SELECT * FROM bookingdates WHERE chaletname like 'Caswell' AND booked=0");
$result = mysql_query($query) or die("Couldn't execute query");?>
if (oxwich); {
$query=("SELECT * FROM bookingdates WHERE chaletname like 'oxwich' AND booked=0");
$result = mysql_query($query) or die("Couldn't execute query");?>
<table width="439" border="1">
<?
while($r=mysql_fetch_array($result))
{
?>
<tr>
<td width="130"><?php echo $r["chaletname"];?></td>
<td width="61"><?php echo $r["startmonth"];?></td>
<td width="67"><?php echo $r["startday"];?></td>
<td width="71"><?php echo $r["endmonth"];?></td>
<td width="82"><?php echo $r["endday"];?></td>
<td width="67"><?php echo $r["year"];?></td>
<td width="116"><?php echo $r["weekprice"];?></td>
</tr>
<?
}
?>
can someone please help, sorry in advance really new to php.
i need to parse through a select variable from a select drop down box to run an if else statement on the posted page.
<form action="availiable.php" method="post">
<fieldset>
<select>
<option>Choose A Chalet:</option>
<option value="<?php echo "$caswell" ;?></option>
<option value="<?php echo "$oxwich" ;?></option>
</select>
</fieldset>
<input type="submit" value="Check Availiability" />
</form>
i need to catch whether caswell or oxwich was selected on the availiable.php page to run a query on the database.
availiable.php file.
<?php include("conninfo.php");
$caswell=$_POST['caswell'];
$oxwich=$_POST['oxwich'];
$strDB=mysql_connect($strServer,$strUser,$strPwd)or die("Could not open database");
$database=mysql_select_db("$strDatabase",$strDB);
if (caswell); {
$query=("SELECT * FROM bookingdates WHERE chaletname like 'Caswell' AND booked=0");
$result = mysql_query($query) or die("Couldn't execute query");?>
if (oxwich); {
$query=("SELECT * FROM bookingdates WHERE chaletname like 'oxwich' AND booked=0");
$result = mysql_query($query) or die("Couldn't execute query");?>
<table width="439" border="1">
<?
while($r=mysql_fetch_array($result))
{
?>
<tr>
<td width="130"><?php echo $r["chaletname"];?></td>
<td width="61"><?php echo $r["startmonth"];?></td>
<td width="67"><?php echo $r["startday"];?></td>
<td width="71"><?php echo $r["endmonth"];?></td>
<td width="82"><?php echo $r["endday"];?></td>
<td width="67"><?php echo $r["year"];?></td>
<td width="116"><?php echo $r["weekprice"];?></td>
</tr>
<?
}
?>
can someone please help, sorry in advance really new to php.