-1

这个问题开始,现在我需要对输出进行样式设置,只是发现 php 不喜欢我放置标签的方式,我也尝试将其封装在"or.<?php $row['field'] ?>仍然不起作用。

    <table class="table table-hover">
<caption>List All Customers from Customer Table</caption>
<thead>
<tr>
<th>id</th>
<th>Inital</th>
<th>First Name</th>
<th>Last Name</th>
<th>Mobile</th>
<th>Landline</th>
<th>Email</th>
<th>Address</th>
<th>Post Code</th>
</tr>
 </thead>
<tbody>
<tr>
<?php
foreach ($rows as $row) { 
?>
 <td><?php $row['clientid']; ?></td>
 <td><?php $row['inital']; ?></td> 
 <td><?php $row['firstname']; ?></td>
 <td><?php $row['lastname']; ?></td>
 <td><?php $row['mobile']; ?></td>
 <td><?php $row['landline']; ?></td>
 <td><?php $row['email']; ?></td>
 <td><?php $row['address']; ?></td>
 <td><?php $row['postcode']; ?></td>
 <?php } ?>
</tr>
</tbody>
</table>

它不起作用,没有结果。:(拔毛!看了其他问题,但北向足够清晰。

4

2 回答 2

5

添加echo..

<td><?php echo $row['clientid']; ?></td>
<td><?php echo $row['inital']; ?></td> 
<td><?php echo $row['firstname']; ?></td>
<td><?php echo $row['lastname']; ?></td>
<td><?php echo $row['mobile']; ?></td>
<td><?php echo $row['landline']; ?></td>
<td><?php echo $row['email']; ?></td>
<td><?php echo $row['address']; ?></td>
<td><?php echo $row['postcode']; ?></td>
于 2013-02-17T00:18:18.837 回答
0

尝试从您的评论中编辑您的代码:可能您只是没有将值推送到 $rows 数组中。

<?php 
 $rows = array() ;
 $result = $dbc->query('SELECT * FROM customer');
 if ($result){
   while ($row = $query->fetch_assoc()){
    $rows[] = $row ; //Put your data in the array first. 
   }
 }
?>

<table>
<tbody> 
 <tr> 
<?php 
 foreach ($rows as $row) { ?> 
  <td><?php echo $row['clientid']; ?></td> 
  <td><?php echo $row['inital']; ?></td> 
  <td><?php echo $row['firstname']; ?></td> 
<?php } ?> 
 </tr> 
</tbody> 
</table>
于 2013-02-17T00:34:47.803 回答