Output to columns php mysql
Posted: Sat Feb 17, 2007 5:16 pm
Hello all,
i have this code that display results in the format
Department A
user1
user2
user3
Department B
user1
user2
user3
below is my code, i have a table called staff departments with the fields dep_id and dep_name and a table for users that holds the staff_departent name;
Code:
My question is, how can i make it display the results in the format (columns)
Department A | Department B
and the users under each department
thanks for any help in advance.
i have this code that display results in the format
Department A
user1
user2
user3
Department B
user1
user2
user3
below is my code, i have a table called staff departments with the fields dep_id and dep_name and a table for users that holds the staff_departent name;
Code:
Code: Select all
<?
include "inc/staffdirectory.php";
$result = @mysql_query("SELECT DISTINCT dep_name from staff_departments ORDER BY dep_name ASC");
While($row = @mysql_fetch_array($result)) {
echo "<strong>$row[dep_name]</strong><br>"; // Category A, B, etc...
$result2 = @mysql_query("SELECT staff_name, staff_lastname, staff_title, staff_phone from users where staff_office = '$row[dep_name]'");
While($row2 = @mysql_fetch_array($result2)) {
echo "$row2[staff_name]";
echo " ";
echo "$row2[staff_lastname]";
echo " ";
echo "$row2[staff_title]";
echo " ";
echo "$row2[staff_phone]<br>";
} //End Product Loop
} // End Category Loop}
?>
Department A | Department B
and the users under each department
thanks for any help in advance.