Board index   FAQ   Search  
Register  Login
Board index php forum :: Database mySQL & php coding

Newbie - Limited results from MySQL query

Codes here !

Moderators: macek, egami, gesf

Newbie - Limited results from MySQL query

Postby Cpt_veerhoek » Wed Mar 19, 2003 2:11 pm

Hello,

I want to add a box to the main page of my site, so everybody can see what the latest additions are. I already have a good script that lists all entries. My problem is that I don't know how to limit the entries shown, to let's say 10 results.
Can anybody tell me how to make/modify my current script so it will show only the latest 10 results?

Thanx in advance
Cpt_veerhoek
New php-forum User
New php-forum User
 
Posts: 2
Joined: Wed Mar 19, 2003 2:03 pm
Location: Netherlands, Europe

Postby Xerpher » Wed Mar 19, 2003 4:00 pm

Silly question... what code are you using? :P
Xerpher
New php-forum User
New php-forum User
 
Posts: 164
Joined: Tue Aug 27, 2002 8:25 pm
Location: Ontario, Canada

Postby Cpt_veerhoek » Wed Mar 19, 2003 10:35 pm

Oops, forgot that, was going to put it in the original post, but I was too tired to think clearly... :(

<?php
require "ezine_db.inc.php";
$ezine_db = ezine_connecte_db();

$str_requete = "SELECT id,stof,auteur,grootte,vak FROM artikel WHERE affichage='$affichage' ORDER BY date DESC";

$result_articles = mysql_query ($str_requete,$ezine_db) or ezine_mysql_die();

print ('<center><table border="1" cellspacing="0">');
print("
<tr>
<td><center><b>Vak</b></td>
<td><center><b>Stof</b></td>
<td><center><B>Auteur</B></td>
<td><center><b>Grootte</b></td>
<td><center><b>Download Link</b></td>
</tr>
");
while ($articleDb =mysql_fetch_object($result_articles))
{
print("
<tr>
<td><center>$articleDb->vak</td>
<td><center>$articleDb->stof</td>
<td><center>$articleDb->auteur</td>
<td><center>$articleDb->grootte</td>
<td><center><a href='download.php?id=$articleDb->id'>Download nu!</a></td>
</tr>
");
}

print ('</table></center>');

?>
Cpt_veerhoek
New php-forum User
New php-forum User
 
Posts: 2
Joined: Wed Mar 19, 2003 2:03 pm
Location: Netherlands, Europe

Postby Romantik » Thu Mar 20, 2003 2:10 am

use LIMIT
read http://www.mysql.com part documentation


Code: Select all
$str_requete = "SELECT id,stof,auteur,grootte,vak FROM artikel WHERE affichage='$affichage' ORDER BY date DESC LIMIT 10";
Romantik
New php-forum User
New php-forum User
 
Posts: 67
Joined: Mon Feb 24, 2003 2:55 am
Location: ../Ukraine/Kherson

Limited results from MySQL query

Postby wmdrumaizi » Thu Apr 10, 2003 12:59 am

Hi Romantic, I've used limit and it worked. But could you tell me how to navigate from one page to next page and so on

Thanks in advance
User avatar
wmdrumaizi
New php-forum User
New php-forum User
 
Posts: 40
Joined: Thu Jan 23, 2003 5:15 pm
Location: Malaysia


Return to mySQL & php coding

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.