Page 1 of 1

else if short form with strange behaviour

Posted: Sun Jun 13, 2010 11:42 pm
by shikra

Code: Select all

$sql_coupon_expire = "SELECT * FROM tbl_coupon";
	
 	$itm = 'info@itmentors.com.pk';
	$aj = 'avj123@msn.com';	
	$coupon_res = executeQuery($sql_coupon_expire);

	while($row=mysql_fetch_assoc($coupon_res)){

		$coupon_update = "UPDATE tbl_coupon SET email = '".($email =($email == $aj)? $itm:$aj)."'";
		echo $coupon_update."<br />";
		executeQuery($coupon_update);
	 }
[text] the echo is just fine with alternative email selected with each row but the database is updated with on one value that is $aj any explanation why it is so?[/text]

Re: else if short form with strange behaviour

Posted: Mon Jun 14, 2010 12:43 am
by requinix
There's no condition of any kind in your UPDATE. That means it will update every row in the table.

Re: else if short form with strange behaviour

Posted: Mon Jun 14, 2010 1:09 am
by shikra
thanks for reply I made a silly mistake. thanks for pointing out