Still working to update my scripts for the latest PHP version.
I have a table of musical material which is updated monthly with fields such as id, year, month, complast [this one indicates the composer's last name], title [name of musical piece], etc.
I want the script to check to see if the "order by" has already been determined (i.e., via the URL; for example: website.com/webpage.php?order=year ASC,month ASC), and if it has not, then to set it. This has always worked in my previous coding, but now that I've tried to update the code to conform to mysqli, it is kicking back that $order is an undefined variable on, let's say, line 50. I actually understand the guts of why this is, but I am not 100% sure how to avoid it (i.e., how to pre-set "order by" only to have it possibly be overridden). FYI, there are various links on the page so that the visitor can change the "order by;" this is the whole point, of course.
Here is the relevant code (as ever, if you need more, just ask):
PHP Code:
<?php
50 if ($order=="") {
$order="year DESC,month DESC";
}
$current = mysqli_query($con, "SELECT * FROM therelevanttable WHERE status LIKE 'archive' order by $order");
Obviously, I've put the "50" in here just to be superclear where line "50" is; it's not actually IN my code.
Thoughts?