else if short form with strange behaviour

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
shikra
Forum Newbie
Posts: 2
Joined: Sun Jun 13, 2010 11:39 pm

else if short form with strange behaviour

Post 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]
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: else if short form with strange behaviour

Post by requinix »

There's no condition of any kind in your UPDATE. That means it will update every row in the table.
shikra
Forum Newbie
Posts: 2
Joined: Sun Jun 13, 2010 11:39 pm

Re: else if short form with strange behaviour

Post by shikra »

thanks for reply I made a silly mistake. thanks for pointing out
Post Reply