Hi.
I am using a switch...case statement to display either a one-line form or a table, depending on the user's actions. However, while the 'list', 'display1', 'describe1' and 'drop1' cases work, the 'display2' and 'describe2' cases are never called. The action is being passed from the form well enough but never picked up by the case😕.
The switch...case statement is here:
class tableAdmin {
// member variables
var $database;
var $linkid;
var $sqlstmt;
var $rc;
// constructor
function tableAdmin ($database, $linkid) {
$this -> database = $database;
$this -> linkid = $linkid;
}
......................
switch ($userinfo[action]) {
case 'list': {
$tablelistarray = $myTableAdmin -> listTables();
displayArray ("Tables", $tablelistarray);
break;
}
case 'describe1': {
displayOneLineForm ('chapter5_tableAdmin.php', 'Table Name', 'in_table', 'describe2', 'Describe Table');
break;
}
case 'describe2': {
$descriptionlist = $myTableAdmin -> describeTable ($table);
displayResultSet ($descriptionlist);
break;
}
case 'drop1': {
displayOneLineForm ('chapter5_tableAdmin.php','Table Name','in_table','drop2','Drop Table');
break;
}
case 'drop2': {
$rc = $myTableAdmin -> dropTable ($userinfo[in_table]);
echo "<br><br>\n<center>\n";
if ($rc == TRUE) {
echo "Table ".$userinfo[in_table]." was dropped.";
} else {
echo "Table ".$userinfo[in_table]." could not be dropped.";
}
echo "</center>\n";
break;
}
case 'display1': {
displayOneLineForm ('chapter5_tableAdmin.php','Table Name', 'in_table', 'display2', 'Display Table');
break;
}
case 'display2': {
echo "display2!";
$tableresults = $myTableAdmin -> displayTable ($userinfo[in_table]);
displayResultSet ($resultset);
break;
}
}
It refers to the following:
function displayResultSet ($resultset) {
echo "function displayResultset called<br>\n";
// Indicate if the resultset is empty
echo "resultset: $resultset";
foreach ($resultset as $k => $v) {
echo "$k: $v";
}
if (empty($resultset)) {
echo "<center>\n";
echo "<br>";
echo "Action returned no rows!";
echo "</center>";
return ;
} else {
echo "<br>\n";
echo "<center>\n";
echo "<table cellspacing = 5 cellpadding = 5 border = 3 bordercolor = \"0000FF\" >\n";
echo "<thead>\n";
echo "<tr>\n";
$keycount = 0;
// Output each key as a column heading
while (list($key, $value) = each ($resultset[0])) {
$keycount++;
echo "<th>";
echo $key;
echo "</th>\n";
}
echo "</tr>\n";
echo "</thead>\n";
// Output each value as elements of a table starting a new row
// each time the key number of columns is reached
$rowcount = sizeof ($resultset);
for ($rowCounter = 0; $rowCounter < $rowcount; $rowCounter++) {
$valuesarray = array_values($resultset[$rowCounter]);
echo "<tr>\n";
for ($colCounter = 0; $colCounter < $keycount; $colCounter++) {
echo "<td>\n";
echo " ";
echo $valuesarray[$colCounter];
echo " ";
echo "</td>\n";
}
}
echo "</tr>\n";
echo "</table>\n";
echo "</center>\n";
echo "<br>\n";
}
}
Any help would be appreciated.
TIA.