I have a table named account.
Table: account
+---------+---------------------+-----------+
| user_id | email | u_name |
+---------+---------------------+-----------+
| 63 | [email protected] | Pross |
| 64 | [email protected] | Pross |
| 73 | [email protected] | Victorss |
| 74 | [email protected] | Ifecosss |
+---------+---------------------+-----------+
But I want to change all the display u_name into "No" from my table whose u_name = "Pross" in my page like this:
+---------+---------------------+-----------+
| user_id | email | u_name |
+---------+---------------------+-----------+
| 63 | [email protected] | No |
| 64 | [email protected] | No |
| 73 | [email protected] | Victorss |
| 74 | [email protected] | Ifecosss |
+---------+---------------------+-----------+
But my code here replaces all the rows with "No". Seems like the placement of my condition is wrong. Here's my code in php to fetch data from database.
<!--############# TABLE CONTENT ##############-->
<tbody>
<?php
while($row = mysql_fetch_array($s1)) {
# Columns from DB
$db_id = $row['user_id'];
$db_email = $row['email'];
$db_uname = $row['u_name'];
# Condition to handle display of u_name row
if($db_uname == "Pross") {
$db_uname_edit = "No";
}
?>
<tr>
<td><?php echo $db_id ?></td>
<td><?php echo $db_email ?></td>
<td><?php echo $db_uname_edit ?></td>
</tr>
<?php } ?>
</tbody>
<!--##########################################-->
But the unwanted output of this is :
+---------+---------------------+-----------+
| user_id | email | u_name |
+---------+---------------------+-----------+
| 63 | [email protected] | No |
| 64 | [email protected] | No |
| 73 | [email protected] | No |
| 74 | [email protected] | No |
+---------+---------------------+-----------+
Why ? Can anybody help me with my code above ? Thanks