hey i desperately need to know the answer for a project if anyone can help...

i and retrievin info from a DB and desplayin it in a dynamic table. then if the <select value='1'> in the form i need to send a variable accross to another page.

the code is like this:

$href = "HowManyPeople.php?daysOfMonth=".$dayArrive."&monthOfYear=".$month."&year=".$year."&nights=".$nights;

require("dbCon.php");

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

        echo "<form id='form1' name='form1' method='post' action='".$href."'>";

        while($row = mysql_fetch_assoc($res))
        {
            echo "<div id='RoomBorder'>";
            echo "<table width='100%'><tr><th colspan='2'>". $row["[COLOR="Red"]RoomName[/COLOR]"] ."</th></tr>";
            echo "<tr><td colspan='2' align='left'>".$row["[COLOR="Red"]Description[/COLOR]"]."</td></tr>";
            echo "<tr><td><b>Max Guests ".$row["[COLOR="Red"]RoomCapacity[/COLOR]"]."</b></td><td><b>Rates</b></td></tr>";
            echo "<tr><td></td><td>".$row["[COLOR="Red"]RoomInSeasonPrice[/COLOR]"]."</td></tr>";
            echo "<tr><td>[COLOR="Green"]How many units do you require: <select name='HowManyUnits' id='HowManyUnits'>[/COLOR]
                            [COLOR="Red"]<option selected='selected' value='0'>Units</option>
                            <option value='1'>1</option>[/COLOR]
                          </select></td><td align='Left'><input type[COLOR="Red"]='submit' name='Next' id='Next' value='Next'[/COLOR]/></td></tr>";
            echo "</table><br><br>";
            echo "</div><br>";
        }

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

so there will be multiple tables with info about each room in each. then if the value from the <options> tag is == 1 i need to send across the 'RoomName'. then i can reconnect to the DB and retrieve all info for that room.

please if anyone can help it is urgent.

many thanks

I'm not sure that I totally understand your question based on your explanation but let me take a stab at it. If I understood it incorrectly, then you'll need to clarify:

If you need to send the RoomName from module to module2 that is just a (straightforward) use of a form variable. Your option (0 or 1) will be sent to module2 and so will the room name. You can do this as a free form entry of a text field (not the best solution) or provide them with a drop-down list that you load with all of the possible room names or have a checkbox or radio button beside each room that you are displaying in the first module. Whichever way you do it, module2 will know which room name to use when it reads the database.

require("dbConnect.php");

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

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

    $i = 1;

    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["Description"]."</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[]' value='".$i."'/></td><td align='Left'><input type='submit' name='Next' id='Next' value='Next' /></td></tr>";
        echo "</table><br><br>";
        echo "</div><br>";

        $i++;
    }

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

third.php

if(isset($_POST['SelectRoom[]']))
{
    for($j = 0; $j<='SelectRoom[]'; $j++)
    {
        echo "SelectRoom[".$j."]";
    }
}

does this look sort of right...?????????

so basically i need to get the checked check boxes and display the Room name for each.

can you give me any advice??

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.