Jump to content

default variable


Fearpig

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!!

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

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

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

while (odbc_fetch_row($rs))
{
  $Model=odbc_result($rs,"Model");
  $FileName=odbc_result($rs,"FileName");
  $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>";

}

odbc_close($conn);
echo "</table>";
[/code]

Thanks in advance.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.