PDA

View Full Version : Showing content


Josh
Thu 17th Aug '00, 3:50pm
I am working on a script that accesses a mySQL database if a variable is called (i.e. page.php?variable=here) and shows a list of options if no variable is called

I looked through a couple of PHP books and found this done with the following code:

if(isset($variable))
{
$content = "code";
}

if($variable == "")
{
$content = "code";
}

print($content);

When I access the page, however, it does not access the mySQL database (with a variable) or show the options (without a variable).

Any ideas on how I should do this?

Mike Sullivan
Thu 17th Aug '00, 3:56pm
if ($variable) {
// Stick the database interface stuff here
} else {
// Stick the options code here
}

Josh
Thu 17th Aug '00, 6:23pm
Thanks!

Josh
Sun 20th Aug '00, 1:57am
That didn't work as well as I had hoped it would.

When I access the page I still get a blank page. I have the if statement setup as you showed:

if ($variable) {

//DATABASE STUFF
$content = $dbresults;

} else {

$content = 'This is the content';

}

And I then call $content with print();. Any ideas why it isn't working?