doubinei1457 2017-03-20 22:02
浏览 144
已采纳

从$ _POST获取数据并在php中显示特定数据

This may have been asked before but i have not been able to find it.

I have created a dropdown list in a form to show a selection from a database. I am then sending that information via $_POST to another page. But i am only getting the one result (eg plantID).

$sql = "SELECT DISTINCT * FROM PLANTS";
$result = mysqli_query($mysqli,$sql)or die(mysqli_error());

//********************* Botannical name drop down box

echo "<form name='selection' id='selection' action='profile.php' method='post'>";

echo "<select name='flower'>";

while($row = mysqli_fetch_array($result)) {
    $plantid = $row['FlowerID'];
    $plantname = $row['Botannical_Name'];
    $plantcommon = $row['Common_Name'];
    $plantheight = $row['Height'];
    $plantav = $row['AV'];
    $plantcolours = $row['Colours'];
    $plantflowering = $row['Flower_Time'];
    $plantspecial = $row['Special_Conditions'];
    $plantfrost = $row['Frost_Hardy'];
    $plantaspect = $row['Aspect'];
    $plantspeed = $row['Growth_Speed'];

    echo "<option value=".$plantid.">".$plantname." -> AKA -> ".$plantcommon."</option>";
} 
echo "</select>";
echo "<br />";


//********************* End of form
echo "<input type='submit' name='submit' value='Submit'/>";
echo "</form>";

Is there any way i can send all the data via post or can i somehow get the required PlantID from the database and show all the information for that record in a table on the second page. Hope this makes sense to someone out there :D

展开全部

  • 写回答

1条回答 默认 最新

  • dongsi8812 2017-03-20 22:19
    关注

    Although technically you can, it is not advised nor used anywhere.

    Just send an id like you do right now and then select all the data with another query based on this id.

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

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部