我想从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>
答案 0 :(得分:0)
请你完成你的while循环。 当你使用mysql_fetch_array时,这些值存储为索引数组而不是关联数组。我假设城市存储在数组的第0个索引中。请检查您的查询结果城市的位置。
while ($friendList = mysql_fetch_array($result))
{
$city=$friendlist[0];
}
答案 1 :(得分:0)
尝试这样的事情:
while($friendList = mysql_fetch_array($result)) {
echo $friendList['City'];
}
答案 2 :(得分:0)
希望这很好用
$result = mysql_query("SELECT id, name FROM mytable");
$friendList = mysql_fetch_array($result)
while ($result as $row )) {
$row['city'];
}
并且不要使用mysql *使用PDO