Jump to content

Help Displaying all Records Selected


dannyone

Recommended Posts

Hey, i have used phpmyadmin and my query works fine and displays all the correct records. however now i am trying to show them in html and its seems that it isn't storing some of the values i am selecting. il show you my code so i can explain better

 

$days = array('mon' => '', 'tue'  => '', 'wed'  => '', 'thu'  => '', 'fri'  => '');

// Add our list of days to our time slots
$times = array(
'9-10' => $days,
'10-11' => $days,
'11-12' => $days,
'12-1' => $days,
'1-2' => $days,
'2-3' => $days,
'3-4' => $days);

// Connect to DB and run our query

$sql = new mysqli('localhost', 'danny', 'danny', 'tutorial');
$run = $sql->query("SELECT Marker_Rooms.Room_ID2, Rooms_Free.Room_ID, Rooms_Free.timeslot, Rooms_Free.day, Rooms_Free.status FROM Marker_Rooms, Rooms_Free WHERE Marker_ID = '101' AND Marker_Rooms.Room_ID = Rooms_Free.Room_ID AND Rooms_Free.status = '0' UNION SELECT Marker_Rooms.Room_ID1, Rooms_Free.Room_ID, Rooms_Free.timeslot, Rooms_Free.day, Rooms_Free.status FROM Marker_Rooms, Rooms_Free WHERE Marker_ID = '101' AND Marker_Rooms.Room_ID1 = Rooms_Free.Room_ID AND Rooms_Free.status = '0' UNION SELECT Marker_Rooms.Room_ID2, Rooms_Free.Room_ID, Rooms_Free.timeslot, Rooms_Free.day, Rooms_Free.status FROM Marker_Rooms, Rooms_Free WHERE Marker_ID = '101' AND Marker_Rooms.Room_ID2 = Rooms_Free.Room_ID AND Rooms_Free.status = '0'");

while($row = $run->fetch_object())
{
$times[$row->timeslot][$row->day] = "<input type=radio name=radio[] id=radio[] value= $row->id/> $row->Room_ID <br> <input type=radio name=radio[] id=radio[] value= $row->id/> $row->Room_ID1 <br> <input type=radio name=radio[] id=radio[] value= $row->id/> $row->Room_ID2";

//////////////////////////////////////////////////////////////// above is my problem!



}

$body = <<< endBody
<center>
<table align="center" border="1" cellspacing="0" cellpadding="1">
	<tr>
		<th align="center">Time</th>
		<th align="center">Monday</th>
		<th align="center">Tuesday</th>
		<th align="center">Wednesday</th>
		<th align="center">Thursday</th>
		<th align="center">Friday</th>
	</tr>
endBody;
// For each time slot, check each day for a value
// If one exists, display it, if not, display an empty table data (<td>)
foreach($times as $timeslot => $day)
{
$body .= "\n\t\t<tr>\n\t\t\t<td>$timeslot</td>";
foreach($day as $course)
{
	$td = (strlen($course) > 0) ? $course : ' ';
	$body .= "\n\t\t\t<td>$td</td>";
}
$body .= "\n\t\t</tr>";
}

$body .= "\n\t</table>\n</center";


?>

<?=$body?>

 

i am trying to show all the Room_ID's with a radio button that have status 0. however it doesn't work, it just show Room_ID, not Room_ID1 or Room_ID2. i have tried just using Room_ID1 and nothing appears so i guess im not selecting it properly.

 

does any1 have any ideas?

 

Thanks

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.