Jump to content

short form of if else does not update database correctly


shikra

Recommended Posts

$sql_coupon_expire = "SELECT * FROM tbl_coupon";

 

$itm = '[email protected];

$aj = '[email protected]';

$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);

}

 

The echo output of the query is just fine i.e alternative email is selected but database is updated with only one value... any explanation why?

 

$sql_coupon_expire = "SELECT * FROM tbl_coupon";

 

$itm = '[email protected];

$aj = '[email protected]';

$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);

}

 

The echo output of the query is just fine i.e alternative email is selected but database is updated with only one value... any explanation why?

need to include the where clause for it to work as desired

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.