Jump to content

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 />';

?>

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.