duanchi6397 2018-06-01 15:45
浏览 50
已采纳

使用表条目加一个填充文本框?

I am trying to increment project number based on the last entry. The the primary key PROJECTNOID auto-increments but is not the same format as the project number (Ex: PROJECTNOID = 1 and Project Number = 19000). I don't want this to be a dropdown box even though some of my code shows the opposite.

<?php
   connect = mysqli_connect("**", "**", "**", "**");

   $query4 = "SELECT PROJECTNOID, ProjectNumber FROM tblProjects ORDER BY 
              PROJECTNOID";
   $result4 = mysqli_query($connect,$query4);

   $options4 = "";

   while($row4 = mysqli_fetch_row($result4);){
      $options4 = $options4."<input value=$row4[0]$row4[1]</input>";
   }

?>

Here is the html textbox:

<label for="txtfield">Project Number</label>
            <!--<input type="text" id="reqtxtfield" name="projectnumber" 
value="<?php  ?>" readonly/>-->
              <?php echo $options4;?>
  • 写回答

2条回答 默认 最新

  • douxian1923 2018-07-05 14:44
    关注

    PHP:

    <?php
      $query_5 = "SELECT MAX(ProjectNumber) FROM tblProjects;";
      $result_5 = mysqli_query($conn, $query_5);
      $row_5 = mysqli_fetch_array($result_5);
      $nextproject=$row_5['MAX(ProjectNumber)']+1;
    ?>
    

    HTML:

    <html>
      <form class="myform" action="<?php echo htmlspecialchars($_SERVER[" PHP_SELF "]);?>" method="post">
      <label for="txtfield">Project Number</label>
         <input type="text" id="reqtxtfield" name="projectnumber" value="<?php echo $nextproject ?>" readonly/><br>
    

    After running successful insert query:

    echo "<meta http-equiv='refresh' content='0'>";  //REFRESH PAGE TO UPDATE PROJECT NUMBER
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 nginx反向代理获取ip,java获取真实ip
  • ¥15 eda:门禁系统设计
  • ¥50 如何使用js去调用vscode-js-debugger的方法去调试网页
  • ¥15 376.1电表主站通信协议下发指令全被否认问题
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥15 复杂网络,变滞后传递熵,FDA
  • ¥20 csv格式数据集预处理及模型选择
  • ¥15 部分网页页面无法显示!
  • ¥15 怎样解决power bi 中设置管理聚合,详细信息表和详细信息列显示灰色,而不能选择相应的内容呢?
  • ¥15 QTOF MSE数据分析