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

array_combine() error
getting an "Warning: array_combine() [function.array-combine]: Both parameters should have an e

split string
Hi all

i have some names (imploded by comma):
Code: toronto,paris,madrid
Now, i would

When file included, REMOTE_ADDR is server's?
I have an index file that handles my site, basically index.php?page=ip will activate "require('

LOOPing Problem
Hello All!

The following code loops through the data and displays the data accordingly. My p

Apple's revamped lineup arrives

I'm personally curious about the magic mouse.. a multi-touch concept sounds like it could be nea

rename the file
File.txt

Code: ***DOCUMENT***
..DN:
000044255
..CB:
..SN:
..PY:
2009
..E

Delete all from a table
I can not get the following code to work. If I run the sql statement in the db it will delete all t

AUTONUMBER PROBLEM
Hello Everyone,

My name is Jones and i am new to this forum and to oracle. I am using ora

Why is this function returning a false value when it shouldn't be??
This is in an include file. I want it to check a value in an html form and see if it's just white s

php mail form text wont appear / javascript included
Guys/gals...

I am running into a problem whereby I have a great piece of javascript code that

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