Php搜索结果不会分配到值中 [英] Php search results are not assigning into values

查看:99
本文介绍了Php搜索结果不会分配到值中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从数据库表中搜索并在HTMl表单上显示,但这些值没有分配给php声明的变量



我尝试过:



i want to search from database table and display on the HTMl form but those values are not assigning to php declared variables

What I have tried:

<?php
    
    
if(isset($_POST['search']))
{
    
    $connect= mysqli_connect("localhost","root","1234","latgsjason");
    if (mysqli_connect_error()){
    echo"Failed to Connect";
    }
//    $result=mysqli_query($connect,"SELECT * FROM customer WHERE veh_regno='$_POST[V_Regno]'");
    $Vregno = $_POST['V_Regno'];
    $query="SELECT 'nic','fullname','address','contact','color' FROM customer WHERE 'veh_regno'=$Vregno LIMIT 1"; 
    $result=mysqli_query($connect,$query);

    while ($row=mysqli_fetch_array($result))
        {
            $VReg=$row['veh_regno'];
            $Nic=$row['nic'];
            $FName=$row['fullname'];
            $Address=$row['address'];
            $Contact=$row['contact'];
            $Color=$row['color'];
        }
        
        mysqli_free_result($result);
        mysqli_close($connect);
}
else
{
    $VReg="";
    $Nic="";
    $FName="";
    $Address="";
    $Contact="";
    $Color="";
}

?>


<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Manage Account</title>
        <link rel="stylesheet" type="text/css" href="CSS/Style SheetGeneral.css">
    </head>
<body>
<br><br><br>

<table background="Images/Back Ground Images/BG1.jpg" border="2" align="center" width ="825" height="820">

    <th align=center valign=center>

        <form action="ManageAccount.php" method="POST"/>

        <div class="textcenter1">
            <h2>Manage An Account</h2>
        </div>
        <br><br>

        <table border="0"; align="center" width ="655" height="550" >
        <tr>
            <td>
                VEHICLE REGISTRATION NUMBER :
            </td>
            <td>
                <input type="text" name="V_Regno" size="40" value="<?php echo $VReg; ?>">
            </td>
        </tr>
        
        <tr>
            <td>
                NATIONAL ID :
            </td>
            <td>
                <input type="text" name="Nic"  size="40" value="<?php echo $Nic; ?>">
            </td>
        </tr>
        
        <tr>
            <td>
                FULL NAME :
            </td>
            <td>
                <input type="text" name="F_Name"  size="40" value="<?php echo $FName; ?>">
            </td>
        </tr>
        
        <tr>
            <td>
                ADDRESS :
            </td>
            <td>
                <input type="text" name="Address" size="40" value="<?php echo $Address; ?>">
            </td>
        </tr>
        
        <tr>
            <td>
                TELEPHONE NUMBER/MOBILE NUMBER :
            </td>
            <td>
                <input type="text" name="Contact" size="40" value="<?php echo $Contact; ?>">
            </td>
        </tr>
        
        <tr>
            <td>
                COLOR :
            </td>
            <td>
                <input type="text" name="Color" size="40" value="<?php echo $Color; ?>">
            </td>
        </tr>
        
<tr>
<td>
NIC Attachment :<select name="NicChk">
                <option selected="" value="">(New Document?)</option>
                <option value="yes">YES</option>
                <option value="no">NO</option>
                </select>
</td>
<td>
    <input type="file" name="Nic_Img" accept="image/*">
</td>
</tr>
<tr>
<td>
Registration Certificate :  <select name="RCcheck">
                            <option selected="" value="">(New Document?)</option>
                            <option value="yes">YES</option>
                            <option value="no">NO</option>
                            </select>
</td>
<td>
    <input type="file" name="Reg_Cer" accept="image/*">
</td>
</tr>

<tr>
<td></td>
<td>
    <input align="left" type="image" src="Images/Buttons/button_search.png" alt="button" name="search" value="Search" width="110" height="50"/>
</form> 
        
 <!--if submit button and reset button in same <form> will perform the formvalidation which leads the reset button also work as a submit button(wont reset anything)-->
 
 <form action="UpdateAccount.php" method="POST"/>
    <input align="center" type="image" src="Images/Buttons/button_update.png" alt="" name="reset" value="reset" width="110" height="50"/>
</td>
</tr>

</form>
 
</table>


</th>
</table>
<br><br>

</body>
</html>

推荐答案

_POST ['search']))
{
_POST['search'])) {


connect = mysqli_connect(localhost,root,1234,latgsjason);
if(mysqli_connect_error()){
echo连接失败;
}
//
connect= mysqli_connect("localhost","root","1234","latgsjason"); if (mysqli_connect_error()){ echo"Failed to Connect"; } //


result = mysqli_query(
result=mysqli_query(


这篇关于Php搜索结果不会分配到值中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