aenigma Posted May 3, 2006 Share Posted May 3, 2006 This is what I have so far:[code]$maxvalue = "SELECT MAX(id) AS id FROM news";$maxresult = mysql_query($maxvalue);$minvalue = "SELECT MIN(id) AS id FROM news";$minresult = mysql_query($minvalue);echo "Max ID is: $maxresult - Mininum ID is: $minresult";[/code]But, all I get is: Max ID is: Resource id #4 - Mininum ID is: Resource id #5 Quote Link to comment Share on other sites More sharing options...
.josh Posted May 3, 2006 Share Posted May 3, 2006 [code]$maxvalue = "SELECT MAX(id) AS id FROM news";$maxresult = mysql_query($maxvalue);$minvalue = "SELECT MIN(id) AS id FROM news";$minresult = mysql_query($minvalue);$max = mysql_fetch_array($maxvalue);$min = mysql_fetch_array($minvalue);echo "Max ID is: " . $max['id'] . " - Mininum ID is: " . $min['id'];[/code]totally quick and dirty and could be done way better. but it works. Quote Link to comment Share on other sites More sharing options...
aenigma Posted May 3, 2006 Author Share Posted May 3, 2006 Ahh, figured it out, you had a small error though. You gave me this:[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]$maxvalue = "SELECT MAX(id) AS id FROM news";$maxresult = mysql_query($maxvalue);$minvalue = "SELECT MIN(id) AS id FROM news";$minresult = mysql_query($minvalue);$max = mysql_fetch_array([!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--]$maxvalue[!--colorc--][/span][!--/colorc--]);$min = mysql_fetch_array([!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--]$minvalue[!--colorc--][/span][!--/colorc--]);echo "Max ID is: " . $max['id'] . " - Mininum ID is: " . $min['id'];[/quote]and it needed to be:[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]$maxvalue = "SELECT MAX(id) AS id FROM news";$maxresult = mysql_query($maxvalue);$minvalue = "SELECT MIN(id) AS id FROM news";$minresult = mysql_query($minvalue);$max = mysql_fetch_array([!--coloro:#000099--][span style=\"color:#000099\"][!--/coloro--]$maxresult[!--colorc--][/span][!--/colorc--]);$min = mysql_fetch_array([!--coloro:#000099--][span style=\"color:#000099\"][!--/coloro--]$minresult[!--colorc--][/span][!--/colorc--]);echo "Max ID is: " . $max['id'] . " - Mininum ID is: " . $min['id'];[/quote] Quote Link to comment Share on other sites More sharing options...
.josh Posted May 3, 2006 Share Posted May 3, 2006 well that means that you are not executing a valid query. putSELECT MIN(id) AS id FROM newsdirectly into phpmyadmin see if it returns a valid result. If it doesn't, then there's your problem. invalid query. If it does, then you may not be connecting to the database at all.edit: my bad. i used the wrong variables. should be$max = mysql_fetch_array($maxresult);$min = mysql_fetch_array($minresult); Quote Link to comment Share on other sites More sharing options...
aenigma Posted May 3, 2006 Author Share Posted May 3, 2006 I fixed it, read above. Quote Link to comment Share on other sites More sharing options...
.josh Posted May 3, 2006 Share Posted May 3, 2006 yeh i saw that and edited it hoping you hadn't read it yet but gah! too late! :) Quote Link to comment Share on other sites More sharing options...
aenigma Posted May 3, 2006 Author Share Posted May 3, 2006 Thanks a bunch for the help mate. You're a lifesaver. 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.