douoyou3348 2017-03-21 13:33
浏览 24
已采纳

如何将文本框的值复制到我的查询中

I have my textbox named Title here!

The Title is the upper most Textbox! I have a query where i should copy the value of that textbox which is 'A' to my query here

        $sql_query="SELECT * FROM tblpost WHERE Page = 'A' ";

this is exactly my code! Hope everyone can guide me because I am Actually new in PHP this is my whole code

        <form method="post">
        <div class="form-group">
      <label>Page Title</label>
      <input name="title" type="text"  value="<?php echo $fetched_row['Title']; ?>" required class="form-control" placeholder="Page Title">
    </div>
  <div class="form-group">
      <select class="form-control" name="active"  id="active">
          <option value="">~~SELECT~~</option>
          <option value="Actived">Activated</option>
          <option value="Deactivated">Deactivated</option>
        </select>
    </div>
    <div class="form-group">
      <label>Meta Tags</label>
      <input type="text"  value="<?php echo $fetched_row['Tags']; ?>" name="tags" required class="form-control" placeholder="Add Some Tags...">
    </div>
    <div class="form-group">
      <label>Category</label>
      <input type="text" name="description"  value="<?php echo $fetched_row['Description']; ?>" class="form-control" required placeholder="Add Category...">
    </div>

         <table class="table table-striped table-hover" id="myTable">
                  <tr>
                    <th>Page Title</th>
                    <th>Status</th>
                    <th>Date Created</th>
                    <th></th>
                  </tr>

                         <?php



                        $sql_query="SELECT * FROM tblpost WHERE Page = //I think it's right here ";

                        $result_set=mysql_query($sql_query);
                        while($row=mysql_fetch_row($result_set))
                        {
                          ?>

                        <tr>
                            <td><?php echo $row[1]; ?></td>
                            <td><?php echo $row[3]; ?></td>
                            <td><?php echo $row[6]; ?></td>
                            <td><a class="btn btn-primary" href="javascript:edt_id('<?php echo $row[0]; ?>')">Edit</a>   <a class="btn btn-danger" href="javascript:delete_id('<?php echo $row[0]; ?>')">Delete</a></td>      
                          </tr>
                            <?php
                     }
                     ?>

                          <script>
                          function myFunction() {
                            var input, filter, table, tr, td, i;
                            input = document.getElementById("myInput");
                            filter = input.value.toUpperCase();
                            table = document.getElementById("myTable");
                            tr = table.getElementsByTagName("tr");
                            for (i = 0; i < tr.length; i++) {
                              td = tr[i].getElementsByTagName("td")[0];
                              if (td) {
                                if (td.innerHTML.toUpperCase().indexOf(filter) > -1) {
                                  tr[i].style.display = "";
                                } else {
                                  tr[i].style.display = "none";
                                }
                              }       
                            }
                          }
                          </script>


             </table>

           <center> <button type="submit" class="btn btn-primary" name="btn-update"><strong>UPDATE</strong></button> <button type="submit" class="btn btn-default" name="btn-cancel"><strong>Cancel</strong></button></center>

                 </form>
  • 写回答

4条回答 默认 最新

  • dtah63820 2017-03-21 13:45
    关注

    If I understand your code snippet correctly, at page load time the "title" is carries in a array variable: $fetched_row['Title']

    So essentially your code should be something like:

    $sql_query="SELECT * FROM tblpost WHERE Page = '".mysql_real_escape_string($fetched_row['Title'])."';";

    If this is new code, you really should use mysqli instead of the deprecated mysql, if at all possible.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算