Includes or alternitive?
I'm trying to include files out of an array and hitting issues . At the moment I have a database set up that it looks like this
id heading_id title description thumbnail main this is for the item on stage, either image or animation link
1 1 April Kelley http://www.ben.broxie.co.uk/benwoolner/portfolioit... http://www.ben.broxie.co.uk/benwoolner/images/port... http://www.aprilkelley.org.uk/
2 1 Little Shopper http://www.ben.broxie.co.uk/benwoolner/portfolioit... http://www.ben.broxie.co.uk/benwoolner/images/port...
When I run my code it currently displays like so
I had intended it to display the description after the title but it doesn't, and what's more confusing to me is the reason why it feels the need to duplicate the first lot of data underneath the details for the second.
Anyway heres my code, all i want is to get the desciption (which in the database is just a link to an external file) to display where I want it and only the once as it goes through the array.
//connect to server and select database; you may need it
$mysqli = mysqli_connect("localhost", "xxx", "xxx", "bessent1_ben");
// sets up queries
$get_data_qry = "SELECT * FROM portfolio_content";
// sets up query calls
$get_data_res = mysqli_query($mysqli, $get_data_qry) or die(mysqli_error($mysqli));
//get and show 1st level navigation
if (mysqli_num_rows($get_data_res) < 1)
echo "<h3>We're Sorry!</h3><p>We've searched our database and couldn't find anything under that category</p>\n";
while ($data = mysqli_fetch_array($get_data_res))
$title = ucwords(stripslashes($data['title']));
$desc = $data['description'];
$thumb = $data['thumbnail'];
$stage = $data['main'];
$link = $data['link'];
$display .= "<br /><br />" .$title."<br />";
$display .= include($desc);
$display .= "<br />";
$display .= "<img src=".$thumb." /><br />";
$display .= $stage."<br />";
if (is_null($link) == false)
$display .= $link."<br /><br />";
Last edited by lil_bugga; 10-12-2010 at 11:33 PM.
Try setting the value to the first $display variable without using concatenation. I cannot test it but I think it has something to do with your $display being global.
Set it like this instead:
since you use echo within the loop.
$display = "<br /><br />" .$title."<br />";
Although, even with that I cannot explain why the description would come before the title.
Last edited by zimonyi; 10-13-2010 at 04:06 AM.
well you were right about the concatination making it duplicate the first data set. I still can't get the included files to load where I want them too, but i'm hoping it won't matter too much.
My plan is to run this php code behind the scenes and link in into flash dynamic text fields. It's displaying all the data even if its not sitting where I want it to atm, so it gives me hope that with some carefull planning I can assign the data to variables that flash can then use to load.
why again do you have to include the info from another file, and not from the database? You don't have to worry about "overcrowding the database", but you do have to worry about what content exists on the other page. Remember that $display is essentially an un-styled, un-contained string of html, which is why I suggested in your other thread that you put everything in the database, and lay it out semantically in a table.
I want these files as includes as it makes maintenace a lot easier. Rather than haveing to amend the database each time, for something so simple as maybe having to change a single letter to a complete up.
By including the url's to text documents all I have to do is edit the text document in something like notepad which makes the whole process a lot easier.
As for symantics I'm not too worried about them. At the moment I'm just dumping the output to screen to make sure the code works, when it's all good I can proceed in making the content display within flash.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)