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)

Did you know?Explore Trending and Topic pages for more stories like this.
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

Floating Point Precision Loss
I'm writing a program to draw a three-dimensional cube (with a corner cut off) without using any 3D

Writing to the middle of a file
Hi I have a bit of a problem. Is there any way i can write some text to a middle of a text file. For

form problem
Hi all, I think this is going to be easy to resolve but for I have been looking at it to long and I

Restricted access to sub-folder in iis6 doesn't work?
Basically I'm trying to add restriction to sub-folder (which contains pdf) in web.config for iis6 as

IF Statement & Two Tables With Different Echoes
I'm retrieving two tables in a single query using UNION ALL, like so:

Code: $query = "SE

Compare user input to flat file data
Help...Am a complete newbie to programming so my code is prolly quite long. Am trying to verify a us

PHP and XML image gallery variable issue
I'm trying to display the large image on the same page as the thumbnails, to do that I'm passing a v

Backflush
I am looking for a report in SAP that would give me a list of all parts that are populated with a ba

a function to check directory depth
I'm working on a php script to upload files in to a set directory.
the user can select to upload

cURL Sending File as Post
This is a bit complicated, I'm just hoping someone else has run into this and knows how to do it a d

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