Thank you, very nice solution, that was answered my question. How can I use your solution if my $sql is as follows:
$sql = "SELECT * FROM $tbl_main, $tbl_country, $tbl_members
WHERE ($tbl_main.country_id = $tbl_country.country_id) AND ($tbl_main.member_id = $theselect) ORDER BY $chosenTable.$orderby LIMIT $startpoint, $limit";
ie how can I use your solution somewhere in the middle of a code.
You can conditionally concatenate the extra condition:
$sql = "SELECT * FROM $tbl_main, $tbl_country, $tbl_members
WHERE ($tbl_main.country_id = $tbl_country.country_id)";
if(isset($theselect)) {
$sql .= " AND ($tbl_main.member_id = $theselect)";
}
$sql .= " ORDER BY $chosenTable.$orderby LIMIT $startpoint, $limit";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.