我的型号代码
function wife($a){
$sql="select person.person_id,person.new_surname,person.fname,person.father_name,person.village,marriage.wife_id from person left join marriage on person.person_id=marriage.wife_id where marriage.husband_id='$a'";
$query=$this->db->query($sql);
return $query->result();
}
我的观看代码
<?php
foreach($result as $row){
echo "first".$row->fname;
echo $row->father_name
echo $row->new_surname;
echo $row->village;
?>
第一行我要显示在上面,第二行我想显示以下
<?php
foreach($result as $row){
echo "Second".$row->fname;
echo $row->father_name
echo $row->new_surname;
echo $row->village;
?>
答案 0 :(得分:0)
<?php
$i = 0;
foreach($result as $row){
if ($i == 0) {
echo "first" . $row->fname;
} else if ($i == 1) {
echo "Second" . $row->fname;
} else {
// Do this for third etc. rows
}
echo $row->father_name
echo $row->new_surname;
echo $row->village;
$i++;
}
?>
答案 1 :(得分:0)
您可以使用任何函数将变量i转换为字符串,该函数可以在没有硬编码字符串的情况下使用,并且可以用于n个数字