Jump to content

[SOLVED] Counting and last entries in a submit form?


Mike088

Recommended Posts

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 :)

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>";

 

}

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 ;-)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.