redarrow Posted March 23, 2007 Share Posted March 23, 2007 what the problam is that i can not get the where clause to get the match becouse i can not find a way to add the user_blog_date and user-blog_id to the select statement afther the count or before. the quistion is how do you use the count with other matches to the database. if you look at my code your see it only counting blog_comments so how can i also get it to look at the other conditions from the where clause. $point_query2="select count(blog_comment) as comment from blog_comments where user_blog_id ='".$_SESSION['point_id']."' and user_blog_date='". $_SESSION['point_date']."' "; Quote Link to comment Share on other sites More sharing options...
btherl Posted March 23, 2007 Share Posted March 23, 2007 What do you want the output to look like? Quote Link to comment Share on other sites More sharing options...
redarrow Posted March 23, 2007 Author Share Posted March 23, 2007 have a quick look at this ok then your see what i am doing ok. i am trying in gd added code to count the current comments within a blog code ok so i need the code to count the number of comments under that blog get me? <?php $query="select * from blogs order by date_added DESC LIMIT $from, $max_results "; $result=mysql_query($query); while($rec=mysql_fetch_assoc($result)){ $_SESSION['point_id']=$rec['id']; $_SESSION['point_date']=$rec['date_added']; $point_query="select * from blogs where id='".$_SESSION['point_id']." ' and date_added='".$_SESSION['point_date']."' "; $point_result=mysql_query($point_query)or die(mysql_error()); while($p=mysql_fetch_assoc($point_result)){ $_SESSION['page_img1']=$p['page_views']; $point_query2="select count(blog_comment) as comment from blog_comments where user_blog_id ='".$_SESSION['point_id']."' and user_blog_date='". $_SESSION['point_date']."' "; echo $point_query2; $point_result2=mysql_query($point_query2)or die(mysql_error()); while($p2=mysql_fetch_assoc($point_result2)){ $_SESSION['page_img2']=$p2['comment']; echo"<table width='300' height='70' border='0' align='center'><td align='center'> <tr><td align='left'> <img height='70' width='60' src='comment_img.php'></img> </td> <td align='center'> <a href='new_blog.php'><font color='yellow'>Add A New Blog</font></a> </td> <td align='right'> <img height='70' width='60' src='blog_img.php'></img> </tr></td> </table>"; } ?> Quote Link to comment Share on other sites More sharing options...
btherl Posted March 23, 2007 Share Posted March 23, 2007 Looks fine to me. What does it display, and what do you want it to display instead of what it does? Quote Link to comment Share on other sites More sharing options...
redarrow Posted March 23, 2007 Author Share Posted March 23, 2007 i am doing stats with gd then the count print's a number on a pic now the firs one works grate. but i think i need to do a join then count within that join not sure yet lol. Quote Link to comment Share on other sites More sharing options...
btherl Posted March 23, 2007 Share Posted March 23, 2007 I noticed something strange in your code. You start by selecting all entries from the blogs table, within a certain range. Then for each row, you select exactly the same data again with your second query. You could simple take page_views from your first query. As for your last query, it looks perfectly fine to me. Maybe you can post your database structure, and also post a sample of what you want the query to return? Quote Link to comment Share on other sites More sharing options...
redarrow Posted March 23, 2007 Author Share Posted March 23, 2007 the first query is diffrent to the second here the new join ok. working on it. $query="select blogs.id,blogs.posted_by,blogs.date_added,blogs.title,blogs.blog, blog_comments.id,blog_comments.posted_by,blog_comments.date_added,blog_comments.title_comment, blog_comments.blog_comment,blog_comments.user_blog_title,blog_comments.user_blog_date,blog_comments.user_blog_id from blogs,blog_comments where blogs.title=blog_comments.user_blog_title "; $result=mysql_query($query)or die (mysql_error()); while($rec=mysql_fetch_assoc($result)){ Quote Link to comment Share on other sites More sharing options...
redarrow Posted March 23, 2007 Author Share Posted March 23, 2007 can some one give me an example of if you had a word in the database the same under the same database field how to count all the matches to the same word. Quote Link to comment Share on other sites More sharing options...
redarrow Posted March 23, 2007 Author Share Posted March 23, 2007 here the database i need to use some sort of php or mysql function to give the current matches of user_blog_title field. as you can see there are two matches (my name) id posted_by date_added title_comment blog_comment user_blog_title user_blog_date user_blog_id 00001 john 1174617900 well done well good all about me 1174617306 00001 00001 john 1174625672 good 1 m8 my name 1174625650 00001 00001 john 1174629404 hi how are you then m8 my name 1174625650 00001 Check All / Uncheck All With selected: Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.