store info for second query?

Hey,

Info: Site to book servers for a period of time. Servers must be activated by click of button from modal window. Modal window is activated by click of button on main page. Bootstrap is used for the framework and formatting.

Problem: There can be more than one booking to be activated at one time. I can not get the modal to load different info since it loads the info for the top booking as soon as the page loads instead of the specified booking upon the button being clicked.

Activatable bookings section:
[php]


Active Bookings



<?php
$query = “SELECT * FROM sc_booking WHERE booking_start <= “.time().” AND booking_end >= “.time().” AND usr_name = '”.$username."’ ORDER BY booking_start";
$result = mysql_query($query) or die(mysql_error());
if (mysql_num_rows($result) > 0)
{ ?>


<?php
while($data = mysql_fetch_array($result))
{
echo(“”);
}
?>
Server Date Start End
SC”.$data[1]." | “.$data[6].” ".date(“D - m/d/Y”,$data[3])." ".date(“H:i”,$data[3])." ".date(“H:i”,$data[4]).“ Activate

<?php
}
else
{
echo “No active bookings.”;
}
?>
[/php]

Modal window:
[php]



×

Activate your server




<?php
$query = “SELECT * FROM sc_booking WHERE booking_num = '”.$data[0]."’ AND usr_name = ‘".$username."’ ORDER BY booking_start LIMIT 1";
$result = mysql_query($query) or die(mysql_error());
$data = mysql_fetch_array($result)
?>

Please confirm the server information


Name: <?php echo $data[6]; ?>
Password: <?php echo $data[7]; ?>


Here is your connect code:




Close
Activate
[/php]

Now I don’t think I should be using $data[0] like this to select the booking, but it is the primary key in the database.

can anyone help me?

Sponsor our Newsletter | Privacy Policy | Terms of Service