Jump to content

[SOLVED] PHP news error.


shyish

Recommended Posts

I'm trying to set up a simple query to get the news from a datbase...

so heres the code I used

 

<?php
$host="localhost";
$username="root";
$password="XXXXXX";
$database="vd";

mysql_connect($host,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM articles";
$result=mysql_query($query);

$num=mysql_numrows($result);

mysql_close();
?>
<?php
$i=0;
while ($i < $num) {

$title=mysql_result($result,$i,"title");
$author=mysql_result($result,$i,"Author");
$body=mysql_result($result,$i,"body");
?>

 

and then at the end of the page I got

<?php
$i++;
}
?>

 

 

And ofcourse in the table for my news in the HTML I just add $title, $body, $autor.

 

The problem is for each column in the database it repeats the entire page...

 

Help?

Link to comment
https://forums.phpfreaks.com/topic/170395-solved-php-news-error/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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