dave416 Posted May 10, 2008 Share Posted May 10, 2008 hey, so heres my basic idea. i have a website about this team and i want to create a file called roster.php which i already have and that displays all the player information from a mysql database in a nice little neat table. each player has detailed information about him in the database and what i want to do is create something like where if you click on Joe Smith's name it displays a page directly for Joe Smith with all the relevant information and a photo (all drawn from the database), so that i dont have to create 50 different pages for 50 different players. i think i can do this with a switch statement but i need a little jumpstart to get me going. thanks for any help you can provide so the end result would be a page url of roster.php?player=JoeSmith and that page would display all the info i have about Joe in the database. Link to comment https://forums.phpfreaks.com/topic/105011-solved-switch-and-mysql-function-help/ Share on other sites More sharing options...
xenophobia Posted May 10, 2008 Share Posted May 10, 2008 Simply just use the sql query to get Joe's details will do. // Get the player name from the url. $player_name = url_decode($_GET['player']); // In-case for sql injection $player_name = mysql_real_escape($player_name); // Construct your sql. $sql = "SELECT * FROM `your_table_name` WHERE `your_player_field_name`='$player_name' "; $qry = mysql_query($sql); Well the $qry will hold the result. Check out more about the phpmysql functions at php.net. Link to comment https://forums.phpfreaks.com/topic/105011-solved-switch-and-mysql-function-help/#findComment-537506 Share on other sites More sharing options...
dave416 Posted May 10, 2008 Author Share Posted May 10, 2008 let me better explain myself, im not sure i did a good job the first time. so lets say i want to view a player page about Joe Smith. i click on his name and i want that to lead me to something like roster.php?player=JoeSmith and my idea for the code would be somewhere along these lines: switch ($player) { case "Joe Smith": echo $alljoesmithsinfo; //dont need help with this part break; } and i want cases for ALL the players in my database (for obvious reasons) Link to comment https://forums.phpfreaks.com/topic/105011-solved-switch-and-mysql-function-help/#findComment-537523 Share on other sites More sharing options...
xenophobia Posted May 10, 2008 Share Posted May 10, 2008 I don't get it why you have to use the switch statement to do that. You just send a sql statement to the database MS (Mysql, Oracle,...), and let them give you the result. Trust me, you don't have to use switch.... Link to comment https://forums.phpfreaks.com/topic/105011-solved-switch-and-mysql-function-help/#findComment-537543 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.