0

最近 PHP を勉強し始めたので、dreamweaver で以下のクエリを作成しました。

enter code here
<?php

if (!function_exists("GetSQLValueString")) {

    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
    {
        if (PHP_VERSION < 6) {
            $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
        }

        $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

        switch ($theType) {
            case "text":
                $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
                break;
            case "long":
            case "int":
                $theValue = ($theValue != "") ? intval($theValue) : "NULL";
                break;
            case "double":
                $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
                break;
            case "date":
                $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
                break;
            case "defined":
                $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
                break;
        }
        return $theValue;
    }

}

mysql_select_db($database_PMS, $PMS);
$query_rs_home = "SELECT * FROM hotelinfo, hotelslider WHERE hotelinfo.hotelid=hotelslider.id";
$rs_home = mysql_query($query_rs_home, $PMS) or die(mysql_error());
$row_rs_home = mysql_fetch_assoc($rs_home);
$totalRows_rs_home = mysql_num_rows($rs_home);
?>

このコードを使用している場合、データベースの最初のレコードしか取得できません。私はそれ以上の記録を取得していません。

誰か助けてください。

4

2 に答える 2

1

使用する:

while($row_rs_home = mysql_fetch_assoc($rs_home)){
 //do something
}
于 2013-03-06T08:51:10.400 に答える
0
mysql_select_db($database_PMS, $PMS);
 $query_rs_home = "SELECT * FROM hotelinfo, hotelslider WHERE hotelinfo.hotelid=hotelslider.id";
 $rs_home = mysql_query($query_rs_home, $PMS) or die(mysql_error());

while($rows= mysql_fetch_array($rs_home)){
 echo $rows['field_name'];//this will print your db record
}
于 2013-03-06T08:57:13.537 に答える