champolot Posted March 18, 2013 Share Posted March 18, 2013 please help me in my problem ... first is it will show the room available and then the user will select a room(there are 3 rooms that can be reserve)...i want it can select more than 2 room....after that reserve.php will show, it will show the room id and room type selected... (continued the question below) ----this is my code in showing the datas from the database----- ROOM.PHP <?php$con = mysql_connect("localhost","root","");if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("shoopingcart", $con);function formatMoney($number, $fractional=false) { if ($fractional) { $number = sprintf('%.2f', $number); } while (true) { $replaced = preg_replace('/(-?\d+)(\d\d\d)/', '$1,$2', $number); if ($replaced != $number) { $number = $replaced; } else { break; } } return $number;} $result = mysql_query("SELECT * FROM room");while($row = mysql_fetch_array($result)) { $a=$row['room_id']; $query = mysql_query("SELECT sum(qty_reserve) FROM rooinventory where arrival <= '$arival' and departure >= '$departure' and room_id='$a'");while($rows = mysql_fetch_array($query)) { $inogbuwin=$rows['sum(qty_reserve)']; } $angavil = $row['qty'] - $inogbuwin; echo '<div style="height: 117px;">'; echo '<div style="float: left; width: 100px; margin-left: 19px;">'; echo "<img width=92 height=72 alt='Unable to View' src='" . $row["image"] . "'>"; echo '</div>'; echo '<div style="float: right; width: 575px; margin-top: -10px;">'; echo '<span class="style5">'.'Avalable Rooms: '.$angavil.'</span>'; if ($angavil > 0){ echo '<input name="roomid[]" type="checkbox" value="' .$row["room_id"]. '" />'; echo '<input type="submit" name="Submit" value="reserve" onclick="setDifference(this.form);"/>'; } if ($angavil <= 0){ echo '<span class="style5"> '.'NO VACANT!'.'</span>'; } echo '<br>'; echo '<input name="typs" type="hidden" value="'.$row['type'].'"/>'; echo '<span class="style5">'.'Room Type: '.$row['type'].'</span><br>'; echo '<span class="style5">'.'Room Rate: '.$row['rate'].'</span><br>'; echo '<input name="avail" type="hidden" value="' .$angavil. '" />'; }mysql_close($con);?> </form> there will be an array to show the datas from the checkbox...and the data from the checkbox will be put in the textbox...then ill save the data...if the user selected 2 rooms there will be a 2 data saved...there will be a 2 data saved so that i can search what are the available rooms to be reserve... RESERVE.PHP <?php $checkBox = $_POST['roomid']; for($i=0; $i<sizeof($checkBox); $i++){ echo $checkBox[$i]; } if($checkBox[$i] == '1') { $a=1; } if($checkBox[$i] == '2') {b=1; } <input name="start" type=text value="<?php echo $checkBox[1] ?>"/> <input name="start" type=text value="<?php echo $checkBox[1] ?>"/> so thats my question Quote Link to comment https://forums.phpfreaks.com/topic/275806-hotel-reservationget-checkbox-value-and-save-to-database/ Share on other sites More sharing options...
yomanny Posted March 18, 2013 Share Posted March 18, 2013 Can you please put the code inside code tags so it's readable? (the <> icon in the WYSIWYG editor) =) - W Quote Link to comment https://forums.phpfreaks.com/topic/275806-hotel-reservationget-checkbox-value-and-save-to-database/#findComment-1419280 Share on other sites More sharing options...
champolot Posted March 18, 2013 Author Share Posted March 18, 2013 here is my full code roomy.php Quote Link to comment https://forums.phpfreaks.com/topic/275806-hotel-reservationget-checkbox-value-and-save-to-database/#findComment-1419283 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.