我是mysqli的新手,并且遇到了使用mysqli循环结果的问题.不幸的是,我只得到了一个结果.当我将查询放入phpMyAdmin时,它会得到三个结果.我相信相关的代码在这里,我只是称错了:
$connection = new mysqli($host, $databaseUsername, $databasePassword, $database);
if ($connection->connect_errno > 0) {
die ('Unable to connect to database [' . $connection->connect_error . ']');
}
$sql = "SELECT clientId, studentFirstName, studentLastName
FROM clients
WHERE (studentEmail = '$postEmail') OR (parentEmail = '$postEmail');";
if (!$result = $connection->query($sql)) {
die ('There was an error running query[' . $connection->error . ']');
}
echo '<select class = "toolbarDropdown" id = "toolbarDropdown-MultipleAccounts">';
while ($row = $result->fetch_array()) {
echo '<option value="'.$row["clientId"].'">'.$row["studentFirstName"].' '.$row["studentLastName"].'</option>';
}
echo '</select>';
Run Code Online (Sandbox Code Playgroud) 所以我将这个SQL的结果提供给一个数组.该数组稍后将成为在键入时操作的文本框的建议.我希望它只返回每个名字1次,即使这个人有多个约会.目前,这将返回具有该名称的人的所有约会,因此如果"Brad Robins"有5个约会,并且我开始键入"Brad",则它会在建议中显示"Brad Robins"5次,而不是仅显示一次.
$sql = "SELECT DISTINCT CONCAT(clients.studentFirstName, ' ', clients.studentLastName) AS name, appointments.location, appointments.subLocation, appointments.appointmentAddress1, appointments.appointmentAddress2, appointments.appointmentCity, appointments.appointmentState, appointments.appointmentZip, appointments.startTime, appointments.endTime, appointments.date, clients.school
FROM appointments JOIN clients
ON appointments.clientID = clients.clientID
WHERE CONCAT(clients.studentFirstName, ' ', clients.studentLastName) = '".$roommate."' AND clients.school = '".$school."';";
Run Code Online (Sandbox Code Playgroud)
对我来说,似乎DISTINCT和CONCAT并没有很好地融合在一起.
使用邮递员,我发送一个POST(我的用户名和密码填写):
https://ssl.reddit.com/api/login?api_type=json&user=XXX&passwd=XXX&rem=True
Run Code Online (Sandbox Code Playgroud)
我收到一个包含modhash和cookie的回复.然后,我发送第二个POST邮递员到:
https://en.reddit.com/api/comment?api_type=json&text=7/1/15TEST&thing_id=t1_csa56v2
Run Code Online (Sandbox Code Playgroud)
使用以下标题(XXX已确认并填写):
User-Agent: XXX
Cookie: reddit_session=XXX
X-Modhash: XXX
Run Code Online (Sandbox Code Playgroud)
这提供了正确的响应,但是当我尝试在PHP中使用CURL执行相同的操作时,它会以USER_REQUIRED响应.我再一次确认cookie和modhash是正确的.
$name = 't1_csa56v2';
$text = 'NEWEST TEST 7/2/15 12:20am';
$url = 'https://en.reddit.com/api/comment';
$modhash = 'XXX';
$cookie = 'XXX';
$headerFields = array (
'User-Agent' => 'XXX',
'Cookie' => 'reddit_session='.$cookie,
'X-Modhash' => $modhash
);
$postFields = array (
'api_type' => 'json',
'text' => $text,
'thing_id' => $name
);
$field_string = http_build_query($postFields);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headerFields);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 3);
curl_setopt($ch, CURLOPT_POSTFIELDS, $field_string);
$response = curl_exec($ch);
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?为什么我不能得到相同的回复? …
我尝试了几种不同的方法在CSS中包含正确的字体.我知道我需要eot版本的字体才能在IE上运行,但是我无法识别它.我使用字体squirrel来转换字体,我已将.eot文件和.otf文件放在一个名为"fonts"的文件夹中.这是我的CSS:
@font-face {
font-family: BebasNeue;
src: url('fonts/BebasNeue.eot');
src: url('fonts/BebasNeue.otf') format("opentype");
}
Run Code Online (Sandbox Code Playgroud)
更新 通过以下建议,我被引导到这个网站:http://www.fontspring.com/blog/further-hardening-of-the-bulletproof-syntax
我使用CSS:
@font-face {
font-family: 'BebasNeue';
src: url('fonts/bebasneue.eot'); /* IE9 Compat Modes */
src: url('fonts/bebasneue.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('fonts/bebasneue.woff') format('woff'), /* Modern Browsers */
url('fonts/bebasneue.ttf') format('truetype'), /* Safari, Android, iOS */
url('fonts/bebasneue.svg#svgBebasNeue') format('svg'); /* Legacy iOS */
}
Run Code Online (Sandbox Code Playgroud)
然后我回到Font Squirrel,再次下载了新的工具包,并正确地重命名了一切,并且工作正常.
所以我一直收到错误:
employeesScript.js:3Uncaught SyntaxError:意外的令牌{.
它让我疯狂,因为我无法弄清楚是什么导致它.我也通过JSFiddle运行它并得到以下错误:
Error:
Problem at line 3 character 50: Expected ')' and instead saw '{'.
$(".employeesPostHours").live("click", fuction() {
Problem at line 3 character 51: Missing semicolon.
$(".employeesPostHours").live("click", fuction() {
Problem at line 45 character 1: Expected '(end)' and instead saw '}'.
});
Implied global: $ 1,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,20, fuction 3, employeeEntry 5,6,7,8,9,10,11,12,13, employeesId 6,23, employeesEmail 7,24, employeesStartTime 8,25, employeesEndTime 9,26, employeesDate 10,27, employeesExtraMoney 11,28, employeesExtraMoneyDetail 12,29, driving 13,30, onTruck 14,31, warehouse 15,32, phones 16,33, flyering 17,34, wageChange 18,35, alert 38 …Run Code Online (Sandbox Code Playgroud) 在 Google 表格中,我想输入一个公式,无论排序如何,该公式都会获取其正下方单元格的值。额外的问题是,我输入公式的单元格在排序后并不总是位于同一位置。
因此,如果我在单元格 A1 中输入公式,我想获取 A2 的值。但是,如果我重新排序,并且该单元格现在位于 A5 中,我希望它为我提供 A6 的值。无论我将目标单元格或带有公式的单元格移动到哪里,我总是想引用位于正下方的单元格。
我觉得也许是地址和间接的某种组合,但我很难理解这一点。
我正在尝试编写一个 SQL 查询,该查询返回自 4 月 1 日以来拥有新发票但尚未安排今年秋季交货的客户的所有学生电子邮件地址。即使我知道有满足这些条件的条目,这也会返回一个空集。我尝试了几种不同的方法,但没有成功,有办法做到这一点吗?
SELECT clients.studentEmail
FROM `clients`, `invoices`
WHERE clients.clientId = invoices.clientId
AND invoices.datePosted > "2013-04-01"
AND NOT EXISTS
(SELECT *
FROM appointments, clients
WHERE clients.clientId = appointments.clientId
AND appointments.serviceDirection = "Delivery"
AND appointments.date > '2013-07-01')
Run Code Online (Sandbox Code Playgroud)