$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 Link to comment https://forums.phpfreaks.com/topic/71603-solved-cannot-get-if-statement-to-work/ 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`"; } Link to comment https://forums.phpfreaks.com/topic/71603-solved-cannot-get-if-statement-to-work/#findComment-360513 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`"; Link to comment https://forums.phpfreaks.com/topic/71603-solved-cannot-get-if-statement-to-work/#findComment-360514 Share on other sites More sharing options...
$username Posted October 3, 2007 Author Share Posted October 3, 2007 Thanks guys, Brett Link to comment https://forums.phpfreaks.com/topic/71603-solved-cannot-get-if-statement-to-work/#findComment-360517 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.