Jump to content

PHP loop


canadabeeau

Recommended Posts

Okay so I have several "articles" stored in a mysql database and am attempting to echo those onto a PHP page.

so on index.php I have

<?php article_layout();?>

(yes there is a require one to get the function but that works)

 

then page_layout is this

<?php
function article_layout(){
$uri = $_GET['uri'];
if($uri == ""){
	$uri = "home";
} else {
	$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?

Link to comment
https://forums.phpfreaks.com/topic/187920-php-loop/
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.