Jump to content

count problams.


redarrow

Recommended Posts

 

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']."' ";

Link to comment
Share on other sites

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>";

}

?>

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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)){

Link to comment
Share on other sites

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:       

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.