Forgot Password / Register
Site Statistics
Total Members: 520
Total Tutorials: 242
Newsest User: 8884244477
Todays Unique Hits: 593
0 Users 2 Guests Online
Forum Index » PHP + MySQL » MYSQL Querys...
Posted on Wednesday 1st August 2007 at 07:43 PM
Diablosblizz
templates/default/images/noavatar.png's Avatar
Senior Member
Hey, I was wondering if there was a way to display the newest things submitted into a database (ordered by ID, so it would start at the highest number ID, and go down).

I want it to display 5 of them, is this possible?

Thanks!
Posted on Wednesday 1st August 2007 at 08:05 PM
SkillMaster
templates/default/images/noavatar.png's Avatar
Senior Member
Code

$query = mysql_query("SELECT * FROM `members` ORDER BY `id` DESC LIMIT 0, 5");
while ($value = mysql_fetch_array))
{
echo ("- $value[username]<br>");
}

Try it
Posted on Wednesday 1st August 2007 at 08:46 PM
Diablosblizz
templates/default/images/noavatar.png's Avatar
Senior Member
I get - m by m times like 1500...

I had to change the code a bit:

Code
<?php
include('members/config.php');
$query = mysql_query("SELECT * FROM `forum_thread` ORDER BY `id` DESC LIMIT 0, 5");
while ($value = mysql_fetch_array)
{
echo ("- $value[title] by $value[poster]<br>");
}
?>


:S
Posted on Wednesday 1st August 2007 at 08:50 PM
SkillMaster
templates/default/images/noavatar.png's Avatar
Senior Member
try
Code

<?php
include('members/config.php');
$query = mysql_query("SELECT * FROM `forum_thread` ORDER BY `id` DESC");
while ($value = mysql_fetch_array)
{
echo ("- $value[title] by $value[poster]<br>");
}
?>
Posted on Wednesday 1st August 2007 at 09:00 PM
Diablosblizz
templates/default/images/noavatar.png's Avatar
Senior Member
Code
<?php
include('members/config.php');
$query = mysql_query("SELECT * FROM `forum_thread` ORDER BY `id` DESC");
while ($value = mysql_fetch_array($query))
{
echo ("- $value[title] by $value[poster]<br>");
}
?>


Something simple, forgot the ($query) on the array part! I was able to fix it! Works too, merci!
Posted on Wednesday 1st August 2007 at 09:14 PM
SkillMaster
templates/default/images/noavatar.png's Avatar
Senior Member
do the first code it only does the first 5
Code

<?php
include('members/config.php');
$query = mysql_query("SELECT * FROM `forum_thread` ORDER BY `id` DESC LIMIT 0, 5");
while ($value = mysql_fetch_array($query))
{
echo ("- $value[title] by $value[poster]<br>");
}
?>
Posted on Wednesday 1st August 2007 at 09:16 PM
Diablosblizz
templates/default/images/noavatar.png's Avatar
Senior Member
Yes, I did that. Just edited it before you posted!

Thanks!
Posted on Wednesday 1st August 2007 at 09:22 PM
SkillMaster
templates/default/images/noavatar.png's Avatar
Senior Member
nice :)

You could do total posts. for users. an total threads
Posted on Wednesday 1st August 2007 at 09:59 PM
Diablosblizz
templates/default/images/noavatar.png's Avatar
Senior Member
Hmm... possibly! :) Merci!
Posted on Saturday 4th August 2007 at 08:48 PM
SkillMaster
templates/default/images/noavatar.png's Avatar
Senior Member
its okay.