mysqli无法显示完整数据

时间:2017-12-09 08:27:52

标签: php mysql mysqli display

我有一个名为testads的表,数据如下

Link to table image

我想创建一个更新页面,其中按行选择数据。我没有更新数据的问题,但是当数据显示在更新页面中而不是公司名称 Subway Malaysia 时,它只显示 Subway 。所有包含多个单词的数据都会发生这种情况。我似乎无法找到问题所在

以下是php代码:

<?php
    include('./include/connection.php');

    $ID=$_GET['no'];

    $query = "SELECT no, id_company, company_name, jobName,state, location, jobDesc, contact FROM testads where no='$ID'";

    $result = mysqli_query($link, $query) or die ("error.");

    while ($row = mysqli_fetch_array($result)){
    $id=$row['no'];
?>

<form class="form-horizontal form-label-left" method="post" action="edit_query.php<?php echo '?no='.$id; ?>">
     <div class="form-group">
         <label class="control-label col-md-3 col-sm-3 col-xs-12" for="comp-name">Company Name <span class="required"></span>
         </label>
         <div class="col-md-6 col-sm-6 col-xs-12">
              <input type="text" id="comp-name" required="required" name="cname" class="form-control col-md-7 col-xs-12" value=<?php echo $row['company_name']; ?>>
        </div>
     </div>

     <div class="form-group">
         <label class="control-label col-md-3 col-sm-3 col-xs-12" for="comp-id">Company ID <span class="required"></span>
         </label>
         <div class="col-md-6 col-sm-6 col-xs-12">
              <input type="text" id="comp-id" required="required" name="cid" class="form-control col-md-7 col-xs-12" value=<?php echo $row['id_company']; ?>>
         </div>
      </div>

      <div class="form-group">
          <label class="control-label col-md-3 col-sm-3 col-xs-12" for="job-name">Job Name <span class="required"></span>
          </label>
          <div class="col-md-6 col-sm-6 col-xs-12">
                <input type="text" id="job-name" required="required" name="jname" class="form-control col-md-7 col-xs-12" value=<?php echo $row['jobName']; ?>>
          </div>
       </div>

      <div class="form-group">
           <label class="control-label col-md-3 col-sm-3 col-xs-12" for="desc">Job Description<span class="required"></span>
           </label>
           <div class="col-md-6 col-sm-6 col-xs-12">
                <textarea id="desc" name="description" class="form-control" maxlength="2000" value=<?php echo $row['jobDesc']; ?>></textarea>
            </div>
       </div>

       <div class="form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="stt">State</label>
            <div class="col-md-6 col-sm-6 col-xs-12">
                 <select name="state" class="form-control">
                        <option value="Johor"<?php echo $row['state'] == 'Johor' ? 'selected="selected"' : '' ; ?>>Johor</option>
                        <option value="Malacca"<?php echo $row['state'] == 'Malacca' ? 'selected="selected"' : '' ; ?>>Malacca</option>
                        <option value="Pahang"<?php echo $row['state'] == 'Pahang' ? 'selected="selected"' : '' ; ?>>Pahang</option>
                        <option value="Selangor"<?php echo $row['state'] == 'Selangor' ? 'selected="selected"' : '' ; ?>>Selangor</option>
                   </select>
              </div>
       </div>

       <div class="form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="loc">Location<span class="required"></span>
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
                 <input type="text" id="loc" required="required" name="location" class="form-control col-md-7 col-xs-12" value=<?php echo $row['location']; ?>>
             </div>
        </div>

        <div class="form-group">
             <label class="control-label col-md-3 col-sm-3 col-xs-12" for="ctc">Contact<span class="required"></span>
             </label>
             <div class="col-md-6 col-sm-6 col-xs-12">
                  <input type="text" id="ctc" required="required" name="contact" class="form-control col-md-7 col-xs-12" value=<?php echo $row['contact']; ?>>
             </div>
        </div>

        <div class="form-group">
             <div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3">
                  <button class="btn btn-success" type="submit" name="submit">Update</button>
             </div>
        </div>

 </form>

1 个答案:

答案 0 :(得分:2)

您需要引用您的值:

<input ... value="<?php echo $row['company_name']; ?>">