Hi,
I am hoping someone can explain to me a better way of coding than I currently do right now. It concerns accessing the results of a SQL query stored in an array.
OK so right now I do somthing similar to this:
$rows = @mysql_query("select count(*) from debate_queue") or die(mysql_error() );
$queue = mysql_fetch_array($rows);
$total = @mysql_query("SELECT count(*) FROM debate") or die(mysql_error() );
$realtotal = mysql_fetch_array($total);
<h3>To date there are <?php echo '<span class="highlight"> ' . $realtotal[0] . '</span>'; ?> points in the debate and there are <?php echo '<span class="highlight"> ' . $queue[0] . '</span>'; ?> people in the que waiting to post a point.</h3>
The only thing is I can't help but think there is a better more efficient way to do things. It annoys me I have to create two variables for every bit of info I need from a SQL query. Plus it is going to get even more annoying as I have to now output various details of the user.
I was thinking about using something like this to try and code it better but it doesn't work:
$details = array();
$details['all'] = @mysql_query("SELECT * FROM debate");
$details['id'] = mysql_fetch_array($details['all']['0']);
echo "<h2>$details[id]</h2>";
Anyone out there help a guy write better code?
Thanks for looking.