Jump to content

[SOLVED] Simple COUNT and output question


thunderdogg

Recommended Posts

Guys i've set up a very simple SQL database called college. There are some variables within, one of those variables is also called college which is the var that stores the name of the college attended. I have a PHP file which allows me to see the output of all my inputs, what i'd like is at the bottom of that to have a COUNT of all the different universities represented, but i've had no luck with that. My SQL skills are low, i'm trying to teach myself with small projects like this. Please let me know what command i would need to add to the bottom of my output page (which i'll show below) so that I could output the COUNT of different universities. The output page is below at the bottom of it is the current Count Query i've put together, but it's not outputing, thanks!!

 

 

----------------

 

 

$result = mysql_query("SELECT * FROM college")

or die(mysql_error()); 

 

echo "<table border='1'>

<tr>

<th>ID</th>

<th>College</th>

<th>Major</th>

<th>Salary</th>

<th>Months</th>

<th>College Experience</th>

<th>Job Value</th>

<th>Overall Education</th>

</tr>";

while($row = mysql_fetch_array($result))

  {

  echo "<tr>";

  echo "<td>" . $row['id'] . "</td>";

  echo "<td>" . $row['college'] . "</td>";

  echo "<td>" . $row['major'] . "</td>";

  echo "<td>" . $row['salary'] . "</td>";

  echo "<td>" . $row['months'] . "</td>"; 

  echo "<td>" . $row['cexperience'] . "</td>";

  echo "<td>" . $row['job'] . "</td>";

  echo "<td>" . $row['education'] . "</td>";

  echo "</tr>";

  }

echo "</table>";

 

$count_query = mysql_query('SELECT COUNT (college) FROM college');

 

echo $count_query;

 

mysql_close($con);

?>

Link to comment
https://forums.phpfreaks.com/topic/67669-solved-simple-count-and-output-question/
Share on other sites

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.