Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/237.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在删除该记录之前,如何显示该记录?_Php_Html_Mysql_Mysqli - Fatal编程技术网

Php 在删除该记录之前,如何显示该记录?

Php 在删除该记录之前,如何显示该记录?,php,html,mysql,mysqli,Php,Html,Mysql,Mysqli,我希望在PHP中向用户显示我正在删除的记录 我试图以要删除的形式显示记录,但仅显示输入类型=文本值,而不显示单选按钮值 <?php require('/home/s3022041/sqlC/dbConnect.php'); if(isset($_POST['search'])) { $search = mysqli_real_escape_string($connection, $_POST['id']); $id = $_POST

我希望在PHP中向用户显示我正在删除的记录

我试图以要删除的形式显示记录,但仅显示输入类型=文本值,而不显示单选按钮值

<?php

    require('/home/s3022041/sqlC/dbConnect.php');
    if(isset($_POST['search']))
    {
        $search = mysqli_real_escape_string($connection, $_POST['id']);
        $id = $_POST['id'];

        $stp1 = preg_replace("/[^a-zA-Z0-9]/", "", $id); //grab only the alphanumerics
         $stp2 = strtoupper($stp1); //Make all alphabets uppercase
            $stp3 = preg_replace('/\d+/', '',$stp2); //extract the alphabets part
                $newsearchid = str_replace($stp3,"-".$stp3."-",$stp2); //put hyphens before and after the alphabet part

        $query = "SELECT * FROM cars WHERE Registration_Number = '$newsearchid' ";
        $query_run = mysqli_query($connection, $query);

        while($row = mysqli_fetch_array($query_run))
        {
            ?>

            <form action="delete_process.php" method="POST" class="form">
                    <h2>Car Registration Form</h2>
                    <div class="mb-3">


                        <input type="radio" name="Car" id="Toyota" value=" <?php echo $row['make']; ?>" />

                        <label for="Toyota" class="form-label">Toyota</label>
                        <select name="Models[Toyota]" class="form-control" value=" <?php echo $row['model']; ?>">
                            <option value="">None</option>
                            <option value="Camri">Camri</option>
                            <option value="Corolla">Corolla</option>
                            <option value="Estima">Estima</option>
                        </select><br>

                        <input type="radio" name="Car" id="Nissan" value=" <?php echo $row['make']; ?>"/>

                        <label for="Nissan" class="form-label">Nissan</label>
                        <select name="Models[Nissan]" class="form-control" value=" <?php echo $row['model']; ?>">
                            <option value="">None</option>
                            <option value="Micra">Micra</option>
                            <option value="roller">roller</option>
                            <option value="fushe">fushe</option>
                        </select><br>

                        <input type="radio" name="Car" id="Mercedez" value=" <?php echo $row['make']; ?>"/>

                        <label for="Mercedez" class="form-label">Mercedez</label>
                        <select name="Models[Mercedez]" class="form-control" value=" <?php echo $row['model']; ?>">
                            <option value="">None</option>
                            <option value="5series">5series</option>
                            <option value="x7">x7</option>
                            <option value="x5">x5</option>
                        </select><br>



                        <label for="vehicleidentificationnumber" class="form-label">vehicle identification
                            number(VIN)</label>
                        <input type="text" disabled="disabled" name="vehicleidentificationnumber" class="form-control" maxlength=20 value=" <?php echo $row['VIN']; ?>" required >
                        <br>

                        <label for="ManufacturingYear" class="form-label">Manufacturing Year</label>
                        <input type="text" name="Manufacture_Year" class="form-control" maxlength=20 value=" <?php echo $row['Manufacture_Year']; ?>" required >

                        <label for="Enginesize" class="form-label">Engine size</label>
                        <input type="text" name="Engine_Size" class="form-control" maxlength=20 value=" <?php echo $row['Engine_Size']; ?>" required>

                        <label for="TransmissionType" class="form-label">TransmissionType</label><br>
                        <input type="radio" name="Transmission_Type" id="TransmissionType" value=" <?php echo $row['Transmission_Type']; ?>" />
                        <label for="Automatic" class="form-label">Automatic</label><br>

                        <input type="radio" name="Transmission_Type" id="TransmissionType" value=" <?php echo $row['Transmission_Type']; ?>" />
                        <label for="Manual" class="form-label">Manual</label><br>

                        <input type="radio" name="Transmission_Type" id="TransmissionType" value=" <?php echo $row['Transmission_Type']; ?>" />
                        <label for="SemiAutomatic" class="form-label">Semi-Automatic</label><br>

                        <label for="NoofSeats" class="form-label">No. of Seats</label>
                        <input type="number" name="NoOfSeats" class="form-control" value="<?php echo $row['NoOfSeats']; ?>" maxlength=20 required>

                        <label for="Noofdoors" class="form-label">No. of doors</label>
                        <input type="number" name="NoOfDoors" class="form-control" maxlength=20 value="<?php echo $row['NoOfDoors']; ?>" required>

                        <label for="Fueltype" class="form-label">Fuel type</label>
                        <input type="text" name="Fuel_Type" class="form-control" maxlength=20 value=" <?php echo $row['Fuel_Type']; ?>" required>

                        <label for="Colour" class="form-label">Colour</label>
                        <input type="text" name="Colour" class="form-control" maxlength=20 value=" <?php echo $row['Colour']; ?>" required>

                        <label for="RegistrationNumber" class="form-label">Registration Number (use Dublin
                            registration) </label>
                        <input type="hidden" disabled="disabled" name="Registration_Number" class="form-control" maxlength=20 value=" <?php echo $row['Registration_Number']; ?>" required>

                        <label for="Dateoffirstregistration" class="form-label">Date of first registration</label>
                        <input type="date" name="DateOfRegestration" class="form-control" maxlength=20 value=" <?php echo $row['DateOfRegestration']; ?>" required>

                    </div>

                    
                    <button type="submit" name="search" class="btn btn-primary">Delete</button>

        </form>

            <?php
        }
        
        
    }
    else{
        echo "<h1> No records found </h1>";
        echo "<a href='index.php'>home</a>";
    }
   

?>

            </div>
            <div class="modal-footer">

                </form>
更改
1。表格

<input type="radio" name="Car" id="Toyota" value="<?=$row['make']; ?>" />
错误原因 如果没有显示单选按钮,则在获取$row['make']时,它很可能是一个“未定义变量”

另一件事,从中删除白色间距。因为这可能在使用MYSQL语句时起作用

<!-- From -->
value=" <?php echo $row['Registration_Number']; ?>"

<!-- To -->
value="<?=$row['Registration_Number']; ?>"

value=“”
value=“”

*速记单行回显/打印供参考,
没有
属性。您的单选元素有两个值属性,仅使用一个。我已删除该属性,但存在相同的问题?您确定要“硬删除”数据吗?是的,我希望删除它警告:您完全可以使用参数化准备语句,而不是手动生成查询。它们由或提供。永远不要相信任何形式的输入!即使您的查询仅由受信任的用户执行。
<input type="radio" name="Car" id="Toyota" <?=($row['make'] == 'Toyota' ? 'value="'.$row['make'].'" checked':NULL); ?> />

<!-- or better yet -->
<input type="radio" name="Car" id="Toyota" value="Toyota" <?=($row['make'] == 'Toyota' ? 'checked':NULL); ?> />
// Change
if($query_run) // << This only tell the script the sql statement run with no errors

// To
if(mysql_affected_rows()<=1) // << This confirms that one or more rows where changed by the sql statement
/* basic usage */
$var = 5;
$var_is_greater_than_two = ($var > 2 ? true : false); // returns true
<!-- From -->
value=" <?php echo $row['Registration_Number']; ?>"

<!-- To -->
value="<?=$row['Registration_Number']; ?>"