PHP loop


Posted on 16th Feb 2014 07:03 pm by admin

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
Code: <?php article_layout();?> (yes there is a require one to get the function but that works)

then page_layout is this
Code: <?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?

No comments posted yet

Your Answer:

Login to answer
97 Like 22 Dislike
Previous forums Next forums
Other forums

why does my session end?
my connect.php starts the session just so you know
i can navigate arround my site fine except whe

Help With editting and deleting form
So look at this image :

http://img194.imageshack.us/img194/8272/snapshot5f.png
This table

Cache PHP Objects/Classes?
Does anyone have ideas about caching PHP objects using something like: http://memcached.org/

ImageCreate()
When I create an image and add text to it I want my text to be replaced with a PNG image, because th

Not adding to db
Hi, I can't figure out why it won't add the record to the database. It's just a simple form to get

Simpler method of getting variables from mysql
Hi Guys,

I'm trying to streamline my CMS's code and as I was writing a new page it occured to

Oracle Connectivity
Hi Every One,

Can we access SAP from oracle database.If it possible then please spec

DELETE FROM not working deletes wrong row
Hello

I have the following code which i found but it doesnt work properly.. it comes up with

Display data returned from Ajaxservices!!
I have a question about displaying results using ajax. I have part of the code below.
$.ajax({

Printing a webpage
I use this to print the webpage: o

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash