PHP Forum

PHP loop

Okay so I have several "articles" stored in a mysql database and am attempting to echo those onto a PHP page.
Advertisement
so on index.php I have
Code: <?php article_layout();?> (yes there is a require one to get the function but that works)

then page_layout is this
Code: <?php
Advertisement
function article_layout(){
$uri = $_GET['uri'];
if($uri == ""){
$uri = "home";
} else {
Advertisement
$uri = $uri;
};
$mysqli = db_connect();
$qry = "SELECT * FROM `articles` WHERE `uri`='$uri'";
$result = $mysqli->query($qry, MYSQLI_STORE_RESULT);
while ($row = mysqli_fetch_array($result)){
$layout = $row['layout'];
require_once('http://'.$_SERVER['HTTP_HOST'].'/themes/default/layouts/'.$layout.'.php?uri='.$uri.'');
};
};?>
which calls the relevant layout page (so the contents it layed out correctly)
now my problem is how to make this cope with more than one article, so far it is only display one article even if it should be display two. Any ideas?
Advertisement

0 answers

No answers posted yet. Be the first to answer.

Your answer

Login to answer

Trending today: see what people are reading