[英]PHP assign MySQLi database value to a PHP variable based on selected row
我想根据数据库中所选学生的相应“contact_number”分配“$numbers”的值。 我试过了:
$numbers = "SELECT contact_number from students where idnumber='$idnumber'";
但它只选择所选学生的 idnumber。
我的桌子图片:学生桌
编码:
<?php
$username = "******@****";
$hash = "*******";
// Config variables. Consult http://api.txtlocal.com/docs for more info.
$test = "0";
// Data for text message. This is the text message data.
$sender = "CCA Update"; // This is who the message appears to be from.
$numbers = "SELECT contact_number from students where idnumber='$idnumber'";
// A single number or a comma-seperated list of numbers
$message = "Your grade has been updated!";
// 612 chars or less
// A single number or a comma-seperated list of numbers
$message = urlencode($message);
$data = "username=".$username."&hash=".$hash."&message="
.$message."&sender=".$sender."&numbers=".$numbers."&test=".$test;
$ch = curl_init('https://api.txtlocal.com/send/?');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch); // This is the result from the API
curl_close($ch);
print_r($result);
?>
如果需要,我可以提供更多信息。
解决了! 这是代码:
$numbers = $row['contact_number'];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.