dongxuying7583 2015-10-28 14:33
浏览 49

结果查询TextBox Html中的Php

I have a PHP page in wich I charge result of a query into a Table that i defined like so:

<?php
$json=file_get_contents("http://www.example.com/myfile.php");
$data =  json_decode($json);

if (count($data->result)) {
echo "<table id= 'tabclb'>";
foreach ($data->result as $arr => $result) {
echo"<tr>";
echo "<td><a href=sel_clb.php?id=$result->ID>$result->ID</a></td>";  
echo"<td>$result->Name</a></td>";
echo"</tr><td>";
        }
echo "</table>";
} 
?>

As you can see, my table will have an hyperlink to a php file to recall that name using the ID record. In php file where i have stored my query, I use GET to execute query Json. Well, can someone tell me how I can take ID and Name from query and put them into two textbox that I already have created in my php page like so?

</form>
          <form action="upd_collab.php" method="post" name="form" id="form">
            <label for="nome">Recall</label>
            <input name="idx" type="text" placeholder="idx"/>
            <label for="pass"><br />
            <br />
            Nome<br />
            <input name="Nome" type="text" placeholder="Nome"/>
            <br />
                            Sesso (M/F)</label>
            <p><input name="Sesso" type="Sesso" placeholder="Sesso"/>
            </p>
            <p>
              <input name="submit" type="submit" value="Modifica"/>
            </p>
            <p> </p>
          </form>

I hope it's clear. Thanks

  • 写回答

2条回答 默认 最新

  • duanqiang2617 2015-10-28 14:46
    关注

    I'll elaborate on my comment that you can do this by interspersing PHP with HTML to achieve this server-side, per your request.

    Assuming the HTML for your form is inside your PHP file but outside your PHP tags, you can add the value of a php variable anywhere in the HTML like so:

        <input name="idx" type="text" placeholder="idx" value='<?php echo $valueOfIDX; ?>'/>
    

    For this to work you must not get to this HTML/variable printing section until after you have the value of your relevant variable, since PHP script is executed line by line without any hoisting.

    I'll also add this question has been answered here: PHP - Set value in HTML-Form

    And you will also find many more examples with an internet search.

    评论

报告相同问题?

悬赏问题

  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用