MYSQL Querys...

Posted on Wednesday 1st August 2007 at 07:43 PM
Diablosblizz
Diablosblizz's Avatar
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
SkillMaster's Avatar
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
Diablosblizz's Avatar
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
SkillMaster's Avatar
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
Diablosblizz's Avatar
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
SkillMaster's Avatar
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
Diablosblizz's Avatar
Yes, I did that. Just edited it before you posted!

Thanks!
Posted on Wednesday 1st August 2007 at 09:22 PM
SkillMaster
SkillMaster's Avatar
nice :)

You could do total posts. for users. an total threads
Posted on Wednesday 1st August 2007 at 09:59 PM
Diablosblizz
Diablosblizz's Avatar
Hmm... possibly! :) Merci!
Posted on Saturday 4th August 2007 at 08:48 PM
SkillMaster
SkillMaster's Avatar
its okay.
Login or register to respond to this forum topic.