Jump to content

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>";

}

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.