$username Posted October 3, 2007 Share Posted October 3, 2007 Ok PHP people, I would like an if statement if a value is not present to us a default value. Let me know if this is how it can be done. if ($Ord == "") $Ord = 'ID'; else $Ord = $_GET['Ord']; $sql = "SELECT * FROM store ORDER BY `$Ord`"; Thank you, Brett Quote Link to comment Share on other sites More sharing options...
sKunKbad Posted October 3, 2007 Share Posted October 3, 2007 if ($_GET['Ord'] == ""){ $Ord = 'ID'; }else{ $Ord = $_GET['Ord']; $sql = "SELECT * FROM store ORDER BY `$Ord`"; } Quote Link to comment Share on other sites More sharing options...
MadTechie Posted October 3, 2007 Share Posted October 3, 2007 if ( !isset($Ord) || empty($Ord) ) { $Ord = 'ID'; }else{ $Ord = $_GET['Ord']; } $sql = "SELECT * FROM store ORDER BY `$Ord`"; Quote Link to comment Share on other sites More sharing options...
$username Posted October 3, 2007 Author Share Posted October 3, 2007 Thanks guys, Brett Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.