I have 2 bits of code which are both doing what they are supposed to:
A) This code shows and updates the field in the database based on the value in the input field
<input id="input" class="input-small" type="text" name='C_N_C' value="<?php if(isset($_POST['C_N_C'])) echo $_POST['C_N_C']; else echo $C_N_C; ?>">
B) This code counts the values in another db and returns the number or rows
<?php
$query = "SELECT COUNT(C_ID) FROM CfortoC WHERE C_ID = '{$_GET['id']}'";
$results = mysql_query($query);
$rows = mysql_fetch_array($results);
echo $rows[0];
?>
Individually these work fine!
**What I need to do is to run the query FIRST then have that value displayed in the input box. Then when "UPDATE" is clicked to update the C_N_C value to that of the query! **
I hope that makes sense! Thanks for any help!
MORE CODE
As requested here is more code!
<div class="control-group">
<label class="control-label" for="input">C Label </label>
<div class="controls">
<input id="input" class="input-small" type="text" name='C_N_C' value="<?php if(isset($_POST['C_N_C'])) echo $_POST['C_N_C']; else echo $C_N_C; ?>">
<?php if(isset($_GET['id'])) { ?>
<?php
$query = "SELECT COUNT(C_ID) FROM CfortoC WHERE C_ID = '{$_GET['id']}'";
$results = mysql_query($query);
$rows = mysql_fetch_array($results);
echo $rows[0];
?>
<?php } ?>
</div>
</div>