30 lines
600 B
PHP
30 lines
600 B
PHP
<?php
|
|
|
|
include "db.php";
|
|
|
|
$tableName = "schools";
|
|
if ($argc > 1) $tableName = $argv[1];
|
|
else {
|
|
$table = readline("Table (schools): ");
|
|
if (strlen(trim($table))) $tableName = $table;
|
|
}
|
|
|
|
$arrayName = readline("Array ($tableName): ");
|
|
if (strlen($arrayName) == 0) $arrayName = $tableName;
|
|
|
|
|
|
echo("\n");
|
|
echo("\$$arrayName = array();\n");
|
|
|
|
$query = "SHOW columns FROM $tableName";
|
|
$results = db_query($query);
|
|
|
|
while ($row = db_fetch_assoc($results)) {
|
|
$field = $row['Field'];
|
|
echo('if (isset($' . $field . ')) $' . $arrayName . "['" . $field . "'] = $" . $field . ";\n");
|
|
}
|
|
|
|
echo("\n");
|
|
|
|
?>
|