Forum Moderators: coopster

Message Too Old, No Replies

Dymanically loading pages

PHP and MySQL

         

Harvs

7:21 am on Oct 19, 2004 (gmt 0)

10+ Year Member



I am currently in the middle of designing a commericial site and everything has been left up to me to design and implement. I am considering using PHP and Mysql because there are going to be many (400 or so) pages that are alll similar.

My question is: Is it possible to load a page dynamically based on what information is stored in the database. For example if no picture is in a picture field it won't load the picture at all. This way I can store different information in the database for each item and still have it looking good when it loads up.

mincklerstraat

7:33 am on Oct 19, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



oh yeah, that's possible - fetch yer rows as
$row[]
(an array), and when you're outputting what you're outputting,

if(!empty($row['pic1'])){ 
echo '<img src="'.$row['pic1'].'" alt="">';
} else {
/* do either nothing, or whatever you want to do if there isn't any image here */
}

Actually, this is a good 'basic' question since I've seen so many sites that deliver broken images when the images run out, or keep on outputting the field names when these fields are blank, returning lots of worthless and potentially distracting info.

dreamcatcher

7:56 am on Oct 19, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Another way to do it is to use the file_exists() function. If the image exists, display it, else do something else. Pretty much the same as what mincklerstraat said, but a slight alternative. :)

Harvs

7:56 am on Oct 19, 2004 (gmt 0)

10+ Year Member



thanks for that mincklerstraat. Along those lines of dynamically making pages would it be possible to make an "admin" only page where someone could input the information into the appropriate fields and from that a page is "generated".

mincklerstraat

8:07 am on Oct 19, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Oh yeah. Will take a bit of reading on php.net and maybe using a pre-written class in PEAR (pear.php.net) or the one called 'pat user', but very doable indeed. If you want to research this, google php and authentication.