gabrielkolbe Posted March 14, 2006 Share Posted March 14, 2006 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 > 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"> Refno: <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 <?=$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 https://forums.phpfreaks.com/topic/4954-struggling-with-sql-query-php/ Share on other sites More sharing options...
Barand Posted March 14, 2006 Share Posted March 14, 2006 As I don't have your db to run the script, what is it doing that it shouldn't?. Alternatively, what is not doing that it should? Link to comment https://forums.phpfreaks.com/topic/4954-struggling-with-sql-query-php/#findComment-17502 Share on other sites More sharing options...
keeB Posted March 14, 2006 Share Posted March 14, 2006 [code] SELECT * FROM right_prop_1 rp1INNER JOIN stats s on s.propID = rp1.propIDWHERE rp1.user_id = '".$_SESSION['index']."'[/code]1 SQL Statement.. all fields joined.. just for you! [= Link to comment https://forums.phpfreaks.com/topic/4954-struggling-with-sql-query-php/#findComment-17505 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.