Current location: Hot Scripts Forums » Programming Languages » PHP » PHP Website help


PHP Website help

Reply
  #1 (permalink)  
Old 12-12-04, 04:37 PM
nicpon nicpon is offline
Wannabe Coder
 
Join Date: Apr 2004
Location: Moving
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
Question PHP Website help

i have created a layout for my page nicpon.net/index.php and this is my code for idnex.php
PHP Code:

<? 

include("header.php"); 
include(
"leftmenu.php"); 
include(
"body.php"); 
include(
"footer.php"); 
?>
. Also i have db in mysql ready to use and i woulid like to make links on the leftmenu to my db so that it shows db content dynamically inthe body section. can you guys give me some advice how should i code php to in order to have different stuff from db displayed in body section??Right now i dont use any frames everything basend on tables as you can see in source of index.php but if i have to i can put it in frames or whatever is neccessary.
Reply With Quote
  #2 (permalink)  
Old 12-12-04, 05:36 PM
Acecool's Avatar
Acecool Acecool is offline
Aspiring Coder
 
Join Date: Nov 2003
Posts: 506
Thanks: 0
Thanked 0 Times in 0 Posts
mysql_connect()
mysql_select_db()
mysql_query()
mysql_fetch_array() in a while()

http://www.php.net/mysql_connect
http://www.php.net/mysql_select_db
http://www.php.net/mysql_query
http://www.php.net/mysql_fetch_array
http://www.php.net/while

Those are the functions you need :-)
__________________
Check Acecoolco.com for PHP Tutorials, and other tuts
If you plan on contacting me, please read this: Legal Terms & Conditions
Reply With Quote
  #3 (permalink)  
Old 12-13-04, 05:33 AM
nicpon nicpon is offline
Wannabe Coder
 
Join Date: Apr 2004
Location: Moving
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
i know how to read db and how to lay it out on the website but i dont know how to code index.php so that it will change the content of body.php or even load different file??
Reply With Quote
  #4 (permalink)  
Old 12-13-04, 06:06 AM
greybird greybird is offline
Newbie Coder
 
Join Date: Dec 2004
Posts: 44
Thanks: 0
Thanked 0 Times in 0 Posts
Well it depends on how you want to do it. To know what page the user is on you will need to check for some value in the URL, so you will need to check $_GET['var'], and then you can either just directly include a different file according to the page; i.e. if the url is mypage.php?id=contact then you include the contact page (checking to make sure the user is allowed to include that page first - we dont want them viewing the password files like this).

Secondly, you could check the URL for a value and then search the database to find what page to include, or simply grab the page from the database itself.

Make sense?
Reply With Quote
  #5 (permalink)  
Old 12-13-04, 07:49 AM
nicpon nicpon is offline
Wannabe Coder
 
Join Date: Apr 2004
Location: Moving
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
yeah, i would like to check which page is currecntly in the browser and then make some links to other pages.Do you have code for that ??
Reply With Quote
  #6 (permalink)  
Old 12-13-04, 10:12 AM
greybird greybird is offline
Newbie Coder
 
Join Date: Dec 2004
Posts: 44
Thanks: 0
Thanked 0 Times in 0 Posts
With links like:
index.php?p=home
index.php?p=about

PHP Code:

if(isset($_GET['p'])){

   
$page $_GET['p'];
}else{
   
$page 'home';
}

//runs some checks to make sure you want to show this page to the user
include("includes/pages/".$page.".php"); 
Etc.
Reply With Quote
  #7 (permalink)  
Old 12-13-04, 01:18 PM
nicpon nicpon is offline
Wannabe Coder
 
Join Date: Apr 2004
Location: Moving
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
greybird,
when i use your code i`m getting this errorrs http://nicpon.net/index.php
even though the file home.php is in therehttp://nicpon.net/home.php. What do you sugest ??
Reply With Quote
  #8 (permalink)  
Old 12-13-04, 02:27 PM
wizkid's Avatar
wizkid wizkid is offline
Newbie Coder
 
Join Date: Nov 2004
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts
Your home.php should be located in your include path.
Reply With Quote
  #9 (permalink)  
Old 12-13-04, 03:00 PM
nicpon nicpon is offline
Wannabe Coder
 
Join Date: Apr 2004
Location: Moving
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
if i include my home.php like this
PHP Code:

include("home.php"); 

then i cant control the files
Reply With Quote
  #10 (permalink)  
Old 12-13-04, 03:16 PM
wizkid's Avatar
wizkid wizkid is offline
Newbie Coder
 
Join Date: Nov 2004
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts
what do you mean you cant control the files?

Try to locate your include path and place your home.php there.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Website nicpon PHP 3 12-10-04 08:58 AM
Website Managment with PHP ? lunatick PHP 8 12-04-04 09:50 AM
FS: Prozilla Memberships (Turnkey Sites) - $10-15 less than Retail! rockergrrl General Advertisements 0 08-11-04 12:05 AM
Syndicating XML data into a website using PHP... Jackal05 PHP 3 07-16-04 02:38 PM
Help! With setting up a basic PHP Forum page on the website. A-A PHP 0 05-05-04 08:15 AM


All times are GMT -5. The time now is 05:18 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.