Jump to content

dannyluked

Members
  • Posts

    95
  • Joined

  • Last visited

    Never

Everything posted by dannyluked

  1. Thank you very much, this topic is finally nearly solved! Just one small problem!!! It now displays exactly how i want it too using: <?php include "config.php"; mysql_connect($server, $db_user, $db_pass) or die(mysql_error()); mysql_select_db($database) or die(mysql_error()); $result = mysql_query("SELECT blog.id, blog.title, count(blogcomments.blogid) AS CommentCount FROM blog LEFT OUTER JOIN blogcomments ON blog.id = blogcomments.blogid GROUP BY blogcomments.blogid") or die(mysql_error()); while($row = mysql_fetch_array( $result )) { echo $row["title"]." - ($row[CommentCount]) comment('s)<br>"; } ?> I just want to know how I limit the amount of outputs to 3 and order them by 'blog.id desc' Again thanks to 'whatsmyname' and 'kickstart'
  2. To start with I do have blogid now! and it allows duplicate entries so... Also the table called 'Comments' in my firt post is actually 'blogcomments' It gave this error: "Unknown column 'blogcomments.id' in 'field list'" For this code: <?php include "config.php"; mysql_connect($server, $db_user, $db_pass) or die(mysql_error()); mysql_select_db($database) or die(mysql_error()); $result = mysql_query("SELECT blog.id, blog.title, count(blogcomments.id) AS CommentCount FROM blog LEFT OUTER JOIN blogcomments ON blog.id = blogcomments.blogid GROUP BY blogcomments.blogid") or die(mysql_error()); while($row = mysql_fetch_array( $result )) { echo "$row"; } ?> So I changed the code to this (I changed the blogcomments.id to blogcomments.blogid): <?php include "config.php"; mysql_connect($server, $db_user, $db_pass) or die(mysql_error()); mysql_select_db($database) or die(mysql_error()); $result = mysql_query("SELECT blog.id, blog.title, count(blogcomments.blogid) AS CommentCount FROM blog LEFT OUTER JOIN blogcomments ON blog.id = blogcomments.blogid GROUP BY blogcomments.blogid") or die(mysql_error()); while($row = mysql_fetch_array( $result )) { echo "$row"; } ?> But it just said: "ArrayArrayArray"
  3. Thank you ever so much, I am just wondering how I apply this. What is the other code to display it. I get the error message: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/a1072392/public_html/b/home/content.php on line 25 I am using this code: <?php include "config.php"; mysql_connect($server, $db_user, $db_pass) or die(mysql_error()); mysql_select_db($database) or die(mysql_error()); $result = mysql_query("SELECT Blog.id, Blog.title, count(Comments.id) AS CommentCount FROM Blog LEFT OUTER JOIN Comments ON Blog.id = Comments.blogid GROUP BY Comments.blogid"); while($row = mysql_fetch_array( $result )) { echo "$row"; } ?> Is that the right code?! Thanks for all help so far
  4. Sorry for the slow reply! I want to show how many coments each blog has. Then on a seperate page those comments will be shown. Sort of like this forum shows how many replies each topic has. Thanks
  5. Thanks abazoskib, Ill read up more on it although I have already read about it and dosent seem to show what I want. Ill read again though! I read xtopolis comment and dont know if hes being sarcastic, hopefully not but I'm posting my question on this forum because I thought it was for help. I have learned basic MySQL myself so have never been taught the more complicated things. Hopefully someone else could help me further
  6. Hi, I have two tables; Blog id title 1 A 2 B 3 C Comments id title comment 1 A Blah, Blah, Blah... 2 A Blah, Blah, Blah... 3 B Blah, Blah, Blah... Then I want the output to be: A - (2) comment('s) B - (1) comment('s) C - (0) comment('s) If anyone knows how to do this could they please give me full php code (form <?php to ?>!). MySQL version 5.1 This would be a great help as I have no idea. Thank you in advance
  7. My knowledge of PHP is worse than yours, you have helped me a lot, thanks for your time!
  8. Could you please give me the full php code including the connect because when I do it, it shows the title that are in both tables where I want it to count them. So could you please give me the full code that will do this: Blogtitle A B C C Blog A B C D The output would be: A - 1 match(‘s) B - 1 match(‘s) C - 2 match(‘s) D - 0 match(‘s) Thank you very much
  9. I just changed the table names and got this: SELECT blogcomments.blogtitle, blogcomments.comment, COUNT(blog.title) FROM blog INNER JOIN blogcomments ON (blog.title=blogcomments.blogtitle) GROUP BY blogcomments.blogtitle but that just give printed "Resource id #10"!
  10. I have these tables: Blogcomments -blogtitle -comment Blog -title -date -other columns... I want a code that shows the ‘title’ column in the table ‘blog’ but also tells you how many rows contain the same title (column ‘blogtitle’) in the table ‘blogcomments’. For example if my tables looked like this Blogtitle A B C C Blog A B C D The output would be: A - 1 match(‘s) B - 1 match(‘s) C - 2 match(‘s) D - 0 match(‘s) MySQL version 5.1
  11. I think I need to join queries or something but i havent done that before. I dont get any errors just no results! I want to query the table 'blogcomments' but use a WHERE clause. But in the WHERE clause I want to query a table called 'blog'! But overall I want it to count the rows in 'blogcomments' that have a title form 'blog'
  12. oh yeah! That still isnt the problem though. That is actually just code i typed, not copied from my actual webpage!
  13. MySQL version = 5.1 Hi, I want to add a comments section to my homemade blog! Firstly I currently have a blog (that queries a database) on my site homepage. The initial blog links to another page that then shows the full blog (links to mysite.com/view_blog?id=(Query ID)). I now want users to be able to post comments under the full blog and on the initial page to show how many comments there are. The idea I am currently trying is that I have created a table called 'blogcomments'. In that table the blog title that you are commenting on is added and the comment. I want the initial blog to do the following: Query the normal blog things (title, date, writing, links...) but also count the number of comments for that particular blog title. I so far have: <?php include "config.php"; mysql_connect($server, $db_user, $db_pass) or die (mysql_error()); $result = mysql_db_query($database, "select * from $table order by id desc LIMIT 3") or die (mysql_error()); while ($qry = mysql_fetch_array($result)) { echo "<div id='title'>$qry[title]</div><div id='date'>$qry[date]</div><dive id='comments'>I WANT TO DISPLAY NUMBER OF COMMENTS HERE</div> "; } ?> Idearly I would have $count = mysql_db_query($database, "SELECT * FROM blogcomments where blogtitle = '$qry[title}'") or die (mysql_error()); $num_rows = mysql_num_rows($count); but this dosent work! So my question is, How do I query the number of comments that have the title $qry[title] baring in mind the comments are in another table. Sorry if it is hard to understand.
  14. Thank you very much!! This works. I have resolved with the method of using inc/img/image.gif instead of the full URL as the site host is only tempory and it saves me a lot of work! Sadly I still cant link to includes from other directories. I think I worded it wrong in my other post. I want to include mysite.com/members/index.php into mysite.com/inc/left.php. what is the code for this. Also when I do this the images dont show again, but they do show in mysite.com/index.php! PS. it wont let me use full URL's to include files!
  15. Hi, I am trying to include my header, footer, left and right in all my pages. These are all php documents and when I navigate to there URL (mysite.com/inc/left.php) they look fine. However, when they are included in mysite.com/index.php using the code: <?php include "inc/left.php" ?> they dont show any of the images. The images for the includes are in mysite.com/inc/img. I also must add that they are linked to the include files as img/header.png, not mysite.com/inc/img/header.png. Does this matter? So, my overall questions are; 1. Why are my images not being displayed in index.php but are in mysite.com/inc/left.php? 2. Does having images in my css as img/header.png and not mysite.com/inc/img/header.png matter? 3. How do I link to the includes from the higher directories like mysite.com/example/index.php? Thank you very much in advance!
  16. OK, I dont understand what some of the posts mean, I am a beginner so I will paste the code and could you please rewrite the code to back up your suggestion: <?php include "config2.php"; mysql_connect($server, $db_user, $db_pass) or die (mysql_error()); $result = mysql_db_query($database, "select * from $table WHERE id = '".$_GET['id']."'") or die (mysql_error()); while ($qry = mysql_fetch_array($result)) { echo "<div class='blog' id='blogcontent'> <div class='Blogcontent' id='title2'><span class='title'>$qry[title]<span class='date'> - $qry[date]</span></span></div> <div id='divLeft'><a href='$qry[image]'><img src='$qry[image]' width='100' height='100' border='0' /></a></div> <div id='main'><span id='main'>$qry[writing]<a href='http://dannyluked.comze.com/template2.php?id=$qry[id]'>[more]</a></span></div> <div id='link'><span class='style51'>Link:</span> <a href='$qry[link]' class='linker' target='_blank'>$qry[link]</a><br /> </div></div>"; } ?>
  17. I cant because then it will still display them just like a normal blog not a 'Recent' blog!
  18. Hi, I have just made a blogging system for my site and would like it to work like another site (http://www.wiganwarriors.com/). These are my questions: 1. How do I limit the number of characters from a query so when It show the main writing in the blog it only shows 100 characters and after links to the rest of the writing? This is what I have so far (by the way this is in a div with queries before and after); $qry[writing]<a href='http://MYSITEHERE/blogtemplate.php?id=$qry[id]'>[more]</a> 2. How do I made the most recent blog show up big (like in the website above) and the next 3 most recent smaller and so on? Any good answers would be greatly appreciated!
  19. Does anyone have an idea how I can made a line of php code to go at the top of a page. I want this so that when the page is viewed it checks if the $username = Admin. If not the guest See's a message, If it is admin other information is shown. Thanks in advance,
×
×
  • 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.