Jump to content


This topic is now archived and is closed to further replies.


default variable

Recommended Posts

Hi guys,
I've written the code below and its all working but I can't figure out the next step. Basically I have a page with a list of products when you click on a product it passes the variable to the next page wich displays all of the related parts.

How do I set up this page to have a default vale incase someone gets to that page without the variable being set? If someone could point me in the right direction I'd be very happy!!

$ModelSelect = $_GET['ModelSelect'];
//basically I want a line here somewhere that says if $ModelSelect is null then 'Model1'  

if (!$conn)
  {exit("Connection Failed: " . $conn);}
$sql="SELECT * FROM Parts_Intranet WHERE Model='$ModelSelect'";
if (!$rs)
  {exit("Error in SQL");}

echo "<table border='1' cellpadding='2' cellspacing='0' class='Body2'><tr>";

while (odbc_fetch_row($rs))
  $AirPressureSwitch=odbc_result($rs,"AIR Pressure Switch");
  $AutoAirVent=odbc_result($rs,"AUTO Air Vent");
  echo "<tr><td>Model</td><td>$Model</td></tr>";
  echo "<tr><td>File Name</td><td>$FileName</td></tr>";
  echo "<tr><td>Air Pressure Switch</td><td>$AirPressureSwitch</td></tr>";
  echo "<tr><td>Auto Air Vent</td><td>$AutoAirVent</td></tr>";


echo "</table>";

Thanks in advance.

Share this post

Link to post
Share on other sites
Give that a try...

if (!isset($_GET['ModelSelect'])){
  $ModelSelect = "model";


Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.