Jump to content

Archived

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

Fearpig

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

[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.

Share this post


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

[code=php:0]
<?php
if (!isset($_GET['ModelSelect'])){
  $ModelSelect = "model";
}
?>
[/code]

Rich

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.