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

Link to comment
Share on other sites

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

 

}

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.