Jump to content

PHP not displaying items..


yeochinh

Recommended Posts

Hi guys,

Im currently having problems with this code:

$query  = ("SELECT COUNT(faculty.FacultyID),department.departmentname,building.buildingname FROM faculty JOIN department JOIN building WHERE faculty.departmentID = department.departmentID && department.buildingID = building.buildingID GROUP BY departmentname");

 

$result = mysql_query($query);

 

while($row = mysql_fetch_array($result, MYSQL_ASSOC))

{

    echo "Total Number of Faculty :".$row[0]. " <br>";

    echo    "Department Name : ".$row[1] ." <br>";

    echo    "Building Location : ".$row[2]." <br><br>";

}

 

Although it loops 11 times (which is the number of items), it doesnt display the content of each row.  Any advice? Thanks

 

 

 

Thanks :D

Link to comment
https://forums.phpfreaks.com/topic/185379-php-not-displaying-items/
Share on other sites

Hi, I've tried doing what you said. but it still didn't show any result.

 

This is the code that I used:

 

$query  = ("SELECT COUNT(faculty.FacultyID),department.departmentname,building.buildingname FROM faculty JOIN department JOIN building WHERE faculty.departmentID = department.departmentID && department.buildingID = building.buildingID GROUP BY departmentname");

 

$result = mysql_query($query);

 

while($row = mysql_fetch_array($result, MYSQL_ASSOC))

{

    echo "Total Number of Faculty :".$row['faculty.facultyID']. " <br>";

    echo    "Department Name : ".$row['department.departmentName'] ." <br>";

    echo    "Building Location : ".$row['building.buildingName']." <br><br>";

}

 

 

Advice please.

:)

 

 

Thank You! :D

Your code should be

echo "Total Number of Faculty :".$row['COUNT(faculty.FacultyID)']. " <br>";

    echo    "Department Name : ".$row['departmentName'] ." <br>";

    echo    "Building Location : ".$row['buildingName']." <br><br>";

I've solved it!

I used MYSQL_NUM :)

 

$query  = ("SELECT COUNT(faculty.FacultyID),department.departmentname,building.buildingname FROM faculty JOIN department JOIN building WHERE faculty.departmentID = department.departmentID && department.buildingID = building.buildingID GROUP BY departmentname");

 

$result = mysql_query($query);

 

while($row = mysql_fetch_array($result, MYSQL_NUM))

{

    echo "Total Number of Faculty :".$row[0]. " <br>";

    echo    "Department Name : ".$row[1] ." <br>";

    echo    "Building Location : ".$row[2]." <br><br>";

}

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.