Think I found it. I made the changes with explanations of what I did. If you have any further questions feel free to ask. Oh and this should be on the list for others to see and maybe learn from

Respectfully,
Ligaya Turmelle

<head>[DATABASE CONNECTION]</head>
<body>
<div class="formdiv">
<form action="remote.php" method="GET">
<select name="order"> <!-- values here are what the switch is based off of.. so I changed them-->
<option value="1'">Country, etc.</option>
<option value="2'">Population</option>
<option value="3'">Nationality</option>
<option value="4">Nationality: Plural</option>
<option value="5">Nationality: Adjective</option>
<option value="6">Geographic Region</option>
</select>
<input type="radio" name="direction" value="0">+
<input type="radio" name="direction" value="1">-
<input type="submit" name="submit" value="Submit">
</form>
</div>
<?php
$colors = array( '#eee', '', '#ff9', '', '#cff', '', '#cfc', '' );
$n=0;
$size=count($colors);


$result = mysql_query('select count(*) FROM cia_people C, famarea2 F WHERE C.IDArea = F.IDArea AND F.IDParent = "eur" AND C.Nationality is not null');
if (($result) && (mysql_result ($result , 0) > 0)) {
// continue here with the code that starts
//$res = mysql_query ("SELECT * FROM type.....
} else {
die('Invalid query: ' . mysql_error());
}


switch($_GET['order']) // use the Get method requires the $_GET super variable
{ // see http://www.php.net/en/language.variables.predefined in the manual
case 1:
$order = 'cia_people.Name';
break;
case 2:
$order = 'cia_people.Pop';
break;
case 3:
$order = 'cia_people.Nationality';
break;
case 4:
$order = 'cia_people.NationalityPlural';
break;
case 5:
$order = 'cia_people.NationalityAdjective';
break;
case 6:
$order = 'famarea2.IDParentReg';
break;
default:
$order = 'cia_people.Name';
break;
}
switch($_GET['direction']) // same reason as above
{
case 0:
$direction = 'ASC';
break;


                                case 1:
                                $direction = 'DESC';
                                        break;

                                default:
                                $direction = 'ASC';
                                break;
                        }

$sql =
'SELECT F.IDArea,
C.IDArea,
C.Name,
C.Pop,
C.Nationality,
C.NationalityPlural,
C.NationalityAdjective
FROM cia_people C, famarea2 F
WHERE (C.Nationality is not null)
AND (F.IDArea = \'eur\')
ORDER BY ' . $order . ',' . $direction; /* here we just use the local variables we moved everything into in the switch statements */
$res = mysql_query($sql) or die('Failed to run ' .
$sql . ' - ' . mysql_error());


echo '<table class="sortphp" id="tab_cia_people_peo">
         <thead>
   <tr><th>Country</th><th>X</th></tr>
         </thead>
         <tbody>';
//<!-- BeginDynamicTable -->
$rowcounter=0;
while ($row = mysql_fetch_array ($res)) {
     $c=$colors[$rowcounter++%$size];
     echo "<tr style=\"background-color:$c\" class='".
$row['Name'] ."'><". $_SERVER['PHP_SELF'] .'?id='.
$row['IDArea'] .">
    <td class='tdname' '". $row['Name'] ."'>".
$row['Name'] ."</td>
    <td>&nbsp;</td></tr>\n";
}
?>
      </tr>
      </tbody>
    </table>
</body>
</html>




David Blomstrom wrote:
Thanks. I guess this is turning into a PHP question
now, but I wondered if you tell me one more thing.

I made the change you suggested, and I now get this
parse error message:

Parse error: parse error, unexpected '{' in
C:\sites\geoworld\about\guide\world\eur\remote.php on
line 119

This is apparently the line it refers to, but it
doesn't make sense to me. I tried deleting the curly
braces/brackets, but it didn't fix anything.

ORDER BY ' . {$_POST['order']} . ',' .
{$_POST['direction']};

This is the script from Hell; every time I change it,
I get a new parse error!

Oh, yes - I also just discovered the single quotes in
my option values, like the one after Nationality:

<option value="cia_people.Nationality'">

I'm not sure where I picked those up; are they
supposed to be there? I removed them, but, again, it
didn't fix anything.

Thanks.

<head>[DATABASE CONNECTION]</head>
<body>
          <div class="formdiv">
            <form action="remote.php" method="GET">
              <select name="order">
          <option value="cia_people.Name'">Country,
etc.</option>
          <option
value="cia_people.Pop'">Population</option>
          <option
value="cia_people.Nationality'">Nationality</option>
          <option
value="cia_people.NationalityPlural'">Nationality:
Plural</option>
          <option
value="cia_people.NationalityAdjective'">Nationality:
Adjective</option>
          <option
value="famarea2.IDParentReg">Geographic
Region</option>
              </select>
              <input type="radio" name="direction"
value="0">+
              <input type="radio" name="direction"
value="1">-
              <input type="submit" name="submit"
value="Submit">
            </form>
          </div>
          <?php
$colors = array( '#eee', '', '#ff9', '', '#cff', '',
'#cfc', '' );
$n=0;
$size=count($colors);

$result = mysql_query('select count(*) FROM cia_people
C, famarea2 F
  WHERE C.IDArea = F.IDArea AND F.IDParent = "eur"
  AND C.Nationality is not null');
if (($result) && (mysql_result ($result , 0) > 0)) {
// continue here with the code that starts
//$res = mysql_query ("SELECT * FROM type.....
} else {
die('Invalid query: ' . mysql_error());
}

switch($order)
{
   case 1:
       $order = 'cia_people.Name';
       break;
   case 2:
       $order = 'cia_people.Pop';
       break;
   case 3:
       $order = 'cia_people.Nationality';
       break;
   case 4:
       $order = 'cia_people.NationalityPlural';
       break;
   case 5:
       $order = 'cia_people.NationalityAdjective';
       break;
   case 6:
       $order = 'famarea2.IDParentReg';
       break;
   default:
       $order = 'cia_people.Name';
       break;
}
switch($direction)
{
  case 0:
    $direction = 'ASC';
    break;

  case 1:
    $direction = 'DESC';
    break;

  default:
    $direction = 'ASC';
    break;
}
/*

$sql =
'SELECT F.IDArea,
   C.IDArea,
   C.Name,
   C.Pop,
   C.Nationality,
   C.NationalityPlural,
   C.NationalityAdjective
FROM cia_people C, famarea2 F
WHERE (C.Nationality is not null)
   AND (F.IDArea = \'eur\')
ORDER BY ' . {$_POST['order']} . ',' .
{$_POST['direction']};
$res = mysql_query($sql) or die('Failed to run ' .
$sql . ' - ' . mysql_error());

echo '<table class="sortphp" id="tab_cia_people_peo">
<thead>
<tr><th>Country</th><th>X</th></tr>
</thead>
<tbody>';
//<!-- BeginDynamicTable -->
$rowcounter=0;
while ($row = mysql_fetch_array ($res)) {
$c=$colors[$rowcounter++%$size];
echo "<tr style=\"background-color:$c\" class='".
$row['Name'] ."'><". $_SERVER['PHP_SELF'] .'?id='.
$row['IDArea'] .">
<td class='tdname' '". $row['Name'] ."'>".
$row['Name'] ."</td>
<td>&nbsp;</td></tr>\n";
}
?>
</tr>
</tbody> </table>
</body>
</html>




__________________________________ Do you Yahoo!? Check out the new Yahoo! Front Page. www.yahoo.com




-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to