nec9716 Posted April 24, 2008 Share Posted April 24, 2008 ok here how I have write it: $sql = 'SELECT avg (total) FROM truck '; $results = conn($sql); echo "<tr> <td >$results</td> </tr>"; but that print......Resource id #3 Quote Link to comment Share on other sites More sharing options...
haku Posted April 24, 2008 Share Posted April 24, 2008 You have to process results from mysql, you can't just use them as is. Here is one way you can get the data you want: $sql = 'SELECT avg (total) FROM truck '; $results = conn($sql); $results = mysql_result($results, 0, 0); echo "<tr> <td >$results</td> </tr>"; Quote Link to comment Share on other sites More sharing options...
wrathican Posted April 24, 2008 Share Posted April 24, 2008 you still need to fetch the array afaik. <?php $sql = 'SELECT avg (total) FROM truck '; $results = mysql_query($sql); while ($row = mysql_fetch_array($results)){ $avg = $row['total']; echo "<tr> <td >$avg</td> </tr>"; } ?> Quote Link to comment Share on other sites More sharing options...
nec9716 Posted April 24, 2008 Author Share Posted April 24, 2008 just try it and it's work fine .....sometime .....I'm surprise ....but this time ....I'm....... well I feel...... :-X. HAKU ....why you write ",0,0 here ......$results = mysql_result($results, 0, 0);.....? thank you ..... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.