hello, I'm having a bit of a problem with using a left join on two mysql tables. I'm trying to work together a little scheduling page that runs weekly. My schedule table stores a staff id from the staff table and that is related to a time slot (I basically will use mod to determine the last 20 rows in the table and those in ascending order are 4 slots/day for 5 week days).
Problem is when I'm just pulling some sample data from the schedule table using a left join to grab the associated staff names, rows keep coming up blank despite having data, e.g., row 5 and row 16.
does anyone see anything inherently wrong with this code? (bugging the hell out of me).
<?php
$table= "schedule";
$dbname = "internal";
$sql = "SELECT schedule.schedule_id, staff.fname, staff.lname FROM schedule LEFT JOIN staff ON schedule.staff_id = staff.id";
//require("../files/db_func.php");
$dbuser = "removed";
$dbpass = "removed";
$host = "localhost";
$connection = @mysql_connect($host, $dbuser, $dbpass) or die(@mysql_error('connection'));
$db = @mysql_select_db($dbname, $connection) or die(@mysql_error('db'));
$result = @mysql_query($sql, $connection) or die(@mysql_error('result'));
//$result = connect($table, $sql, $db);
$count = 0;
echo "<table>\n";
echo "<tr>\n";
if(mysql_num_rows($result) > 0){
while ($row = mysql_fetch_array($result)){
$count++;
echo "<td>".$row['fname']." ".$row['lname']."ROW ID: ".$row['schedule_id']."</td> ";
if (($count % 5) == 0){
echo "</tr>\n<tr>";
}
}
echo "</tr>\n";
}
echo "</table>";
?>