0

我想从 mysql 检索值到 php 这是代码 我想从 mysql 检索值到 php 这是代码

   <?php
    include 'config.php'; 
$query = "SELECT * FROM dealerpostproperty  dp
LEFT JOIN property_type ON property_type.id = dp.property_Id LEFT JOIN registration ON registration.UserName = dp.UserName
WHERE dp.City = 'Navi Mumbai'
";
$result = mysql_query($query) or die ("Query failed");
//get the number of rows in our result so we can use it in a for loop
$numrows = (mysql_num_rows ($result));
// loop to create rows
if($numrows >= 1){
for ($r = 0; $r <= $numrows; $r++) {
// loop to create columns
while ($friendList = mysql_fetch_array($result))
 {     
 $_SESSION['PropertyId'] = $friendList['property_Id'];

//Create table

echo " <tr> <td class='td2'>";

echo '<a href=# alt=Image Tooltip rel=tooltip content="<div class=td2><div id=imagcon><img src=img/1.jpg class=tooltip-image/></div><div id=con>'.$friendList['BedRooms'].' bhk </div><div id=con>'.$friendList['property_type'].'</div><div id=con>Area:'.$friendList['CoveredArea'].'</div><div id=con> '.$friendList['Type_cust'].' :'.$friendList['FirstName'].' '.$friendList['LastName'].' </div> <div id=con> <a href=# > View All Details </a>   </div>
<br/>
  <div id=con> <a href=# >';

 echo " <img src='Dealer/images/email.png' style='width:15px;height:15px' />";  

 echo ' Contact Advertiser </a>  </div> </div>
 ">'.$friendList['Name_of_ProjOrSociety'].'</a>'.'<br>';

echo "
</td>
<td ></td>

</tr>

<tr>
<td>".$friendList['City']."  


</td>
<td>


</td>

</tr> ";
echo $friendList['dp.City'];
echo "fffff";

 }}
}

?>

我想从中检索价值

<td>".$friendList['City']."  


</td>

我试过这个但不工作怎么办??????我是php新手

???????????????????????????????????????

<td>".$friendList['dp.City']."  


    </td>
4

3 回答 3

0

你能完成你的while循环吗?当您使用 mysql_fetch_array 时,这些值存储为索引数组而不是关联数组。我假设城市存储在数组的第 0 个索引中。请检查您的查询结果,城市的位置是什么。

while ($friendList = mysql_fetch_array($result))

{

$city=$friendlist[0];

}

于 2013-10-23T11:10:43.353 回答
0

尝试这样的事情:

while($friendList = mysql_fetch_array($result)) {
   echo $friendList['City'];
}
于 2013-10-23T11:20:34.023 回答
0

希望这工作正常

$result = mysql_query("SELECT id, name FROM mytable"); 
$friendList = mysql_fetch_array($result)
while ($result as $row )) {
      $row['city'];
 }

并且不要使用 my_sql* 使用 PDO

于 2013-10-23T11:22:33.740 回答