0

hey all

i'm busy makin an online bookin system for a project. What i need is when the rooms get displayed, the customer can select, using check boxes which rooms he/she wants. ranging from 1 room to all 6 if he/she wants.

then on the next page i need only the rooms that have been checked to be displayed. finding it a bit difficult and brain is about to crash...

this is some of the code so far:

send.php

<?php


require("dbConnect.php");

    if($con)
    {
        mysql_select_db($database);
        $res = mysql_query("select * from room where RoomName not in (select RoomName from booking)");

        echo "<form id='form1' name='form1' method='post' action='recive.php'>";


        while($row = mysql_fetch_assoc($res))
        {
            echo "<div id='RoomBorder'>";
            echo "<table width='100%'><tr><th colspan='2'>". $row["RoomName"] ."</th></tr>";
            echo "<tr><td colspan='2' align='left'>".$row["RoomDescription"]."</td></tr>";
            echo "<tr><td><b>Max Guests ".$row["RoomCapacity"]."</b></td><td><b>Rates</b></td></tr>";
            echo "<tr><td></td><td>".$row["RoomInSeasonPrice"]."</td></tr>";
            echo "<tr><td>Select desired room:<input type='checkbox' name='SelectRoom[]' vaule=".$row["RoomName"]."/></td><td align='Left'>";

            echo "<input type='submit' name='Next' id='Next' value='Next' /></td></tr>";
            echo "</table><br><br>";
            echo "</div><br>";

        }       
        //<!--End of div RoomBorder-->
        echo "</form>";
    }
?>

then recive.php

<?php

require('dbConnect.php');

if($con)
{
    mysql_select_db($database);
    $res = mysql_query("Select * from room");

    while($row = mysql_fetch_assoc($res))
    {
        if(isset($_POST['Next']))
        {
            echo $_POST['SelectRoom'][$i]."<br>";
        }
        $i++;
    }
}

?>

if anyone can help me out i'd be so so so so so so so stoked... just don't know what to do anymore...

thank you pl

Edited by mike_2000_17: Fixed formatting

2
Contributors
8
Replies
9
Views
6 Years
Discussion Span
Last Post by P0lT10n
0

well i have got it to give me the 'on' value for each check box that is checked.
however it should be sending the value - being the RoomName - across and displaying them. Not "on"... which means it has a value i think???

code for the fist page is the same:
----------------------------------

require("dbConnect.php");
		
	if($con)
	{
		mysql_select_db($database);
		$res = mysql_query("select * from room where RoomName not in (select RoomName from booking)");

		echo "<form id='form1' name='form1' method='post' action='recive.php'>";
	
		
		while($row = mysql_fetch_assoc($res))
		{
			echo "<div id='RoomBorder'>";
			echo "<table width='100%'><tr><th colspan='2'>". $row["RoomName"] ."</th></tr>";
			echo "<tr><td colspan='2' align='left'>".$row["RoomDescription"]."</td></tr>";
			echo "<tr><td><b>Max Guests ".$row["RoomCapacity"]."</b></td><td><b>Rates</b></td></tr>";
			echo "<tr><td></td><td>".$row["RoomInSeasonPrice"]."</td></tr>";
			echo "<tr><td>Select desired room:<input type='checkbox' name='SelectRoom[]' vaule='".$row["RoomName"]."'/></td><td align='Left'>";
			
			echo "<input type='submit' name='Next' id='Next' value='Next' /></td></tr>";
			echo "</table><br><br>";
			echo "</div><br>";
			
		}
		
		//<!--End of div RoomBorder-->
		echo "</form>";
	}

here is my code for the reciving page:
----------------------------
recive.php
----------

require('dbConnect.php');

if($con)
{
	mysql_select_db($database);
	
	extract($_POST);

        if(is_array($SelectRoom))
        {
	   foreach($SelectRoom as $value)
	   {
		echo $value;
	   }
        }
}

if anyone can see what i'm doing wrong pl drop me a line

shot

Edited by Ezzaral: Added code tags. Please use them to format any code that you post.

0

delete this post and post it again but put your code between CODE TAGS...

Edited by mike_2000_17: Fixed formatting

