2013-03-06 5 views
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); 
?> 

이 코드를 사용하는 경우 데이터베이스의 첫 번째 레코드 만 표시됩니다. 나는 더 이상의 기록을 얻지 못하고있다.

제발 도와주세요.

+0

내가 hotelid으로 'FIELD_NAME'를 사용할 수 있습니다 $ row_rs_home – acutesoftware

답변

1

사용 :

while($row_rs_home = mysql_fetch_assoc($rs_home)){ 
//do something 
} 
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 
} 
+0

의 위해서 var_dump를합니까? –

관련 문제