The question is under the code. Anyone know how to do this?
[php]<?php
require_once(‘Connections/conn.php’);
// Find Current Portals (these can change)
mysql_select_db($database_conn, $conn);
$rsColumns = mysql_query(“SHOW COLUMNS FROM portals LIKE ‘portal_%’”);
// Make Array of current portals
while($row = mysql_fetch_array ($rsColumns)){
$whereColumn .= "".$row['Field'] . "
, ";
}
$whereColumn = substr_replace($whereColumn, “”, -2);
// Portal status of an individual property
mysql_select_db($database_conn, $conn);
$propertyID = 1133; // For testing puposes
$rsPortalsQuery = “SELECT {$whereColumn} FROM portals WHERE portalID LIKE $propertyID”;
$rsPortals = mysql_query($rsPortalsQuery, $conn);
$array = mysql_fetch_assoc ($rsPortals);
//
foreach($array AS $key => $value)
{
if ($value == “Yes”) {
$selectValue = “Yes
No”;
} else {
$selectValue = “Yes
No”;
}
$tableRows .= "<tr>
<td>$key :</td>
<td><select name="$key">
$selectValue
</select></td>
</tr><br>";
}
echo $tableRows;
?> [/php]
//
// So far so good. The table rows for the form display with the appropriate
// values selected, but how do I get these values into an SQL insert statement.
// Normally I’d retrieve them by using $_POST[‘portalName1’], $_POST[‘portalName2’]
// for , , etc
// but in this case the select names are dynamically generated.
// So the question is how do I make a list of $_POST[xxx] variables exchanging
// the xxx for $key value from the array…?
//