Jump to content

Orderby in href not working?


ICKY

Recommended Posts

I'm new to php and had to pick up another person's development :o  Anyway, I have pasted what I think to be correct but it won't work. I am trying to get the hyperlink to sort the page by horse name but I will be adding other sorting options later after this problem is solved. Can someone help?

 

 

 

//check to see if an order has been set and passed as a variable

$orderby = $_GET['orderby'];

if($orderby == NULL){

        $orderby = "horseName";

}

 

$order = $_GET['order'];

if($order == NULL){

        $order = "ASC";

}

 

 

    //get all the show horses

//show horses have a 'horseGender' of 'c', 'f' or 'g' AND are 3 year old or over

 

    my_connect();

 

    //work out the year that horseYOB must be greater than

$minimum_year = date("Y") - 3;

 

$query = "SELECT * FROM `horses` WHERE (`horseGender` = 'c' OR `horseGender` = 'f' OR `horseGender` = 'g') AND `horseYOB` <= '$minimum_year' AND `show_me` = '1' ORDER BY CAST(replace(horseSalePrice, '$','') as unsigned int) desc";

 

//printf("Query is: ".$query);

 

$result = my_query($query);

 

    //get the number of horses which are for show

$num_rows = mysql_num_rows($result);

 

    //set the 'previous_letter' variable for the first time round the loop

$previous_letter_show = "";

 

?>

 

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML>

<HEAD>

<TITLE></TITLE>

<META NAME="Generator" CONTENT="EditPlus">

<META NAME="Author" CONTENT="">

<META NAME="Keywords" CONTENT="">

<META NAME="Description" CONTENT="">

<link href="../br_style.css" type="text/css" rel="stylesheet" />

<link href="../print.css" type="text/css" rel="stylesheet"  media="print">

 

</HEAD>

 

<h4>Show Horses<div id="print"><a href="showrosterprint.php" target="_blank"><img src="images/printer1.gif" BORDER="0"><br>

  <span class="style1">Print</span></a></div></h4>

 

<span class="smalltext11">Sort by:</span>

<a href="tab_show.php?orderby=horseName&order=ASC"><img src="images/sort_up.gif" border="0"></a><a href="tab_show.php?orderby=horseName&order=ASC">Name</a>

<a href="tab_show.php?orderby=horseName&order=DESC"><img src="images/sort_down.gif" border="0"></a>

<!--</h1><a href="tab_show.php?orderby=horseYOB&order=ASC"><img src="images/sort_up.gif" border="0"></a><a href="tab_show.php?orderby=horseYOB&order=ASC">Age</a>

<a href="tab_show.php?orderby=horseYOB&order=DESC"><img src="images/sort_down.gif" border="0"></a>

<a href="tab_show.php?orderby=horseGender&order=ASC"><img src="images/sort_up.gif" border="0"></a><a href="tab_show.php?orderby=horseGender&order=ASC">Sex</a>

<a href="tab_show.php?orderby=horseGender&order=DESC"><img src="images/sort_down.gif" border="0"></a>-->

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.