canadabeeau Posted January 10, 2010 Share Posted January 10, 2010 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 More sharing options...
canadabeeau Posted January 10, 2010 Author Share Posted January 10, 2010 am I going about this the wrong way? Link to comment https://forums.phpfreaks.com/topic/187920-php-loop/#findComment-992201 Share on other sites More sharing options...
canadabeeau Posted January 10, 2010 Author Share Posted January 10, 2010 if I use 2 different "layouts" it works but as soon as I go back to using the same layout001.php to process it all it fails to echo both articles...... any clues? Oh forgot Thanks in advance and if this is not very clear let me know Link to comment https://forums.phpfreaks.com/topic/187920-php-loop/#findComment-992202 Share on other sites More sharing options...
canadabeeau Posted January 10, 2010 Author Share Posted January 10, 2010 not quite solved if I change require_once to require it echo's the layout twice but with the same content :-( Link to comment https://forums.phpfreaks.com/topic/187920-php-loop/#findComment-992203 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.