Now I’m creating a code to query a DB. The DB is working fine and my query to, but I use a while statement in my code to search by email my DB, is the user exists, the message :
echo"<h2>User information</h2><br>";
echo"<b>$nombre $apellido1 $apellido2</b><br>";
is show.
If not the message :
echo"This email is not in DB!!!";
THE COMPLETE CODE IS:
<?php
include('config.php');
db_connect();
viewheader();
$email5=$email_busca;
$sql = "SELECT * FROM $dbtable";
$resultat = mysql_db_query($dbname, $sql);
if(empty($debut)) $debut = 0;
$nb_total=mysql_num_rows($resultat);
$sql = "SELECT * FROM $dbtable ORDER BY username ASC limit $debut, $max";
$resultat = mysql_db_query($dbname, $sql);
$nbenr = mysql_num_rows($resultat);
while ($profil = mysql_fetch_array($resultat))
{
$myid = ($profil["id"]);
$username = ($profil["username"]);
$nombre = ($profil["nombre"]);
$apellido1 = ($profil["apellido1"]);
$apellido2 = ($profil["apellido2"]);
if (($email1)== ($email5))
{
echo"<h2>User information</h2><br>";
echo"<b>$nombre $apellido1 $apellido2</b><br>";
}
else
echo"This email is not in DB!!!";
}
@mysql_close($db);
?>
The problem is when the user exists the information of my user is show but also 6 times the message This email is not in DB!!!.
I have six records at this moment in my DB this is why the message is show six times.
But is the email is not valid the message This email is not in DB!!! is show six times.
I already use the exit; to end the while but if I use It for a invalid email no message is show.
NEED HELP TO FINISH MY PROYECT
THANKS .
MARIO
Have a problem with a while function !!!!!!!!!
Moderator: General Moderators
I cant see that you declared $email1 anywhere, hence
will allway return false, and your echo goes out...
Code: Select all
<?php
if (($email1)== ($email5))
?>