Howto php?

All about creating websites!
Post Reply
User avatar
1r0l3
suck-o-fied!
suck-o-fied!
Posts: 69
Joined: 18 Jul 2009, 16:00
14

Howto php?

Post by 1r0l3 »

Hello guyse, again ;)

I got this problem, i want a "overview" system of some articles, and it to print all the articles there is in my database, i want to do it with a sql query like:
$show = mysql_query("SELECT * FROM news") or die(mysql_error());
then i want it to show whats in news, with a while loop are something like that, but anyone could give me an example how to do it ? what mysql_fecth should i choose and how to do it?

Thanks from 1r0l3, again :D

User avatar
Gogeta70
^_^
^_^
Posts: 3275
Joined: 25 Jun 2005, 16:00
18

Post by Gogeta70 »

I would do something like this:

Code: Select all


if(!@$query = mysql_query("SELECT * FROM news"))
{
    echo mysql_error();
    die();
}

while($row = mysql_fetch_assoc($query))
{
  // handle the database output here
}

I hope that helps.
¯\_(ツ)_/¯ It works on my machine...

User avatar
1r0l3
suck-o-fied!
suck-o-fied!
Posts: 69
Joined: 18 Jul 2009, 16:00
14

Post by 1r0l3 »

Thanks alot gogeta, got it working now ! :D

User avatar
Gogeta70
^_^
^_^
Posts: 3275
Joined: 25 Jun 2005, 16:00
18

Post by Gogeta70 »

No problem ^_^
¯\_(ツ)_/¯ It works on my machine...

Post Reply