是否有可能在PHP中不使用while循环获取所有数据?


Is it possible to fetch all data without using while loop in PHP

我这里有一个大表包含特定数据的所有信息,我试图回显所有的信息,但不使用while loop是可能的吗?

下面是我要做的:

这是我的查询:

$query = "SELECT * FROM `info` WHERE `id` = ?";
$stmt = mysqli_prepare($conn, $query);
mysqli_stmt_bind_param($stmt, 's', $_GET['id']);
mysqli_stmt_execute($stmt);
mysqli_stmt_bind_result($stmt, $id, $full_name, $phone_number, $crew_rank,$date_of_birth,$age,$telephone_number,$vessel,$place_of_birth,$religion,$joining_date,$citizenship,$civil_status,$sss_number,$joining_port,$shoe_size,$boiler_size,$ht,$wt,$last_vessel,$address,$depedent1_fullname,$depedent2_fullname,$depedent3_fullname,$dependent1_address,$dependent2_address,$dependent3_address,$dependent1_telnumber,$dependent2_telnumber,$dependent3_telnumber,$dependent1_relationship,$dependent2_relationship,$dependent3_relationship,$dependent1_dob,$dependent1_place_of_birth,$dependent2_dob,$dependent3_dob,$passport_number,$passport_date_issued,$passport_date_expiry,$sirb_number,$sirb_date_issued,$sirb_date_expiry,$src_number,$src_position,$src_date_issued,$yellow_fever_number,$yellow_fever_date_issued,$yellow_fever_date_expiry,$us_visa_number,$us_visa_type,$us_visa_date_issued,$us_visa_date_expiry,$australia_number,$australia_type,$australia_date_issued,$australian_date_expiry,$mar_license_position,$mar_license_number,$mar_license_date_issued);

,这就是我试图对表做的:

<table border="1" style="table-layout: fixed;" align="center">
  <caption class="center">PERSONAL</caption>
  <tr>
    <th align="left">NAME: </th>
    <td colspan="3"><input type="text" name="full_name" value="<?php echo $full_name; ?>" size="37"></td>
    <th colspan="1" align="left">MOBILE: </th>
    <td><input type="text" name="phone_number" value="<?php echo $phone_number; ?>" size="11"></td>
    <th align="left">RANK: </th>
    <td><input type="text" name="crew_rank" value="<?php echo $crew_rank; ?>" size="10"></td>
  </tr>

NOTICE:注意每个表行

中的值

谢谢

不要害怕使用循环。你可以打开PHP标签,写下你的代码,关闭它们,写HTML,再写很多次。

看看这个简单的例子:

<?php while ($row = mysqli_fetch_assoc($result)) { ?>
    <input type="text" name="full_name" value="<?php echo $result['full_name']; ?>" size="37">
<?php } ?>