Hi
I have a 1 table in my database called cities, and another table in my database called players.
Here are the fields I think are needed for what I want to do.
Table Cities
City_ID
City_Name
City_Description
Minimum_Level
In the players table
id
username
level
City_ID
Here is what I'm trying to do.
I want to give my users the ability to travel from city to city within the game. When they go to the drive.php, it looks at their level and then pulls from the city table any city they meet the minimum level requirement (I have this part working)
I want the names of the cities to be a link, that they can click on. When clicked it updates the City_ID to the location in the players table to the location they clicked on.
Here is the code I have so far, it displays the proper cities, but I don't know how to make the links update this players City_ID.
<?php
$querycity = $db->execute("SELECT * FROM Cities Where $player->level >= Minimum_Level");
echo "<table width=\"100%\">\n";
echo "<tr class=\"cellheader\"><td><div align=\"center\">Wanna Go Somewhere do ya?</div></td></tr><tr>\n";
echo "<td><div align=\"center\">Here are the cities that you can go too.</div></td></tr><tr>\n";
echo "<td>\n";
while ($getcity = $querycity->fetchrow()){
echo "<a href='#?cmd=go&id={$getcity['City_ID']}'>{$getcity['City_Name']}</a><br>";
echo "</td>\n";
echo "</tr></table>\n";
if($_GET['cmd']=="go")
{
$sql="UPDATE set City_ID='$City_ID' FROM players WHERE id='".$getcity['City_Id']."'";
$sql_result=mysql_query($sql)or die (mysql_error());
echo " ".$getcity['City_Name']." Updated!";
}
}
?>
When you move your cursor over the link, it shows an URL like this
http://www.caraudiocentral.net/CAC_Mafia_Life/drive.php#cmd=go&id=1
Now if I can somehow update City_ID in the players table with what shows after id=1, I think this will work great.
I'm also thinking I'm missing in my update query, to tell it which player to update?
I should have a $players->City_ID or some type of variable in there right? Just like I did in the select query?
Does anyone have any suggestions, or a better way to make this work?
Thanks