Results 1 to 4 of 4

Thread: Displaing information from DB on webpage Modification

  1. #1
    Join Date
    Sep 2007
    Posts
    83
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Displaing information from DB on webpage Modification

    I use this to pull information from DB and display on web page. I would like to modify it to only display information if the field in the DB has been populated. Right now this is what is display
    Bob Smith
    Buggy
    Buggy Sportsman YES
    Arena Truck YES
    Monster Truck
    Stadium Truck
    The name is a text field from form and the others are check boxes. Buggy Was not checked so no value, Buggy Sportsman was check so its value was YES and so on.
    Heres the mod I need If not checked then it doesnt show anything If check it shows.
    Bob Smith
    Buggy Sportsman YES
    Arena Truck YES
    PHP Code:
    mysql_connect(localhost,$username,$password);
    @
    mysql_select_db($database) or die( "Unable to select database");
    mysql_query($query);
    $query'SELECT Name, Eighth_Scale_Buggy, Eighth_Scale_Sportsman, Arena_Truck, Monster_Truck, Stadium_Truck FROM Entry_Form ORDER BY id DESC LIMIT 0, 250';

    $result=mysql_query($query);

    $num=mysql_numrows($result);

    if (
    $num==0) {

    echo 
    "<i><strong>NO On-Line Forms Filled Out</strong></i><br>";
    }else{
    echo 
    "<i><strong>Filled out Entry Form</strong></i><br>";
    }

    mysql_close();

    $i=0;
    while (
    $i $num) {

    $Name=mysql_result($result,$i,"Name");
    $Eighth_Scale_Buggy=mysql_result($result,$i,"Eighth_Scale_Buggy");
    $Eighth_Scale_Sportsman=mysql_result($result,$i,"Eighth_Scale_Sportsman");
    $Arena_Truck=mysql_result($result,$i,"Arena_Truck");
    $Monster_Truck=mysql_result($result,$i,"Monster_Truck");
    $Stadium_Truck=mysql_result($result,$i,"Stadium_Truck");
    echo 
    "<b>$Name<br>Buggy $Eighth_Scale_Buggy<br>Buggy Sportsman $Eighth_Scale_Sportsman<br>Arena Truck $Arena_Truck<br>Monster Truck $Monster_Truck<br>Stadium Truck $Stadium_Truck<hr>";

    $i++;
    }

    ?> 

  2. #2
    Join Date
    Jan 2008
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    This is what I would have done.

    Code:
    mysql_connect(localhost,$username,$password);
    @mysql_select_db($database) or die( "Unable to select database");
    
    $sql= 'SELECT Name, Eighth_Scale_Buggy, Eighth_Scale_Sportsman, Arena_Truck, Monster_Truck, Stadium_Truck FROM Entry_Form ORDER BY id DESC LIMIT 0, 250';
    $query = mysql_query($sql) or die(mysql_error());
    $result=mysql_fetch_array($query);
    
    $num=mysql_numrows($result);
    
    if ($num==0) {
    
    echo "<i><strong>NO On-Line Forms Filled Out</strong></i><br>";
    }else{
    echo "<i><strong>Filled out Entry Form</strong></i><br>";
    }
    
    mysql_close();
    
    $i=0;
    while ($i < $num) {
    
    $Eighth_Scale_Buggy = $result["Eighth_Scale_Buggy"];
    $Eighth_Scale_Sportsman = $result["Eighth_Scale_Sportsman"];
    $Arena_Truck = $result["Arena_Truck"];
    $Monster_Truck = $result["Monster_Truck"];
    $Stadium_Truck = $result["Stadium_Truck"];
    $Name = $result["Name"];
    
    echo "<B>$name</b><BR>";
    
    if ($Eighth_Scale_Buggy != ""){
    echo  "Buggy $Eighth_Scale_Buggy<BR>";
    }
    if ($Eighth_Scale_Sportsman != ""){
    echo  "Buggy Sportsman $Eighth_Scale_Sportsman<BR>";
    }
    if ($Arena_Truck != ""){
    echo  "Arena Truck $Arena_Truck<BR>";
    }
    if ($Monster_Truck != ""){
    echo  "Monster Truck $Monster_Truck<BR>";
    }
    if ($Stadium Truck != ""){
    echo  "Stadium Truck $Stadium_Truck<BR>";
    }
    
    echo "<hr>";
    
    $i++;
    }

  3. #3
    Join Date
    Sep 2007
    Posts
    83
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I get this
    Parse error: syntax error, unexpected T_STRING in /home/ksp/pro_pg.php on line 77
    Never Mind error I got it worked out
    THANKS nrglift your way works great
    Thank you
    Last edited by big-dog1965; 01-02-2008 at 05:53 PM.

  4. #4
    Join Date
    Jan 2008
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Could I see the page you used it on?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •