the_crazyman Posted March 24, 2007 Share Posted March 24, 2007 this probably appears quite basic, but I am a beginner. I'm performing a select statement against my database SELECT *, COUNT(column) FROM blah blah blah WHERE blah blah blah GROUP BY member what i'm trrying to do is retreive a count of a column. i.e. $variable1 = $record->variable1; $variable2 = $record->variable2; $variable3 = $record->variable3; $variable4 = $record->COUNT($variable3); I keep getting the white screen of death, caused by the $variable4 line. How do I retrieve a count? the SQL is correct as I've ran it against the database itself in the sql window. but this has me beat.. any advise greatly appreciated. Link to comment https://forums.phpfreaks.com/topic/44176-solved-count/ Share on other sites More sharing options...
MadTechie Posted March 24, 2007 Share Posted March 24, 2007 try this SELECT *, COUNT(column) theCounter FROM blah blah blah WHERE blah blah blah GROUP BY member this will change the column name to "theCounter" Link to comment https://forums.phpfreaks.com/topic/44176-solved-count/#findComment-214504 Share on other sites More sharing options...
desithugg Posted March 24, 2007 Share Posted March 24, 2007 $query = mysql_query("SELECT *,COUNT(column) as column_num from whatever where whatever = '$whatever'") or die(mysql_error()); $row = mysql_fetch_array( $query ); $count_column = $row["column_num"]; Link to comment https://forums.phpfreaks.com/topic/44176-solved-count/#findComment-214505 Share on other sites More sharing options...
the_crazyman Posted March 25, 2007 Author Share Posted March 25, 2007 cheers for replying. madtechie, used your suggestion and it worked cheers Link to comment https://forums.phpfreaks.com/topic/44176-solved-count/#findComment-214533 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.