Autor Zpráva
hrubos
Profil
Who can show me why I can't insert number of room into database when user choose room???I only can insert id_reversation well into database.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<meta http-equiv="content-type" content="text/html; charset=windows-1250">
<meta name="generator" content="PSPad editor, www.pspad.com">
<html>
<head><title>Rezevace</title></head>
<body>
<form method = "POST" action = "data.php">


<?php
require_once ("D:\htdocs\BP\db_connectFun.php");
db_connect();

$query="SELECT DISTINCT p.id_numberRoom,p.number_room,p.building,p.floor,p.state_room,
p.id_typeRoom, t.number_beg,t.price
FROM pokoj p,type_room t
WHERE p.id_typeRoom = t.id_typeRoom";

$query_numRoom = "SELECT DISTINCT p.number_room FROM pokoj p";
$result_numRoom = mysql_query($query_numRoom);
$result=mysql_query($query)or die(mysql_error());

$num=mysql_numrows($result);
mysql_close();


$i=0;

while ($i < $num ) {

$id_numberRoom=mysql_result($result,$i,"id_numberRoom");
$number_room=mysql_result($result,$i,"number_room");
$building=mysql_result($result,$i,"building");
$floor=mysql_result($result,$i,"floor");
$number_beg=mysql_result($result,$i,"number_beg");
$price=mysql_result($result,$i,"price");

?>
<tr>
<?php
$n=0;
echo "<td>$id_numberRoom</td>" ;
echo "<td>$number_room</td>" ;
echo "<td>$floor</td>";
echo "<td>$building</td>";
echo "<td>$number_beg</td>";
echo "<td>$price</td>";

if($number_beg==2) {
for($s=1;$s <=2;$s++ )
echo "<td> <input type= 'radio' value = '$n' name= 'id_reservation'></td>";
}
if($number_beg == 3){
for($s=1;$s<=3;$s++ )
echo "<td> <input type= 'radio' value = '$n' name= 'id_reservation'></td>";
}

echo "<td> <input type= 'radio' value = '$n' name= 'id_reservation'></td>";
//echo "<td> <input type= 'radio' value = '$number_room' name= 'number'></td>";
$i++ ;



db_connect();



if($number_room==$i){
$query_room = "insert into reser_1 " . "(number_room) values"
. "('$number_room')";
mysql_query($query_room) or die(mysql_error());
}

}
?>
<tr>
<td>
<input type="submit" value="Submit" name="submit">
</td>
</tr>
</tr>
</form>
</body>
</html>


//data.php
<?php
$id_reservation = $_POST['id_reservation'];
//$number = $_POST['number'];

if(!get_magic_quotes_gpc())
{
$id_reservation = addslashes($id_reservation);
}

@ $db = mysql_connect("localhost", "root","ha1985") or die("Error");
mysql_select_db("kolej",$db) or die("Can't choose database");

$query = "insert into reser_1 " . "(id_reservation) values"
. "('$id_reservation')";
mysql_query($query) or die(mysql_error());
?>
Toto téma je uzamčeno. Odpověď nelze zaslat.