lundi 11 juillet 2016

possible ?: mysql row to an if condition

hi guys im trying to insert a mysql data to a variable that will set an if condition depending on the result. is this possible, am i doing it right? what is the right way to do it ? what i want to achieve is to validate if there's a equal value given by the user inside my mysql rows.

$db = mysql_connect('localhost','test','');

if (!$db)
{
  print "<h1>Unable to Connect to MySQL</h1>";
}

$dbname = 'test';

$btest = mysql_select_db($dbname);

if (!$btest)
{
  print "<h1>Unable to Select the Database</h1>";
}


$sql_statement  = "SELECT * ";
$sql_statement .= "FROM registered_email ";


$result = mysql_query($sql_statement);

$outputDisplay = "";
$myrowcount = 0;

if (!$result) {
  $outputDisplay .= "<br /><font color=red>MySQL No: ".mysql_errno();
  $outputDisplay .= "<br />MySQL Error: ".mysql_error();
  $outputDisplay .= "<br />SQL Statement: ".$sql_statement;
  $outputDisplay .= "<br />MySQL Affected Rows: ".mysql_affected_rows()."</font><br />";
} 
 else{
  $numresults = mysql_num_rows($result);

  for ($i = 0; $i < $numresults; $i++)
  {



    $row = mysql_fetch_array($result);

    $id  = $row['id'];
    $sentEmailClients = $row['email'];

    $outputDisplay.= "".$sentEmailClients."<br />";
  }

 }

and here what im trying to achieve, btw is $clientEmail has a default values so dont worry about that.

if($clientEmail === $outputDisplay){

 ...... some codes..........
}
else{
....... some codes.......
}

Aucun commentaire:

Enregistrer un commentaire