simple php question..

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
oshen
Forum Newbie
Posts: 6
Joined: Mon Jun 12, 2006 11:36 pm

simple php question..

Post by oshen »

hi...this is my 1st post.

i looked around the tutorials for help, but i think my question is so basic that i can't find an answer for it.

i'm trying to use PHP with a drop down box exactly like this:

http://alexisstrum.com/_objects/ipod/default.php

i understand most of the code, and i've implemented php in some basic ways in the past, but i don't understand these specfic "values" and how to store the actual content on each page?

what kind of file is being called up that is simply named "7" or "8".

thankyu.
oshen
Forum Newbie
Posts: 6
Joined: Mon Jun 12, 2006 11:36 pm

apologies

Post by oshen »

me, again.

ignore my question. i realize i know nothing..no need to waste your time.

i'm going to dig into some tutorials and try to learn myself and then post again if i still can't figure it out.

thanks.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

You are not wasting your time at all, this is a very valid question and we will be happy to assist you.

From looking at that site, it doesn't look like it is including any files.. possibly making database calls of menu items with the correlating ID which is found in the url.

A very simple example would be

Code: Select all

//lets grab a valid number for our very
$id = (isset($_GET['id']) && is_numeric($_GET['id']) ? $_GET['id'] : 1)

$result = mysql_query('SELECT * FROM `menu_items` WHERE `parent_id` = '.$id);

// fetch the results

while ($row = mysql_fetch_assoc($result))
{
    // display each menu item
}
Do let us know if you need anything clarified to expanded upon.
oshen
Forum Newbie
Posts: 6
Joined: Mon Jun 12, 2006 11:36 pm

thankyou

Post by oshen »

thanks Jcart. i sincerely appreciate your help.

i've just built this website for my band: http://violetnine.com

i'm trying to learn new and better ways of doing things.

i normaly just put everything inside one large HTML file...as you'll see.

then, i noticed websites that will use PHP pages and i'm not sure why.
what is the advantage of using them?

i know they are good for more complicated tasks, but i don't know what the advantage is to using PHP when the file you are making is just a simple webpage with basic content.

specifically in examples like these:
http://motioncitysoundtrack.com/news.php
http://anberlin.com/index2.php?AllNews

you can ignore any "flash" stuff. i'm just trying to understand why it's a PHP file and not an HTML.

my guess is that somehow using PHP, you can update the "news" section more easily???
or is it essentially doing the same thing?

thanks very much,
tom
User avatar
TheMoose
Forum Contributor
Posts: 351
Joined: Tue May 23, 2006 10:42 am

Post by TheMoose »

They use PHP because they can then post new content without having to modify the source code for every page. It allows for more dynamic content that's easier to update.
User avatar
pedrotuga
Forum Contributor
Posts: 249
Joined: Tue Dec 13, 2005 11:08 pm

Post by pedrotuga »

in an easy and simpefied way: php is used to generate html acording on the content.
The content is stored usualy on a database (mysql, postgres, or others) or in text files.

google for "php connect a mysql database"
or "php guesbook tutorial"

it's not at all as dificult as most think.

All of us are here to help and be helped so post you questions

BTW great site
oshen
Forum Newbie
Posts: 6
Joined: Mon Jun 12, 2006 11:36 pm

ah..

Post by oshen »

thanks for the help you two.

that all makes sense, and was what i had assumed.

seems nice to be able to update content more easily that way.

i'll google what you mentioned and then read up on it more.

if i can't figure it out, i'll ask more questions.

thanks!
tom
Post Reply