Jump to content

How to add integer value to count(*) function


schult70

Recommended Posts

How can I modify the following code to not display $hash_row['total'], but to display the sum of the counted "total" value + 1?  Is there a way that I can assign that variable in the "select query" area (for instance, "COUNT(hr.hasher_id) + 1 as total1"), and then call $hash_row['total1] in the result table?

 

I'm not sure if the syntax exists to add an integer value to a COUNT value and assign to a new variable...

 

<?php 
include "modules/dbase_connection.php";

#create MySQL connection
$sql_connection = sql_connect("blah","blah","blah","blah");

# select the Hashers and  hashes by total number<br />
$hash_query = "
SELECT
ha.*,
COUNT(hr.hasher_id) as total
FROM
hashers as ha,
hash_records as hr
WHERE
hr.hasher_id = ha.hasher_id
GROUP BY
         hr.hasher_id
ORDER BY
total DESC
";

$hash_result = mysql_query($hash_query) or die(mysql_error());

$x = 1;


while($hash_row = mysql_fetch_array($hash_result))
{
#display the table header
if($x == 1) {
echo '
<br />
<table align="left">
	<br />
	<tbody>
		<tr><br /><td colspan="2"><strong>Potential On-Sec</strong></td><br /></tr>';

         $x++;
}

echo '<tr><br /><td>' . $hash_row['hasher_name'] . '</td><br /><td>' . $hash_row['total'] . '</td><br /><td>- ' . $hash_row['real_name'] . '</td><br /></tr>';
}
echo '</tbody></table></td><br />';

?>

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.