0

例如

id - Name - Surname - Phone - Married
1 - Ann - AnnS - 123 - No
2 - Mary - MarryS - [empty] - Yes
3 - Jane - JaneS - 321 - [empty]

现在我想通过id记录并打印这样的信息(将行名称更改为 SMTH ELSE 并且如果行为空 - 根本不显示行):

SELECT * FROM `girls` WHERE `id`='1'

The girls name - Ann 
The girls surname - AnnS
The girls number - 123
Is the girl married? - No

//-/

SELECT * FROM `girls` WHERE `id`='2'

The girls name - Ann
The girls surname - AnnS
Is the girl married? - No

在不使服务器超载的情况下如何更容易做到(表中有大约 130 行)?

4

1 回答 1

1

一次全选

$sql = "select * from girls";

然后遍历 php 中的结果集

$result = mysql_query($mysql);

while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
    echo "The girls name - ".$row['name'].";
     //....
}
于 2012-10-28T23:53:48.387 回答