Announcement

Collapse
No announcement yet.

Showing content

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Showing content

    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?
    Josh
    [email protected]

  • #2
    Code:
    if ($variable) {
    // Stick the database interface stuff here
    } else {
    // Stick the options code here
    }

    Comment


    • #3
      Thanks

      Thanks!
      Josh
      [email protected]

      Comment


      • #4
        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?
        Josh
        [email protected]

        Comment

        widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
        Working...
        X