如何使用表单提取数据并使用php在表格中显示它

时间:2022-10-25 19:57:53

I am not sure how to go about doing this, but I have an assignment tomorrow and i'm new in php i have to put in the html part a text box and check bob and radio button and drop down list and then take data from user and then extract data in php and display it in table also using php . Any one can helps me please

我不知道怎么做这个,但我明天有一个任务,我是php的新手我必须在html部分放一个文本框并检查bob和单选按钮和下拉列表,然后从中获取数据用户然后在php中提取数据并使用php将其显示在表中。任何人都可以帮助我

1 个解决方案

#1


0  

file.html

<form action="file.php" method="post">
Name:<input type="text" name="name"><br>From<br>
<input type="radio" name="from" value="us">US<br>
<input type="radio" name="from" value="else">Else<br>
<select name="car">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="fiat" selected>Fiat</option>
<option value="audi">Audi</option>
</select>
<input type="submit">
</form>

file.php

   <?php
   $name = $_POST['name'];
   //this takes the data from input
    $from = $_POST['from'];
    $car = $_POST['car'];
    echo "<table><tr><td>Name</td><td>From</td><td>Car</td></tr>
    <tr><td>".$name."</td><td>".$from."</td><td>".$car."</td></tr></table>";`
    ?>

This will return a table with the inserted values.

这将返回一个包含插入值的表。

#1


0  

file.html

<form action="file.php" method="post">
Name:<input type="text" name="name"><br>From<br>
<input type="radio" name="from" value="us">US<br>
<input type="radio" name="from" value="else">Else<br>
<select name="car">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="fiat" selected>Fiat</option>
<option value="audi">Audi</option>
</select>
<input type="submit">
</form>

file.php

   <?php
   $name = $_POST['name'];
   //this takes the data from input
    $from = $_POST['from'];
    $car = $_POST['car'];
    echo "<table><tr><td>Name</td><td>From</td><td>Car</td></tr>
    <tr><td>".$name."</td><td>".$from."</td><td>".$car."</td></tr></table>";`
    ?>

This will return a table with the inserted values.

这将返回一个包含插入值的表。