Jump to content

Order By Problem. Should be easy!


Snooble

Recommended Posts

if (isset($_GET['orderby'])) {

$order = $_GET['orderby'];

$query = "SELECT * FROM songs ORDER BY $order";

}

$query = "SELECT * FROM songs";

$result = mysql_query($query) or die('Query failed: ' . mysql_error());

 

That should be all the code you need. So i put URL or :

 

www.wezzsmusic.ifastnet.com/WM/music.php?orderby=Title

 

and they dont change. Have a look at that page and see what you can do...

 

You'll need to login.

 

user = test

pass = abc123

 

Thanks,

 

SNooble

Link to comment
https://forums.phpfreaks.com/topic/40707-order-by-problem-should-be-easy/
Share on other sites

Your overiding your $query variable with this line.

 

$query = "SELECT * FROM songs";

 

Your code needs to be more like....

 

<?php

  if (isset($_GET['orderby'])) {
    $order = $_GET['orderby'];
    $query = "SELECT * FROM songs ORDER BY $order";
  } else {
    $query = "SELECT * FROM songs";
  }

  // more code.

?>

wezzsmusic.ifastnet.com/WM/music.php

 

sign in with

 

username = test

password = abc123

 

that link works, copy and paste it. navigate to the tab "MUSIC" and then you can see my trobule. It's hard to explain.

 

Numbers are shown like

 

1

10

2

29

 

...

 

But even with the song title you should have AAAAAA before Arnold

 

??

 

Snooble

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.