doutang0335 2016-07-14 18:25
浏览 66
已采纳

如何从PHP / MySQL返回到调用页面?

I've dummied up the page here: http://bsaroundtable.org/scota/testit.php All you need to do to run it is hit the submit button. A value is already supplied. Below is the editDBlisting.php code that it is supposed to use to build (in this case) a table.

But I never get anything back except most of the echo("in the php, str = $q"); and then only the text and not the value of $q. So I understand that its not getting to the PHP. But why? I've tried GET instead of POST, plus nearly every other combination available.

This is nearly line for line what I'm doing in another place and it works perfectly so no doubt I've got a little error that I can't find. Please help me find the issue.

This time you can make fun of me for not seeing it.
{

/*  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>"); 

?>

}

  • 写回答

1条回答 默认 最新

  • dsa99349 2016-07-14 18:35
    关注

    Maybe there is more than one mistakes, but what I can see is that in the form on the page testit.php you have set name of input to getCode, but in editDBlisting.php you have line $q = $_POST['str']; instead of $q = $_POST['getCode'];

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 我的代码无法在vc++中运行呀,错误很多
  • ¥50 求一个win系统下运行的可自动抓取arm64架构deb安装包和其依赖包的软件。
  • ¥60 fail to initialize keyboard hotkeys through kernel.0000000000
  • ¥30 ppOCRLabel导出识别结果失败
  • ¥15 Centos7 / PETGEM
  • ¥15 csmar数据进行spss描述性统计分析
  • ¥15 各位请问平行检验趋势图这样要怎么调整?说标准差差异太大了
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 wpf界面一直接收PLC给过来的信号,导致UI界面操作起来会卡顿
  • ¥15 init i2c:2 freq:100000[MAIXPY]: find ov2640[MAIXPY]: find ov sensor是main文件哪里有问题吗