PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I'm new to php and had to pick up another person's development 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";
}
//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 = "";
Also... what is my_connect() ? Is that some sort of database abstraction wrapper? It looks like it wants to be mysql_connect(). If it IS a wrapper (and database portability is important to your app), you should consider using the built-in PDO functions: http://php.net/pdo
Your problem:
What errors do you get? Does the scritp say something? Have you tried something else than the below? Is the red text the only thing not working in the script?