Jump to content

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

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.