0
require("dbConnect.php");
		
	if($con)
	{
		mysql_select_db($database);
		$res = mysql_query("select * from room where RoomName not in (select RoomName from booking)");

		echo "<form id='form1' name='form1' method='post' action='recive.php'>";
	
		
		while($row = mysql_fetch_assoc($res))
		{
			echo "<div id='RoomBorder'>";
			echo "<table width='100%'><tr><th colspan='2'>". $row["RoomName"] ."</th></tr>";
			echo "<tr><td colspan='2' align='left'>".$row["RoomDescription"]."</td></tr>";
			echo "<tr><td><b>Max Guests ".$row["RoomCapacity"]."</b></td><td><b>Rates</b></td></tr>";
			echo "<tr><td></td><td>".$row["RoomInSeasonPrice"]."</td></tr>";
			echo "<tr><td>Select desired room:<input type='checkbox' name='SelectRoom[]' vaule='".$row["RoomName"]."'/></td><td align='Left'>";
			
			echo "<input type='submit' name='Next' id='Next' value='Next' /></td></tr>";
			echo "</table><br><br>";
			echo "</div><br>";
			
		}
		
		//<!--End of div RoomBorder-->
		echo "</form>";
	}

----------------------
recive.php
----------

1.
      require('dbConnect.php');
   2.
       
   3.
      if($con)
   4.
      {
   5.
      mysql_select_db($database);
   6.
       
   7.
      extract($_POST);
   8.
       
   9.
      if(is_array($SelectRoom))
  10.
      {
  11.
      foreach($SelectRoom as $value)
  12.
      {
  13.
      echo $value;
  14.
      }
  15.
      }
  16.
      }

ok code is between code tags...

any idea's to help???

0

if your code dont works is because you used "" between an echo... i mean, calling a variable array with "" inside an echo... you should fix this

echo "<div id='RoomBorder'>";
echo "<table width='100%'><tr><th colspan='2'>". $row["RoomName"] ."</th></tr>";
echo "<tr><td colspan='2' align='left'>".$row["RoomDescription"]."</td></tr>";
echo "<tr><td><b>Max Guests ".$row["RoomCapacity"]."</b></td><td><b>Rates</b></td></tr>";
echo "<tr><td></td><td>".$row["RoomInSeasonPrice"]."</td></tr>";
echo "<tr><td>Select desired room:<input type='checkbox' name='SelectRoom[]' vaule='".$row["RoomName"]."'/></td><td align='Left'>";

to this

echo "<div id='RoomBorder'>";
echo "<table width='100%'><tr><th colspan='2'>".$row['RoomName']."</th></tr>";
echo "<tr><td colspan='2' align='left'>".$row['RoomDescription']."</td></tr>";
echo "<tr><td><b>Max Guests ".$row['RoomCapacity']."</b></td><td><b>Rates</b></td></tr>";
echo "<tr><td></td><td>".$row['RoomInSeasonPrice']."</td></tr>";
echo "<tr><td>Select desired room:<input type='checkbox' name='SelectRoom[]' vaule='".$row['RoomName']."'/></td><td align='Left'>";

Edited by P0lT10n: n/a

0
require("dbConnect.php");
		
	if($con)
	{
		mysql_select_db($database);
		$res = mysql_query("select * from room where RoomName not in (select RoomName from booking)");

		echo "<form id='form1' name='form1' method='post' action='recive.php'>";
	
		
		while($row = mysql_fetch_assoc($res))
		{
			echo "<div id='RoomBorder'>";
			echo "<table width='100%'><tr><th colspan='2'>". $row['RoomName'] ."</th></tr>";
			echo "<tr><td colspan='2' align='left'>".$row['RoomDescription']."</td></tr>";
			echo "<tr><td><b>Max Guests ".$row['RoomCapacity']."</b></td><td><b>Rates</b></td></tr>";
			echo "<tr><td></td><td>".$row['RoomInSeasonPrice']."</td></tr>";
			echo "<tr><td>Select desired room:<input type='checkbox' name='SelectRoom[]' vaule='".$row['RoomName']."'/></td><td align='Left'>";
			
			echo "<input type='submit' name='Next' id='Next' value='Next' /></td></tr>";
			echo "</table><br><br>";
			echo "</div><br>";
			
		}
		
		//<!--End of div RoomBorder-->
		echo "</form>";
	}

------------
recive.php
------

require('dbConnect.php');

if($con)
{
	mysql_select_db($database);
	
		extract($_POST);

if(is_array($SelectRoom))
{
	foreach($SelectRoom as $value)
	{
		echo $value."<br>";
	}
    }

}

sigh... doesn't seem to be the problem... when i check the box the value i get on the reciving page is 'on' for as many boxes as i checked. still the same problem...

dammit - i just don't know anymore

0

Bwahahahahahahahahaha

you legend.... i was tearing my hear out. works fine now... few! thought the logic was fine - what a tit i am.

once again - shot!!!!!!!!!!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.