gpt4 book ai didi

php - 为什么我的表单选择没有改变 mysql 查询逻辑?

转载 作者:太空宇宙 更新时间:2023-11-03 10:43:05 25 4
gpt4 key购买 nike

<分区>

我正在尝试获取一个简单的下拉选择表单来更改 reg_id 查询以发送 gcm 消息。查询是从所有 channel 中选择的 reg_id!='0' 但不是“AND .$and. 额外条件。看起来很简单但不能正常工作。$count 的回显总是相同的

<html>
<head>
<title>Notifications</title>
</head>

<body>
<form method="post">
<textarea type="text" name="msg" id="msg" rows="25" cols="80"></textarea>
<input type="submit" value="send"/>

<div class="col-md-2">
<select name="cat" class="form-control">
<option value="All">All</option>
<option value="ranked">ranked</option>
<option value="new">new</option>
</select>
</div>
</form>
</body>
</html>


<?php
switch($_GET['cat']){
case 'All':
$and='user_id!="2095"';
break;

case 'ranked':
$and='salutes>"10"';
break;

case 'new':
$and='created=CURDATE()';
break;

default:
$and='user_id!="2095"';
}

if(isset($_POST['msg'])){
$pdo=new PDO('mysql://hostname=localhost;dbname=database', 'user', 'password');

$user_ids=$pdo->query('select reg_id from accounts where channel!="0" AND '.$and.' AND user_id!="2095"');
$user_ids=$user_ids->fetchAll(PDO::FETCH_ASSOC);
$ids=array();
foreach($user_ids as $row){
$ids[]=$row['reg_id'];
$count++;
}
// API access key from Google API's Console
define( 'API_ACCESS_KEY',"***************");
$msg = array
(
'privateMessage' => "{$_POST['msg']}",
'messageText' => "{$_POST['msg']}",
'user_id' => "2095",
'handle' => "Administration",
'rank' => "z"
);
$fields = array
(
'registration_ids' => $ids,
'data' => $msg,
"time_to_live" => 3,
"priority" => "high",
);

$headers = array
(
'Authorization: key=' . API_ACCESS_KEY,
'Content-Type: application/json'
);

$ch = curl_init();
curl_setopt( $ch,CURLOPT_URL, 'https://android.googleapis.com/gcm/send' );
curl_setopt( $ch,CURLOPT_POST, true );
curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );
curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false );
curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $fields ) );
$result = curl_exec($ch );
curl_close( $ch );
echo $count;
}

?>

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com