Ok so I've searched and searched but still struggling to resolve my problem. This is my current php coding:
$show = "Select effectiveness, round((Count(effectiveness)* 100 / (Select Count(*) From acupuncture))) as Score
From acupuncture
Group By effectiveness
ORDER BY Score DESC";
$result = mysql_query ($show);
WHILE($show = mysql_fetch_array($result))
{
$field1 = $show[effectiveness];
$field2 = $show[Score];
echo "$field1: ";
echo "$field2%<br><br>";
}
In addition to displaying the above I would also love to display the number of rows in the table. I know the sql code is:
"SELECT COUNT(id) AS entries FROM acupuncture"
Problem is when I try to input this into my php page I keep getting errors. I want to show both SELECT statement results on the one php page. If someone can help I would greatly appreciate it.
Thank you Shikz
All good, problem has been fixed. Thanks for all your help :) PS This is the code I inputted:
$size = @mysql_query("SELECT COUNT(*) AS `total` FROM acupuncture");
$query = mysql_fetch_array($size);
echo "Number of entries: ";
echo $query['total'];
echo "<br><br>";
I was writing up the php code incorrectly before, but now all good. Thanks again.
Try this:
while($show = mysql_fetch_assoc($result))
{
$field1 = $show['effectiveness'];
$field2 = $show['Score'];
echo "$field1: ";
echo "$field2%<br/><br/>";
}
To cound all rows found read here
Small hints:
Make change in
WHILE($show = mysql_fetch_array($result))
{
$field1 = $show[effectiveness];
$field2 = $show[Score];
echo "$field1: ";
echo "$field2%<br><br>";
}
TO
WHILE($row= mysql_fetch_array($result))
{
$field1 = $row[effectiveness];
$field2 = $row[Score];
echo "$field1: ";
echo "$field2%<br><br>";
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.