How can I display info based on recordset results?
I have a page where a user registers travel information. One of the fields they must fill in is a preferred method of travel (Flying, Train, or Driving) and is submitted by a radio group. I know how to display table rows depending on if a recordset is empty or not, but what I want to do with this page is display relevant information based on the value of a recordset. If the user selects flying as their method, then I only want to display the Airport information. If a user selects Train, then I want to display only the train station information. If the user selects driving then I do not want to display either train station or airport information. I tried using a php if statement, but I think my syntax may have been wrong so I'm just going to display my original page with none of my "attempt" code in it. Many thanks for your help in advance.
[code]
<?php session_start(); ?>
<?php require_once('../../Connections/connDB.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$colname_rsDisplay = "-1";
if (isset($_SESSION['Username'])) {
$colname_rsDisplay = (get_magic_quotes_gpc()) ? $_SESSION['Username'] : addslashes($_SESSION['Username']);
}
mysql_select_db($database_connDB, $connDB);
$query_rsDisplay = sprintf("SELECT ID, Email_Address, First_Name, Middle_Name, Last_Name, Date_of_Birth, Phone_Number, Travel_Type, Airport_Depart, Airport_Return, Train_Depart, Train_Return, Additional_Comments FROM Travel WHERE Email_Address = %s", GetSQLValueString($colname_rsDisplay, "text"));
$rsDisplay = mysql_query($query_rsDisplay, $connDB) or die(mysql_error());
$row_rsDisplay = mysql_fetch_assoc($rsDisplay);
$totalRows_rsDisplay = mysql_num_rows($rsDisplay);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>TRIO Student Support Services</title>
<link rel=stylesheet type="text/css" href="../style.css">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
body,td,th {
font-family: Arial, Helvetica, sans-serif;
font-size: 11pt;
}
.style3 {
font-size: 22pt;
font-weight: bold;
}
.style4 {
font-size: 12pt;
font-weight: bold;
}
.style5 {color: #FF0000}
</style>
</head>
<body bottommargin="0" leftmargin="0" rightmargin="0" topmargin="0" background="../img/background.jpg">
<table height="123" width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top">
<td><img src="../img/blanklogo.jpg" width="574" height="123" border="0" alt=""></td>
<td width="100%" valign="middle" background="../img/topbg.jpg"><span class="style3">Student Support Services</span><br>
<span class="style4">Office of Federal TRIO Programs</span></td>
</tr>
</table>
<table height="40" width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top">
<td width="100%" background="../img/topbar.jpg"> </td>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top">
<td width="201"><BR>
<a href="../index.php">HOME</a><BR>
<img src="../img/menubar.jpg" width="201" height="11" border="0" alt=""><BR>
<a href="../readerresources.php">READER RESOURCES</a><BR>
<img src="../img/menubar.jpg" width="201" height="11" border="0" alt=""><BR>
TRAVEL REGISTRATION<BR>
<img src="../img/menubar.jpg" width="201" height="11" border="0" alt=""><BR>
<a href="../contactus.php">CONTACT US</a><BR>
<img src="../img/menubar.jpg" width="201" height="11" border="0" alt=""><BR>
</td>
<td width="100%">
<table width="90%" border="0" align="center" cellpadding="10" cellspacing="0">
<tr valign="top">
<td>
<br>
Thank you for registering your travel information. Our travel agent will be in touch with you shortly. The information
you submitted is displayed below. Please verify it. Should you need to make any changes, please click <a href="login.php">here</a> to log in
and update your information.<br>
<br>
<table width="90%" border="0" align="center" cellpadding="5" cellspacing="0">
<tr>
<td width="44%"><div align="right">First Name:</div></td>
<td width="56%"><span class="style5"><?php echo $row_rsDisplay['First_Name']; ?></span></td>
</tr>
<tr>
<td><div align="right">Middle Name:</div></td>
<td><span class="style5"><?php echo $row_rsDisplay['Middle_Name']; ?></span></td>
</tr>
<tr>
<td><div align="right">Last Name:</div></td>
<td><span class="style5"><?php echo $row_rsDisplay['Last_Name']; ?></span></td>
</tr>
<tr>
<td><div align="right">Date of Birth:</div></td>
<td><span class="style5"><?php echo $row_rsDisplay['Date_of_Birth']; ?></span></td>
</tr>
<tr>
<td><div align="right">Phone Number:</div></td>
<td><span class="style5"><?php echo $row_rsDisplay['Phone_Number']; ?></span></td>
</tr>
<tr>
<td><div align="right">Method of Travel:</div></td>
<td><span class="style5"><?php echo $row_rsDisplay['Travel_Type']; ?></span></td>
</tr>
<?php if ($row_rsDisplay['Travel_Type'] == "Flying") { ?>
<tr>
<td><div align="right">Airport Departing From:</div></td>
<td><span class="style5"><?php echo $row_rsDisplay['Airport_Depart']; ?></span></td>
</tr>
<tr>
<td><div align="right">Airport Returning To:</div></td>
<td><span class="style5"><?php echo $row_rsDisplay['Airport_Return']; ?></span></td>
</tr>
<?php } ?>
<tr>
<td><div align="right">Train Station Departing From:</div></td>
<td><span class="style5"><?php echo $row_rsDisplay['Train_Depart']; ?></span></td>
</tr>
<tr>
<td><div align="right">Train Station Returning To:</div></td>
<td><span class="style5"><?php echo $row_rsDisplay['Train_Return']; ?></span></td>
</tr>
<tr>
<td><div align="right">Additional Comments or Accomodations:</div></td>
<td><span class="style5"><?php echo $row_rsDisplay['Additional_Comments']; ?></span></td>
</tr>
</table>
<br>
<br>
<br>
<br></td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
<?php
mysql_free_result($rsDisplay);
?>
[/ code]