简体   繁体   English

Select * 不显示来自 Mysql 的记录

[英]Select * is not showing records from Mysql

I have written a query.我写了一个查询。 It is not showing records from Mysql.它没有显示来自 Mysql 的记录。 I am trying to call data from Mysql so i can update it.我正在尝试从 Mysql 调用数据,以便我可以更新它。 But it is not fetching the data.但它没有获取数据。 Same code is working on other form and there Title is not showing too.相同的代码正在处理其他形式,并且标题也没有显示。 Don't know whats wrong, but i have tried all things to show.不知道出了什么问题,但我已经尝试了所有的东西来显示。 Even tried to call the database connection file directly but still no success.甚至尝试直接调用数据库连接文件,但仍然没有成功。

My PHP code我的 PHP 代码

    <?php
if(isset($_GET['Competition_ID'])){

   $SelectAllPackages = mysqli_query($con, "SELECT * FROM competitions WHERE id='".$_GET['Competition_ID']."'");
   while($row=mysqli_fetch_assoc($SelectAllPackages)){

    $competition_title      = $_POST['competition_title'];
    $vimeo_url              = $_POST['vimeo_url'];
    $start_date             = $_POST['start_date'];
    $end_date               = $_POST['end_date'];
    $tickets                = $_POST['tickets'];
    $ticket_price           = $_POST['ticket_price'];
    $status                 = $_POST['status'];
   }
}

if(isset($_POST['update_competition'])){


    $up_competition_title   = $_POST['competition_title'];
    $up_vimeo_url           = $_POST['vimeo_url'];
    $up_start_date          = $_POST['start_date'];
    $up_end_date            = $_POST['end_date'];
    $up_tickets             = $_POST['tickets'];
    $up_ticket_price        = $_POST['ticket_price'];
    $up_competition_status  = $_POST['status'];

    $insertQuery = mysqli_query($con,"UPDATE competitions SET

    title                   = '$up_competition_title',
    vimeo_url               = '$up_vimeo_url',
    start_date              = '$up_start_date',
    end_date                = '$up_end_date',
    tickets                 = '$up_tickets',
    ticket_price            = '$up_ticket_price',
    status                  = '$up_competition_status'

    WHERE id='".$_GET['Competition_ID']."'
     "); 

    if($insertQuery){
        echo '<script>window.location.href = "all_competitions.php";</script>';
        }       
}


?>

My HTML code is here我的 HTML 代码在这里

<div class="col-md-6">
                                            <div class="form-group">
                                                <label class="control-label">Competition Title</label>
                                                <input type="text" id="firstName" name="competition_title" class="form-control" value="<?php echo $title; ?>">
                                                </div>
                                        </div>

Why don't you use你为什么不使用

if (isset($_POST['Competition_ID'])) {
  $id = mysqli_real_escape_string($conn, $_POST['Competition_ID']);
{
 if (empty($id)) {
    array_push($errors, "ID is required");
  }
if (count($errors) == 0) {
    $query = "SELECT * FROM competition WHERE Competition_ID='$id'";
    $results = mysqli_query($conn, $query);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM