Jump to content

struggling with Sql query - php


gabrielkolbe

Recommended Posts

Hi, i would appreciate if someone can just have a look at this and tell me where, I am going wrong.....I am trying to get a prop_ID from a table called right_prop_1, then use this ID to query a 'stats' table. The combine the info from both tables in rows that gets echoed out.

Here is the code:

thanks in advance.............

[code]$query = "SELECT * FROM right_prop_1 WHERE user_id = '".$_SESSION['index']."'";
$result = mysql_query($query) or die(mysql_error());
if (mysql_num_rows($result) == 0) {
?>
        <tr bordercolor="#FFFFFF">
        <td class="menu_names" bgcolor= "<?=$row_color?>" colspan=5 >&nbsp;You have no visited Properties at this time</td>
        </tr>
<? } else {

$propid = $row->prop_ID;
$type = $row->type;
$suburb = $row->suburb;
$price1=$row->price;
$price = number_format($price1);



$query = "SELECT * FROM stats  WHERE propid = '".$prop_ID."' order by propid asc limit ".$page.", 30";
$result = mysql_query($query) or die(mysql_error());
while ($row = mysql_fetch_object($result)) {
$visited=mysql_num_rows($result);

$row_color = ($row_count % 2) ? $color1 : $color2;
    ?>
    <tr bgstyle="color:#FFFFFF">
    <td width="20%" bgcolor= "<?=$row_color?>" class="menu_names">&nbsp;Refno:&nbsp;<span class="blacktahoma"><?=$prop_ID?></span></td>
    <td width="10%" bgcolor= "<?=$row_color?>" class="menu_names"><?=$type?></td>
    <td width="16%" bgcolor= "<?=$row_color?>" class="blacktahoma">R<?=$price?></td>
    <td width="20%" bgcolor= "<?=$row_color?>" class="menu_names"><?=$suburb?></td>
    <td width="17%" align="left" bgcolor= "<?=$row_color?>" class="menu_names">Viewed &nbsp;&nbsp;<?=$visited?></td>
    <td width="17%" bgcolor= "<?=$row_color?>" class="menu_names"><div align="right"><a href="index.php?action=detailstats&prop_ID=<?=$row->prop_ID?>">View details</a></div></td>
    </tr>
<? $row_count++; } } ?>
</table>[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.