I need to check for the presence of a text say 'mrame' in the row values in DB. I do this by the below code. But the else part executes whenever $username !== $x. I don't want this to happen. My aim is to execute the else part only for the first time and also the while loop should stop once a else has executed.
$username = "mrame";
$ch=mysql_query("select USER_NAME from ADM_APP_USER_DTL;");
$i=0;
$rows=mysql_num_rows($ch);
while($i < $rows)
{
$x = mysql_result($ch, $i, 0);
if($username==$x)
{
echo "User name already in use. Try another name.";
}
else
{
echo "mrame is testing";
}