Mike088 Posted February 12, 2009 Share Posted February 12, 2009 Hey everyone, I am trying to accomplish something that I thought would be rather easy to find instructions on the web... however I can't find a thing ??? My dilemma is as follows. I have a submit form and I want to simply have some text below it stating the last 10 entries along with another area of text that is displaying the 10 most popular entries. I was told to try using a MySQL database for something similar to this but again can't find any information on how to do so If you could help out please feel free to it would be much appreciated Quote Link to comment Share on other sites More sharing options...
drisate Posted February 12, 2009 Share Posted February 12, 2009 Last 10 $transaction = mysql_query("SELECT * FROM table order by id desc limit 10") or die (mysql_error()); while($trans = @mysql_fetch_array($transaction)){ echo $trans[id]."<br>"; } Same thing for 10 most popular $transaction = mysql_query("SELECT * FROM table order by popular dsc limit 10") or die (mysql_error()); while($trans = @mysql_fetch_array($transaction)){ echo $trans[id]."<br>"; } Quote Link to comment Share on other sites More sharing options...
Mike088 Posted February 12, 2009 Author Share Posted February 12, 2009 Thanks for that drisate, so that's the outputing of the information? I'm new to mysql so how am I to actually get the submit form data into a mysql database to recall it? Is there any tutorials or is it something simple? Quote Link to comment Share on other sites More sharing options...
drisate Posted February 12, 2009 Share Posted February 12, 2009 Yeah th web is full of them http://www.php-mysql-tutorial.com/wikis/mysql-tutorials/insert-data-into-a-mysql-database.aspx Basacly you make a form and point the result to a php page <form action="page.php" method="POST"> Then page.php gets the vars of the form using $_POST[NAME] NAME is the name of the field <input type="text" name="username" size="20"> username would be the name Then you insert it into the database using this command $resultn = mysql_query("INSERT INTO table ('username') VALUE ('$_POST[username])")or die(mysql_error()); Of course you need to create your database first ... then your table ... then connect to the database. Find your self a tutorial and check it out in details. Good luck ;-) Quote Link to comment Share on other sites More sharing options...
Mike088 Posted February 12, 2009 Author Share Posted February 12, 2009 Thank you so much for the great help drisate Quote Link to comment Share on other sites More sharing options...
drisate Posted February 12, 2009 Share Posted February 12, 2009 np bro have fun ;-) 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.