Wednesday, 11 September 2013

SQL/PHP status not upating when new record added

SQL/PHP status not upating when new record added

I have a PHP/MySQL problem I'm hoping someone can help me with. What I am
trying to accomplish is this: If the MySQL column 'account number, first
name, lastname & company name' fields are empty Then show a green button
indicating that.
If the 'cabinet number' field in the database is NOT empty show a red
button indicating that.
The code works fine to a certain point. Here is where I'm running into an
issue. The buttons displaying green (indicating empty) are not changing
when a new record is added. In other words, when I enter a new record with
just the server cabinet number, that indicates that the cabinet is empty.
When I add a new record with that same cabinet number AND the data in the
rest of the column fields, that cabinet should indicate no longer empty.
It's not updating though. Here is my code:
$query = mysql_query ("SELECT * from cust_data group by cabinet_number
ORDER by cabinet_number ASC");
WHILE ($rows = @mysql_fetch_array($query)){
if (($rows['account_number']=="") &&
($rows['customer_first_name']=="") &&
($rows['customer_last_name']=="") &&
($rows['company_name']==""))
{
echo '<form method="GET" action="cabinet_result_page.php">
<input type="hidden" value="'.$rows['cabinet_number'].'"
name="cabinet_number">
<input type="hidden" value="'.$rows['id'].'" name="id">
<img src="images/bulletpoint_green.png">
<input type="submit" value="'.$rows['cabinet_number'].'"
name="'.$rows['cabinet_number'].'" id="submit">
</form>';
}
else if ($rows['cabinet_number']!=="")
{
echo '<form method="GET"
action="cabinet_result_page.php">
<input type="hidden"
value="'.$rows['cabinet_number'].'"
name="cabinet_number">
<input type="hidden" value="'.$rows['id'].'" name="id">
<img src="images/bulletpoint_red.png">
<input type="submit"
value="'.$rows['cabinet_number'].'"
name="'.$rows['company_name'].'" id="submit">
</form>';
}

No comments:

Post a Comment