我在这里虚拟了页面:http://bsaroundtable.org/scota/testit.php运行它所需要做的就是点击提交按钮。已经提供了一个值。 下面是 editDBlisting.php 代码,它应该用来构建(在本例中)一个表。
但除了大部分 echo("in the php, str = $q"); 之外,我什么也没得到。然后只有文本而不是 $q 的值。所以我知道它没有到达 PHP。但为什么?我尝试过 GET 而不是 POST,以及几乎所有其他可用的组合。
这几乎是我在另一个地方所做的事情,它工作得很好,所以毫无疑问我有一个我找不到的小错误。 请帮我找出问题所在。
这次你可以取笑我没有看到它。
{
/* Title: editDBlisting.php
Written: 2016=07-12
Reference:
*/
ini_set("display_errors",1);
error_reporting (E_ALL ^ E_NOTICE);
require_once "dbConnectDtls.php";
define("CONST_USER_TIMEZONE", "America/Chicago");
/* server timezone */
define("CONST_SERVER_TIMEZONE", "CST");
/* server dateformat */
define("CONST_SERVER_DATEFORMAT", "Y-m-d H:i:s");
function now($str_user_timezone = CONST_USER_TIMEZONE,
$str_server_timezone = CONST_SERVER_TIMEZONE,
$str_server_dateformat = CONST_SERVER_DATEFORMAT) {
// set timezone to user timezone
date_default_timezone_set($str_user_timezone);
$date = new DateTime("now");
$date->setTimezone(new DateTimeZone($str_server_timezone));
$str_server_now = $date->format($str_server_dateformat);
// return timezone to server default
date_default_timezone_set($str_server_timezone);
return $str_server_now;
}
$dttm_change = now(CONST_USER_TIMEZONE,CONST_SERVER_TIMEZONE,CONST_SERVER_DATEFORMAT);
$q = $_POST["str"];
echo("in the php, str = $q");
$stmt = $db_found->prepare("SELECT * FROM SCOTA WHERE edit_code = '$q' ");
$stmt->execute();
$result = $stmt->fetchAll();
foreach($result as $row) {
echo ("<table id='feedback'>
<col><col><col><col><col><col><col><col><col>
<thead style='text-align: center;'>
<tr>
<th>CRN</th>
<th>Registrar</th>
<th>Call Sign</th>
<th>eMail</th>
<th>Youth</th>
<th>Adult</th>
<th>Camp Name</th>
<th>Official</th>
<th>City</th>
</tr></thead><tbody><tr>");
echo ("<td class=\"edit\" id=\"campRegNumber:$row[id]\">$row[campRegNumber] </td>");
echo ("<td class=\"edit\" id=\"name:$row[id]\">$row[name] </td>");
echo ("<td class=\"edit\" id=\"callSign:$row[id]\">$row[callSign] </td>");
echo ("<td class=\"edit\" id=\"eMail:$row[id]\">$row[eMail] </td>");
echo ("<td class=\"edit\" id=\"adultCount:$row[id]\">$row[adultCount] </td>");
echo ("<td class=\"edit\" id=\"youthCount:$row[id]\">$row[youthCount] </td>");
echo ("<td class=\"edit\" id=\"campName:$row[id]\">$row[campName] </td>");
echo ("<td class=\"edit\" id=\"official_scout_camp:$row[id]\">$row[official_scout_camp] </td>");
echo ("<td class=\"edit\" id=\"city:$row[id]\">$row[city] </td>");
echo ("</tr></tbody></table>");
echo ("<br><br>");
echo ("<table id='feedback'>
<col><col><col><col><col><col><col><col><col><col><col>
<thead style='text-align: center;'>
<tr>
<th>State</th>
<th>Country</th>
<th>Latitude</th>
<th>Longitude</th>
<th>Grid</th>
<th>Power</th>
<th>Date Start</th>
<th>Time Start</th>
<th>Time End</th>
<th>Date End</th>
<th>Comments</th>
</tr>
</thead><tbody><tr>");
echo ("<td class=\"edit\" id=\"state:$row[id]\">$row[state] </td>");
echo ("<td class=\"edit\" id=\"country:$row[id]\">$row[country] </td>");
echo ("<td class=\"edit\" id=\"latitude:$row[id]\">$row[latitude] </td>");
echo ("<td class=\"edit\" id=\"longitude:$row[id]\">$row[longitude] </td>");
echo ("<td class=\"edit\" id=\"grid:$row[id]\">$row[grid] </td>");
echo ("<td class=\"edit\" id=\"power:$row[id]\">$row[power] </td>");
echo ("<td class=\"edit\" id=\"dateStart:$row[id]\">$row[dateStart] </td>");
echo ("<td class=\"edit\" id=\"timeStart:$row[id]\">$row[timeStart] </td>");
echo ("<td class=\"edit\" id=\"timeEnd:$row[id]\">$row[timeEnd] </td>");
echo ("<td class=\"edit\" id=\"dateEnd:$row[id]\">$row[dateEnd] </td>");
echo ("<td class=\"edit\" id=\"comments:$row[id]\">$row[comments] </td>");
}
echo ("</tr></tbody></table>");
?>
}
最佳答案
也许有不止一个错误,但我可以看到,在testit.php
页面上的表单中,您已将输入名称设置为getCode
,但在 editDBlisting.php
中,您有行 $q = $_POST['str'];
而不是 $q = $_POST['getCode'];
关于javascript - PHP/MySQL的返回如何返回到调用页面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38381566/