Hi everyone,

I was hoping somebody could help me unravel this - i'm very new in programming in php and i'm teaching myself so bear with me.

scenario:

I have a website with 4 distinct section (all in seperate tables):

1. A header - where my menu buttons are,
2. A body,
3. A static piece,
4. A footer.

I want to be able to interchange the body section with different data (i would like to use include files), but i don't want to have to repeat all the other data in a seperate php file.

So in short i want the body to change and the rest to stay the same.

I have the layout of the page on www.melktert.co.za/home.php - you'll see the white section in the middle is what i want to change when the user selects a different menu item.

oh yes, and i've got each section listed as a different function.

would really appreciate some input.

thanks,
tim

Recommended Answers

All 8 Replies

hey, i'm an idiot. just realized what i gotta do now. sorry. thanks anyway,

And what are you supposed to do ? :)

ahoy.

What i did now was just put each section into a different include file and then made my main pages like news.php, link.php, etc. and just included the sections in :) without having to re-copy the code each time.

Is there a better way of doing this?

Also, I have a SQL database running with news articles and event information. How do I create a link of a certain article? for instance, i list all the news articles on the right and i want to open a specific one by clicking on it from the list. at the moment my list is just a static list.

please help me out, it really takes me long to figure this stuff out on my own hehe.

Thanks for reply.

Tim

Simple. Pass the id of the news. For eg.

$query="select id from news";
$result=mysql_query($query);
while($row=mysql_fetch_array($result)){
$id=$row['id'];
echo <a href=\"news.php?id=$id\">Part of the news</a>";
}
//this will print all the ids from the table.
//when the user clicks on the hyperlink, in news.php, 
$id=$_GET['id'];
$query="select news from news where id='$id'";
$result=msql_query($query);
$row=mysql_fetch_array($result); //id returns only 1 row with the news
$news=$row['news'];
print $news;
?>

That should give you a basic idea.

thanks a lot - this is all new to me, but i understand the code when i see it - just to think of it is difficult for me.

oh yes, and another thing - how do i create a form that outputs html code into the database? like this news field now, i have a web app that i made to enter the data into the mySQL database, but the normal text area box is just plain text and i have to manually code the html tags in. is there an applet (e.g. the one i'm typing in now) to automatically add those tags?

thanks again.

Yep. There is tinymce editor which has all the options you are looking for ! Have a look. Its easy to use.

wow, everything just came in to place now! thanks a lot for the help! you'll most probably hear more from me!

tim

:) yes sure!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.