You can't generally put logic in a string like that. There is one exception, the ternary operator.
//option one ternary operator
return "<form name=\"form2\" method=\"post\" action=\"home.php?page=manage&action=entries\"><select name=\"sort\" style=\"font-size: 11px; font-weight: bold; color: 000000;\" onchange=\"document.forms['form2'].submit()\">
" . ($_GET['sort'] == 1?"<option selected value=\"1\">Sort by Date</option>":"<option value=\"1\">Sort by Date</option>");
//option two variable
$var="<form name=\"form2\" method=\"post\" action=\"home.php?page=manage&action=entries\"><select name=\"sort\" style=\"font-size: 11px; font-weight: bold; color: 000000;\" onchange=\"document.forms['form2'].submit()\">
";
if($_GET['sort'] == 1) {
$var.=?"<option selected value=\"1\">Sort by Date</option>";
} else {
$ar.="<option value=\"1\">Sort by Date</option>";
}
return $var;
Many people don't like the ternary operator because it can make code difficult to read but like it, maybe I need a slap too 😃
Bubble