ibright Posted December 9, 2009 Share Posted December 9, 2009 Here is what I have and I don't understand why it is not working. Have search the internet for two nights can't seem to fix it. ANY HELP, would be greatly appreciated. // Make a MySQL Connection mysql_connect($host, $user, $password) or die(mysql_error()); mysql_select_db($database) or die(mysql_error()); $pageType = $_GET['variable']; switch($pageType) { case "Stallion" or "Mare": // Retrieve all the data from the "Horses" table and joins Sire & Dam Table. $query = "SELECT * FROM Horses, SirePedigree, DamPedigree WHERE Horses.sireId=SirePedigree.sireId AND Horses.damId=DamPedigree.damId AND Horses.sex= '$pageType'"; break; case "Owned": $query = "SELECT * FROM Horses, SirePedigree, DamPedigree WHERE Horses.sireId=SirePedigree.sireId AND Horses.damId=DamPedigree.damId AND Horses.status= '$pageType'"; break; default: echo "You are at Eyebright farm"; break; } $result = mysql_query($query) or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/184497-creating-a-query-using-case-statement/ Share on other sites More sharing options...
forumforme123 Posted December 9, 2009 Share Posted December 9, 2009 What error are you getting? Is it a problem with the switch? How about: case "Stallion": case "Mare": // Retrieve all the data from the "Horses" table and joins Sire & Dam Table. $query = "SELECT * FROM Horses, SirePedigree, DamPedigree WHERE Horses.sireId=SirePedigree.sireId AND Horses.damId=DamPedigree.damId AND Horses.sex= '$pageType'"; break; Link to comment https://forums.phpfreaks.com/topic/184497-creating-a-query-using-case-statement/#findComment-973941 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.