Jump to content

[SOLVED] switch and mysql function help


dave416

Recommended Posts

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

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.

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)

 

Archived

This topic is now archived and is closed to further replies.

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