Hi, i have a massive problem and have to solve it by 2moro nite…
…Got the following table:
Room table> RoomID, RoomNo, Capacity
I’ve made the code in HTML, have got a text box to enter the capacity they require – this is assigned to $capacity – and an SQL query is done to pull out a room with a bigger capacity than $Capacity.
The code does nothing – gives me a blank page!
Heres the code…if you could find a problem with it – please let me know
[COLOR=Indigo]<?
$usr = “***“;
$pwd = “
$db = “***“;
$host = “
# connect to database
$cid = mysql_connect($host,$usr,$pwd);
mysql_select_db($db);
if (mysql_error()) { print “Database ERROR: ” . mysql_error(); }
?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>
</head>
<body>
<?php
if($submitupdate) {
$Capacity = $_GET[“Capacity”];
$sql = “SELECT RoomID, RoomNo, Capacity FROM Room WHERE Capacity=>$Capacity”;
$result = mysql_query($sql,$connection)
or die(“Couldn’t execute Name SELECT query”);
//Printing Results in HTML
echo “<br><br><table border=0 align=center>”;
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo “t<tr>n”;
foreach ($line as $col_value) {
echo “tt<td>$col_value</td>n”;
}
echo “t</tr>n”;
}
?>
<table bgcolor=”white” align=”center”>
<form action=”<?php echo $PHP_SELF?>” method=”get” name=”form1″>
<table>
<tr><td><b>Capacity: </b> </td><td><input type=”int” name=”Capacity” size=40></td></tr>
<input type=”Submit” name = “submitupdate” value = “Submit Request”>
</table>
</form>
<?php } ?>
</body>
</html>[/COLOR]
Thats the code…one more thing I wnated to ask – anyone know how I could put the results into a table with each column headed with the field label. The code I’m using (see “//Printing Results in HTML” in above code) just gives me a list of rows.
THANKS