ineedhelp Posted March 4, 2007 Share Posted March 4, 2007 Ok so im trying to learn some PhP and MySQL.. but bleh! Ive made a site where people submit their email and name eatch time they add something to my database. I would really like it to output how many times they have submited info to the database. But i have no idea how to do it, i can ofcourse get the output but then it just goes like this: joe - [email protected] joe - [email protected] bla - [email protected] bla - [email protected] joe - [email protected] joe - [email protected] bla - [email protected] where i would like it to output: joe - [email protected] has submitted 4 articles bla [email protected] has submitted 3 articles Sorry if this should be in the PHP area, as said im kind of new to it all Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/41124-solved-grrr-cant-output-info-like-i-want-it-to/ Share on other sites More sharing options...
paul2463 Posted March 4, 2007 Share Posted March 4, 2007 a couple of mysql commands you might be interested in <a href="http://www.tizag.com/mysqlTutorial/mysqlcount.php"> MySql Count() command </a> <a href="http://dev.mysql.com/doc/refman/5.0/en/distinct-optimization.html"> MySql DISTINCT() command </a> Quote Link to comment https://forums.phpfreaks.com/topic/41124-solved-grrr-cant-output-info-like-i-want-it-to/#findComment-199193 Share on other sites More sharing options...
tippy_102 Posted March 4, 2007 Share Posted March 4, 2007 Something like this should work....keeping in mind that I'm new to this so there is probably an easier way... $query_name = "SELECT DISTINCT name FROM database ORDER BY name"; $result_name = mysql_query($query_name) or die ("couldn't execute query: . mysql_error()"); while ($row = mysql_fetch_array($result_name,MYSQL_ASSOC) ) { foreach ($row as $name_found) { $query2 = "SELECT * FROM database WHERE name ='$name_found'"; $result2 = mysql_query($query2) or die ("couldn't execute query"); $numofrows_name = @mysql_num_rows($result2); echo "$name_found has submitted $numofrows_name articles"; } // end foreach } // end while That hasn't been tested, but should give you an idea of what to do. Quote Link to comment https://forums.phpfreaks.com/topic/41124-solved-grrr-cant-output-info-like-i-want-it-to/#findComment-199195 Share on other sites More sharing options...
ineedhelp Posted March 4, 2007 Author Share Posted March 4, 2007 Cheers you 2 And tippy that code worked like a charm Paul cheers for the links, some good reading there! Quote Link to comment https://forums.phpfreaks.com/topic/41124-solved-grrr-cant-output-info-like-i-want-it-to/#findComment-199222 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.