1
這裏是我的代碼MySQL的替換特定的文本列基於檢查
$all = array();
$pdo = new PDO("mysql:host=$hostname;dbname=$dbname;charset=utf8", $username, $password);
$stmt = $pdo->query("SELECT `resume_status` , count(`resume_status`) total_candidates
FROM `conts` WHERE `client_id` = '56' group by `resume_status`");
$all[] = $stmt->fetchAll(PDO::FETCH_ASSOC);
echo json_encode($all);
如果我打印$所有的數組沒有JSON編碼它,它顯示了以下數據
Array
(
[0] => Array
(
[0] => Array
(
[resume_status] => 1
[total_candidates] => 39
)
[1] => Array
(
[resume_status] => 2
[total_candidates] => 7
)
[2] => Array
(
[resume_status] => 3
[total_candidates] => 2
)
)
)
我取從表中的多個狀態針對該resume_status柱
如果resume_status = 1(那麼它應該是resume_status => '待處理')
如果resume_status = 2(那麼它應該是resume_status> '在隊列')
如果resume_status = 3(那麼它應該是resume_status => '已批准')
我已經在試圖case語句查詢但沒有成功。任何幫助都感激不盡。感謝
謝謝.. 曾任職完美:) –