scottyrob
09-05-2006, 01:36 AM
Hi
I will be using this code to count the amount of people in one of the rows in my database.
<link rel="stylesheet" href="files/main.css" type="text/css">
<?php
require("files/db_connect.php");
// Request the text of all the jokes
$result = @mysql_query('SELECT * FROM `Awards` GROUP BY `ID`');
$row = mysql_fetch_array($result);
if (!$result) {
exit('<p>Error performing query: ' . mysql_error() . '</p>');
}
$num = mysql_num_rows($result);
echo "<div>";
for ($i=0; $i<$num; $i++)
{
$row = mysql_fetch_row($result);
?>
<a href="awards_people.php?ID=<? echo "$row[0]" ?>"><? echo "$row[3]\n";
$people = array("Peter", "Joe", "Glenn", "Cleveland");
$people_res = count($people);
echo $people_res;
?></a> <Br /><? } ?><b>25</b> Explorers currently have awards!<?
echo "</div>";
?>
Outputs =
<div> <a href="awards_people.php?ID=20">* Cheif Scout's Diamond
4</a> <br> <a href="awards_people.php?ID=30">* Cheif Scout's Platinum
4</a> <br> <a href="awards_people.php?ID=40">* Cheif Scout's Gold
4</a> <br> <a href="awards_people.php?ID=50">* Duke of Edinburgh's
4</a> <br> <a href="awards_people.php?ID=60">* Explorer Belt
4</a> <br> <a href="awards_people.php?ID=70">* International
4</a> <br> <a href="awards_people.php?ID=80">* Faith
4</a> <br> <a href="awards_people.php?ID=90">* Environmental
4</a> <br> <a href="awards_people.php?ID=">
4</a> <br><b>25</b> Explorers currently have awards!</div>
Q1 = How do i get rid off that very last line? the one that has No. ID? Ive checked the DB and there dosent seem to be a blank record there...
Q2 = Currently, it counts from the people in the array above. How can i change it so it counts the people in my database?
Scott
I will be using this code to count the amount of people in one of the rows in my database.
<link rel="stylesheet" href="files/main.css" type="text/css">
<?php
require("files/db_connect.php");
// Request the text of all the jokes
$result = @mysql_query('SELECT * FROM `Awards` GROUP BY `ID`');
$row = mysql_fetch_array($result);
if (!$result) {
exit('<p>Error performing query: ' . mysql_error() . '</p>');
}
$num = mysql_num_rows($result);
echo "<div>";
for ($i=0; $i<$num; $i++)
{
$row = mysql_fetch_row($result);
?>
<a href="awards_people.php?ID=<? echo "$row[0]" ?>"><? echo "$row[3]\n";
$people = array("Peter", "Joe", "Glenn", "Cleveland");
$people_res = count($people);
echo $people_res;
?></a> <Br /><? } ?><b>25</b> Explorers currently have awards!<?
echo "</div>";
?>
Outputs =
<div> <a href="awards_people.php?ID=20">* Cheif Scout's Diamond
4</a> <br> <a href="awards_people.php?ID=30">* Cheif Scout's Platinum
4</a> <br> <a href="awards_people.php?ID=40">* Cheif Scout's Gold
4</a> <br> <a href="awards_people.php?ID=50">* Duke of Edinburgh's
4</a> <br> <a href="awards_people.php?ID=60">* Explorer Belt
4</a> <br> <a href="awards_people.php?ID=70">* International
4</a> <br> <a href="awards_people.php?ID=80">* Faith
4</a> <br> <a href="awards_people.php?ID=90">* Environmental
4</a> <br> <a href="awards_people.php?ID=">
4</a> <br><b>25</b> Explorers currently have awards!</div>
Q1 = How do i get rid off that very last line? the one that has No. ID? Ive checked the DB and there dosent seem to be a blank record there...
Q2 = Currently, it counts from the people in the array above. How can i change it so it counts the people in my database?
Scott