尝试使用Javascript填充字段,由PHP回应

Here's my code. Is there some reason this should not work? I'm getting all of the fields from MySQL.

Basically what I want is to send information back from a page, with an id number, and this should be used to select the row number for MySQL.

Here's my code from the first page:

$org = $_POST['organization'];
header('Location: '.$admin.'?org='.$org);

And then my code on main page:

ECHO '<script>';
ECHO 'document.getElementById("orgid").value="'.$org_id.'"';
ECHO 'document.getElementById("orgname").value="'.$org_name.'"';
ECHO 'document.getElementById("add1").value="'.$add_1.'"';
ECHO 'document.getElementById("add2").value="'.$add_2.'"';
ECHO 'document.getElementById("city").value="'.$city.'"';
ECHO 'document.getElementById("state").value="'.$state.'"';
ECHO 'document.getElementById("zip").value="'.$zip.'"';
ECHO 'document.getElementById("url").value="'.$url.'"';
ECHO 'document.getElementById("email").value="'.$email.'"';
ECHO 'document.getElementById("phone").value="'.$phone.'"';
ECHO 'document.getElementById("contact").value="'.$contact.'"';
ECHO 'document.getElementById("hours").value="'.$hours.'"';
ECHO 'document.getElementById("file").value="'.$file.'"';
ECHO 'document.getElementById("notes").value="'.$notes.'"';
ECHO 'document.getElementById("description").value="'.$description.'"';
ECHO '</script>';

And here's the code to communicate with MySQL:

if (isset($_GET["org"])  && ($_GET['org'] !== '')) {
$org = $_GET['org'];
$resorgfull = mysql_query("SELECT org_id, org_name, add_1, add_2, city, state, zip, url, email, phone, contact, hours, file_loc, notes, description FROM organization WHERE org_id=".$org.");
if (!$resorgfull) {
    die('Invalid query: ' . mysql_error());
}

One thing definitely wrong is the way you're echoing the scripts, it should be more like this:

echo "<script type='text/javascript'>
";
echo "document.getElementById('orgid').value='$org_id';
";
...

Or preferably...

// Close the PHP tag and output straight HTML with embedded PHP values:
?>
<script type="text/javascript">
document.getElementById('orgid').value='<?php echo $org_id; ?>';
...

If this doesn't fix it, you'll have to give us more info regarding what is not working.

I don't see the code where you take the query result and fetch each row.. are you doing that?