I have this code snippet from selected_char_id.php :
Code: Select all
<?php
include 'connect.php';
if(!isset($_SESSION)) {
session_start(); }
if(isset($_POST['select_character']))
{
$details = explode(" ", $_POST['select_character']);
echo "<br>";
$query = sprintf("SELECT char_id FROM characters WHERE char_name = '%s' AND char_dynasty = '%s'", $details[1], $details[2]);
$result = mysql_query($query);
list($selected_char_id) = mysql_fetch_row($result);
}
?>
Code: Select all
<?php
include 'connect.php';
include 'selected_char_id.php';
if(!isset($_SESSION)) {
session_start(); }
$query = sprintf("SELECT id FROM users WHERE UPPER(username) = UPPER('%s')",
mysql_real_escape_string($_SESSION['username']));
$result = mysql_query($query);
list($userID) = mysql_fetch_row($result);
$query = sprintf("SELECT name, type from cities where user_id = ('%d') AND char_id = '%d' order by type desc",$userID, $selected_char_id);
$result = mysql_query($query);
echo "Holdings: <br>";
while($holding = mysql_fetch_assoc($result)){
$name = $holding['name'];
$type = $holding['type'];
echo "<a href = http://localhost/Caught%20in%20the%20Middle/holding_ui.php >Mayor of " . $name . " " . $type . "<br><br></a>";
}
?>
Don't worry about $_POST['select_character'] as it comes from another script loaded with a select option, and i used explode() because the aforementioned var is composed of multiple columns from the database.