adding links as variables

hi im new here…

a simple question as i cant get the hang of variables at the moment.

i am wanting to use links for categories on a page where when the button/link is pressed it alters the mysql requested column to a different column.

$result = mysql_query(“SELECT * FROM victoria ORDER BY cd”);
while($row = mysql_fetch_array($result)){
$x = $row[‘cd’];
print "

"; } mysql_close($con); ?>

this is what it controls
a line of images collected from my database.
i want to a dd a button that changed cd to say dvd etc which is the name of one of the other columns of data in my database.
rather than writing a new page to display the other columns.

can anyone help?

Are you looking for something like this:

[code]
$search_option = “cd”;
if ($_POST[‘search_for’] == “dvd”) { $search_option = “dvd”; }

$sql = "SELECT “.$search_option.” FROM victoria ORDER BY ".$search_option;
// Rest of your code here[/code]

Sponsor our Newsletter | Privacy Policy | Terms of Service