0
<?php
require_once("./Connections/root.php");
mysql_select_db($database_root, $root);
include 'p_settings.php';
session_start();
$user = $_SESSION['MM_Username'];
$q = mysql_query("SELECT id FROM performer WHERE username='$user' LIMIT 1") or die("Error : " . mysql_error());
$r = mysql_fetch_assoc($q);
$id = $r['id'];

?>
You can set three countries as banned." <br>
Please choose from the following countries:
<?php
$query = mysql_query("SELECT * FROM performer_s WHERE id='$id' LIMIT 1");
$res1 = mysql_fetch_assoc($query);
if($res1['baned_c'] != NULL) { $res1 = $res1['baned_c']; } else { $res1 = "NONE"; }
if($res1['baned_c2'] != NULL) { $res2 = $res1['baned_c2']; } else { $res2 = "NONE"; }
if($res1['baned_c3'] != NULL) { $res3 = $res1['baned_c3']; } else { $res3 = "NONE"; }

echo "<form action=p_settings_ban_s.php>";
echo "<select name=country>";
echo "<option value=>NONE</option>";

$query1 = mysql_query("SELECT DISTINCT country_name FROM country_list ORDER BY country_name ASC");
while($row1 = mysql_fetch_assoc($query1)) {
    if($row1['country_name'] == $res1)
        { echo "<option selected value=" . $row1['country_name'] . ">" . $row1['country_name'] . "</option>"; }
    else 
        { echo "<option value=" . $row1['country_name'] . ">" . $row1['country_name'] . "</option>"; }
}
echo "</select>";

echo "<select name=country2>";
echo "<option value=>NONE</option>";

$query2 = mysql_query("SELECT DISTINCT country_name FROM country_list ORDER BY country_name ASC");
while($row2 = mysql_fetch_assoc($query2)){
    if($row2['country_name'] == $res2)
        { echo "<option selected value=" . $row2['country_name'] . ">" . $row2['country_name'] . "</option>"; }
    else
        { echo "<option value=" . $row2['country_name'] . ">" . $row2['country_name'] . "</option>"; }
}
echo "</select>";

echo "<br /><input type=submit value=Update List />";
echo "</form>";
echo $res2;
mysql_close();

?>

so this is my code....$query1 works fine....$query2 doesen't....$res2 returnes only the first leather of the name from the DB
In the DB its ALGERIA and i only get A

2
Contributors
3
Replies
22
Views
3 Years
Discussion Span
Last Post by broj1
0

As far as I can see $res2 does not depend on $query2. Can you put this temporary debug code just after line 38 and post the result here:

die($row2['country_name'] . ' ' . $res2);
0

there is nothing to post....the second drop down list(from $query2) is created with the default value "NONE"....thats it

0

So according to the following condition:

if($res1['baned_c2'] != NULL) { $res2 = $res1['baned_c2']; } else { $res2 = "NONE"; }

the baned_c2 field contains no value and no value is selected in your drop down. That contradicts with what you said:

$res2 returnes only the first leather of the name from the DB
In the DB its ALGERIA and i only get A

Your HTML is also structured against the rules (atribute values should be enclosed in quotes at least). This might not be the cause but if you structure it right the some chance for errors is eliminated. Correct way would be:

echo '<form action="p_settings_ban_s.php">';
echo '<select name="country">';
echo '<option value="">NONE</option>';

    $query1 = mysql_query("SELECT DISTINCT country_name FROM country_list ORDER BY country_name ASC");
while($row1 = mysql_fetch_assoc($query1)) {
    if($row1['country_name'] == $res1)
    { 
        echo '<option selected value="' . $row1['country_name'] . '">' . $row1['country_name'] . "</option>"; }
    else
    { 
        echo '<option value="' . $row1['country_name'] . '">' . $row1['country_name'] . "</option>"; }
    }
    echo "</select>";
    ...
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.