php if语句 为真,PHP - IF语句始终为True In While循环

Im目前正在开发adwords SDK。

从数据库中查询产品是否有货,并将广告设置为暂停或启用。

现在在我的while循环中,我有一个IF语句,由于某种原因,它总是正确地启动。我想也许它只使用第一个价值,而不是通过$股票循环,如果这是什么情况下的任何想法?

我需要它来运行每个库存状态。如果'有存货'后启用其他设置为暂停

继承人的代码

$sql = "SELECT * FROM MYDB.MYTBL" ;

$result = mysqli_query($conn, $sql);

if ($result) {

while($row = mysqli_fetch_array($result))

{

$adGroup = $row['adgroup'];

$adGroupId = $row['adgroup_id'];

$product = $row['product'];

$stock = $row['stock'];

$client = $row['client'];

if ($stock === "In Stock") {

if(!function_exists('UpdateAdGroupExample')){

function UpdateAdGroupExample(AdWordsUser $user, $adGroupId) {

// Get the service, which loads the required classes.

$adGroupService = $user->GetService('AdGroupService', ADWORDS_VERSION);

// Create ad group using an existing ID.

$adGroup = new AdGroup();

$adGroup->id = $adGroupId;

// Update the status.

$adGroup->status = 'ENABLED';

// Create operation.

$operation = new AdGroupOperation();

$operation->operand = $adGroup;

$operation->operator = 'SET';

$operations = array($operation);

// Make the mutate request.

$result = $adGroupService->mutate($operations);

// Display result.

$adGroup = $result->value[0];

printf("Ad group with ID '%s' has updated default bid '$%s'.\n", $adGroup->id,

$adGroup->status);

}

try {

// Get AdWordsUser from credentials in "../auth.ini"

// relative to the AdWordsUser.php file's directory.

$user = new AdWordsUser();

$user->SetClientCustomerId('XXXXXXXXX');

// Log every SOAP XML request and response.

$user->LogAll();

// Run the example.

UpdateAdGroupExample($user, $adGroupId);

} catch (Exception $e) {

printf("An error has occurred: %s\n", $e->getMessage());

}

}

try {

// Get AdWordsUser from credentials in "../auth.ini"

// relative to the AdWordsUser.php file's directory.

$user = new AdWordsUser();

$user->SetClientCustomerId('XXXXXXXXX');

// Log every SOAP XML request and response.

$user->LogAll();

// Run the example.

UpdateAdGroupExample($user, $adGroupId);

} catch (Exception $e) {

printf("An error has occurred: %s\n", $e->getMessage());

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值