HTML标记在PHP中的echo标记中不起作用

时间:2016-05-24 10:41:49

标签: php html

这是我的带有html文本框的PHP代码

<input type="text"  class="form-control" value="<?php  
   $items=mysql_query("select * from order_detail_master where order_id = ".$no_of_orders['order_id']);
   echo "<table><tr><th>Item Name</th><th>Qty</th></tr>";
     if($items){
         while($res_items = mysql_fetch_assoc($items)){

             $item_name = mysql_query("select item_name from item_master where item_id = ".$res_items['item_id']);
             while($item_name_rs = mysql_fetch_assoc($item_name)){
                 $i_n = $item_name_rs['item_name'];
              }
             echo "<tr><td>".$i_n."</td><td>".$res_items['odm_quantity']."</td></tr>";
        }
}

echo“”;

我的输出看起来像  enter image description here

1 个答案:

答案 0 :(得分:0)

我不确定你要做的是什么,但我认为当它实际上不是一个表格时没有理由有一个html输入类型。如果您正在尝试查询数据库,我会将这个简单的脚本放在一起,这可能有助于指导您按照您尝试实现的目标进行操作。您可以在mysql查询行中使用*作为通配符来帮助简化操作。另外,确保$ link与db_connect匹配。我没有测试过,但它应该可以正常工作。

<?php                              
$sql=mysqli_query($link, "select * FROM order_detail_master") or die(mysqli_error($link));
  ?>
    <tr>
      <th>Order ID</th>
      <th>Item ID</th>
      <th>Item Name</th>
      <th>ODM Quantity</th>    
    </tr>
<?php      
    while($row=mysqli_fetch_assoc($sql))
    {     
  ?> 
   <tr>
    <td><?php echo $row['order_id'];?></td>
    <td><?php echo $row['item_id'];?></td>
    <td><?php echo $row['item_name'];?></td>
    <td><?php echo $row['odm_quantity'];?></td>
    </tr>
  <?php 
    } 
  ?> 
相关问题