Log in

View Full Version : Displaing information from DB on webpage Modification



big-dog1965
12-18-2007, 05:25 AM
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

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++;
}

?>

nrglift
01-02-2008, 03:36 PM
This is what I would have done.


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++;
}

big-dog1965
01-02-2008, 04:47 PM
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 greatThank you

nrglift
01-07-2008, 04:01 PM
Could I see the page you used it on?