I have tried the below and all bring out the data, but not in the correct order.
$sql="SELECT * FROM log_login ORDER BY $POST[D1]";
$sql="SELECT * FROM log_login ORDER BY 'log.html, [D1]'";
$sql="SELECT * FROM log_login ORDER BY date"; //date order only
$sql="SELECT * FROM log_login ORDER BY username";
The select does not function, what am I missing.
and what do you mean about the validation code?
If it false { else?
You should separate your tasks.
First of all you should make yourself know, what SQL query you want.
Second, produce that query from variables you have. Ensure that this resulting query is exactly the same you wanted.
Third, take some precautions against someone put “;DROP table log_login” into $POST[D1]
Do it step by step. Don’t take second step before first.
What SQL query(-es) you want to run?
Query “SELECT * FROM log_login ORDER BY username” does work?
If not - what are symptoms? If usernames goes out in the incorrect order, there may be encoding problem.
Well, now I see your problem.
Yo fail to name variable properly.
Both $_POST [D1] and $POST[D1] are wrong.
Try to print out your variable and find right name for it.
Try to print out your variable and find right name for it.
Do not know how to write this code.
$sql=“SELECT * FROM (log_login ORDER BY {$_POST[D1]}”;
I get - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘’ at line 1
I don’t know what you’re doing, but your database server doesn’t know anything about your website files. Putting log.php into the query you’re going to send to MySQL is definitely not right.
As an aside, I have not seen a worthwhile use of frames since 1998
No, I don’t know what I am doing. So, I threw together a index.php with all of the code on one page.
And the info site comes out in no sequence. I believe in the same order of the mysql database. Maybe I should index one of the columns? Date is, althought it does not list by date.
I just went with a ORDER BY date"; and dropped the form select all together.
I do not know code well enough to build a page the worked the way I wanted.
I may give it another try later, though. Need to learn all of the meaning of the ??? coding variables. First… php.net and w3schools.com/php is a start.
if ($_POST['D1'] === 'username') $orderby = 'username';
if ($_POST['D1'] === 'date') $orderby = 'date';
// and so on
$sql="SELECT * FROM log_login ORDER BY $orderby";