Ok
This is a program that get's all the databases in the system, logs the user out, or locks the database to the other users (other then Sys Admiin) and must be unlocked before allowing further use.
So far everything is great.
I have an array set up listing all the databases, a page that allows users to be checked off and logged out, a message to be sent, and allows the sys admin to then select each database to be locked with a checkbox.
The submit button works with a switch statement offering offline, logout, or online functions.
Now it is the oflline where my problem lies, for now at least, this will later be the same for online.
It is the damn checkboxes.
I have it so that thedatabases appear in a table with a checkbox beside each one, set up in the foreach statement.
The problem is that when submit is clicked the checked ones, and the unchecked ones, go offline. It is not passing the information about which database should and should not be offline true.
And i'm lost now.
🙂
the foreach set up as a table to define all databases and offer the checkbox:
foreach($dbase as $index => $value) {
$current = $value;
$dbName = $index;
mysql_select_db($current, $conn) or die( not finding: '.mysql_errno().":".mysql_error());
echo "<tr><td><input type='checkbox' name='status' value='offline'></td><td>Lock this database $dbase</td></tr>
}
if I set up the input checkbox with this code then in the view source page I can tell which checkbox is for which database:
<input type='checkbox' name='status[$value]' value='offline'>
Submit is clicked leading to this:
if(isset($submit)) {
case "online":
submit_online_function();
break;
case "offline":
submit_offline_function();
break;
default:
}
exit;
}
which leads to this function:
function submit_offline_function() {
global $status, $current_db, $dbName, $dbase, $conn, $control_flag;
foreach($dbase as $index => $value) {
$current_db = $value;
$dbName = $index;
mysql_select_db($current_db, $conn);
/ *$some function that updates, inserts or deletes the data to the apropriate table in the database*/
$some = "insert into table(control_flag, msg, status) values ('$control_flag', '$msg', '$status')";
mysql_db_query($current_db, $some, $conn);
I know the problem lies in how it is getting passed from the checkbox to the submit switch to the function
but I'm not sure how to fix it all up.
Any ideas?