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

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

Something Non-Traditional. Can we solve?
I have an idea for an application here. It's mostly flash, but it couldn't work without a somewhat n

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

problems with php variables in mysql query
i can't seem to get the following query to work.

select $q1c from $vote_rate where id = $re

Batch update record with Pagination
Hoping someone can help me with this issue I'm having, im trying to batch update records from a resu

Shuffle Array
Hi,

I am writing a script for a game that needs players to randomly be assigned a target (ano

Big O & time complexity ???
can you help me how to calculate the Big O & time complexity for any algorithm and c++ program pleas

session checking in page load
hai all I have a web site is www.Mryas.com in this my login page is Page1.aspx its co

Call db table from any PHP file
Hi,

I want to be able to call a database table that will be setup in another file called init

PHP submit form script causing blank page
Im trying to submit a form using this script, however nothing shows up on the page, does anyone know

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