Jump to content

dachshund

Members
  • Posts

    312
  • Joined

  • Last visited

Everything posted by dachshund

  1. Hi Vinny, Sorry if I was initially unclear about what I was trying to achieve, the rough code below is what I'm trying to make work $sql = mysql_query("SELECT DISTINCT tag_one + tag_two + tag_three FROM table ORDER BY (number of occurrences) DESC"); while($rows=mysql_fetch_array($sql)){ echo $rows['tag_one + tag_two + tag_three]; }
  2. does anyone know if the above is possible, and how you would group together the columns to echo out as one?
  3. basically Im trying to work out how to make something like this work $sql = mysql_query("SELECT DISTINCT tag_one + tag_two + tag_three FROM table ORDER BY (number of occurrences) DESC");
  4. thanks. i'm assuming this is the wrong way to echo out the results? $sql = "SELECT tag, COUNT(*) AS number_occurences FROM (SELECT tag_one AS tag FROM content UNION ALL SELECT tag_two FROM content UNION ALL SELECT tag_three FROM content) AS merged_tags GROUP BY tag ORDER BY COUNT(*) DESC"; $result=mysql_query($sql); while($rows=mysql_fetch_array($result)){ }
  5. apologies, i don't think i explained myself too well to begin with. for each article, 'tag1' can be defined as any word you wish, such as "amazon" or anything else. this is the same as tag2 and tag3, you can enter any tag you like. I realise this would normally be done with one comma delimited column, but it was set up like this a while ago and works fine for the time being as we generally don't need more than 3 tags per article. basically what I want to do is find out what words have been used most as a tag. so the query would simply list popular tag words in order of how many times they have been used. i would like the end echo to be something like the below amazon - 26 times antarctica - 22 times london - 4 times new york - 2 times the problem is "amazon" could have been entered as tag1 on one article, and tag3 on another article, so I need to search and could all three columns as one. hope that makes a little more sense and thanks for your help so far!
  6. Hi, I have three tag columns in my mysql database - tag1, tag2, and tag3. Is it possible to count how many times tag words appear in tag1, tag2, and tag3 combined and then list in order of how many times they appear? Thanks
  7. it appears the links are being sent out to people as messages on facebook via. hacked accounts. has anyone heard of this happening before?
  8. or how I can just echo 'invalid request' if they go to an address like that?
  9. any ideas?
  10. Hi all, I seem to be coming under some sort of hacker attack by which hundreds of "visitors" go to the index.php page followed by a code which is a number then an equals sign then another number, for example "?1o4t95spb5=8abd1befd07bd4" Does anyone know what this is and how it can be stopped? Thanks
  11. Hi, I'm having trouble with my $_GET command picking up spaces within the URL, for example if it says index.php?brand=carhartt that works fine, but if it says index.php?brand=Happy%20Socks it can't recognise there is a space. Any help? Thanks
  12. worked it out, it's $pos = strpos($comment, 'http://'); if ($pos !== false) { $pos = '1'; } if (strlen($comment) != strlen(strip_tags($comment)) OR $name == '1' OR $comment == '1' OR $pos == '1'){
  13. Sorry, here: $pos = strpos($comment, 'http://'); if ($pos === true) { $pos = '1'; } if (strlen($comment) != strlen(strip_tags($comment)) OR $name == '1' OR $comment == '1' OR $pos == '1'){
  14. Ok, so I tried this, but it doesn't seem to be working. Can anyone see where I've gone wrong. Thanks for your help. if ($pos === true) { $pos = '1'; } if (strlen($comment) != strlen(strip_tags($comment)) OR $name == '1' OR $comment == '1' OR $pos == '1'){ echo 'comment failed'; }
  15. Hi, I have a comment form which currently makes sure people do not post any html with the below code: <?php if(strlen($comment) != strlen(strip_tags($comment)) OR $name == '1' OR $comment == '1'){ ?> I am still getting a lot of spam that contains a web address such as http://www.viagra.com. To stop these comments going through, I want to check to see if a web address has been included in the $comment, and if so, not allow it. Can anyone help? Thanks
  16. Hi, I have the following code but I want to skip the very first result (or row) as I already have that echoed in a different format above. $sql = "SELECT * FROM content WHERE `live` LIKE '0' AND `date` >= SUBDATE(CURRENT_DATE, 1) ORDER BY `views` DESC LIMIT 40"; $result=mysql_query($sql); while($rows=mysql_fetch_array($result)){ Thanks
  17. Hi, I'm trying to find all the MySQL entries from the last 24 hours. So far I have this. I just don't know how to take 1 day off the current time. $lastday = date('Y-m-d h:i:s'); $sql = "SELECT * FROM content WHERE `live` LIKE '0' AND `date` >= '$lastday' ORDER BY date DESC LIMIT 40"; $result=mysql_query($sql); while($rows=mysql_fetch_array($result)){ Thanks in advance, Jack
  18. worked it out it is : $query = mysql_query("SELECT MAX(`id`) AS `id` FROM `comments` WHERE `replyto` LIKE '$commentid' AND `moderate` LIKE '0' ORDER BY id ASC");
  19. here we go: <?php $commentsql="SELECT * FROM comments WHERE articleid LIKE $id AND moderate LIKE 0 AND replyto LIKE 0 ORDER BY id ASC"; $commentresult=mysql_query($commentsql) or die (mysql_error()); while($commentrows=mysql_fetch_array($commentresult)){ $date = date('d F y', strtotime($commentrows['datetime'])); $sql="SELECT * FROM content WHERE id='$id'"; $result = mysql_query($sql) or die (mysql_error()); $rows=mysql_fetch_array($result); $articleid=$rows['id']; $replyto = $commentrows['id']; if (strlen($http) > 3) { $http = substr($http, 0, 7); } ?> <script type="text/javascript"> $(function(){ $('#<?php echo $commentrows['id']; ?>').click(function(){ $("#randomdiv<?php echo $commentrows['id']; ?>").load('http://www.website.co.uk/reply_comment.php', {'id' : '<?php echo $commentrows['id'];?>'}) }); }); $(function(){ $('#reply<?php echo $commentrows['id']; ?>').click(function(){ $("#randomdiv<?php echo $commentrows['id']; ?>").load('http://www.website.co.uk/reply_comment.php', {'id' : '<?php echo $commentrows['id'];?>'}) }); }); </script> <div id="posted_comments"> <ul> <li class="comment_text"> <? echo $commentrows['comment']; ?> </li> <li class="username"> <?php echo $commentrows['name']; ?> <span class="comment_date"> <?php echo 'Posted '; $dateNew = strtotime($commentrows['datetime']); if (timePassed($dateNew) == '') { echo 'just now'; }else { echo timePassed($dateNew); } if (timePassed($dateNew) == 'yesterday' OR timePassed($dateNew) == '') { }else { echo ' ago'; } echo ' '; ?> </span> <span class="comment_reply"> <a id="<?php echo $commentrows['id']; ?>" /> Reply </a> </span> <div class="clear"></div> </li> </ul> </div> <?php $commentid = $commentrows['id']; $replycommentsql="SELECT * FROM comments WHERE replyto LIKE $commentid AND moderate LIKE 0 ORDER BY id ASC"; $replycommentresult=mysql_query($replycommentsql) or die (mysql_error()); while($replycommentrows=mysql_fetch_array($replycommentresult)){ ?> <div id="reply_comments_wrap"> <div id="posted_reply_comments"> <ul> <li class="comment_text"> <? echo $replycommentrows['comment']; ?> </li> <li class="username"> <?php echo $replycommentrows['name']; ?> <span class="comment_date"> <?php echo 'Posted '; $dateNew = strtotime($replycommentrows['datetime']); if (timePassed($dateNew) == '') { echo 'just now'; }else { echo timePassed($dateNew); } if (timePassed($dateNew) == 'yesterday' OR timePassed($dateNew) == '') { }else { echo ' ago'; } echo ' '; ?> </span> <?php $query = mysql_query("SELECT MAX[`id`] FROM `comments` WHERE `replyto` LIKE '$commentid' AND `moderate` LIKE '0' ORDER BY id ASC"); $maxRow = mysql_fetch_array($query); $max = $maxRow['id']; if($replycommentrows['id'] == $max) { ?> <span class="comment_reply"> <a id="reply<?php echo $commentrows['id']; ?>" /> Reply </a> </span> <?php } ?> <div class="clear"></div> </li> </ul> </div> <div class="clear"></div> </div> <?php } ?> <div id="randomdiv<?php echo $commentrows['id']; ?>"></div> <?php } mysql_close(); ?> <script type="text/javascript"> function validateForm() { var x=document.forms["comment"]["n"].value if (x==null || x=="" || x=="Your name...") { $('#comment_wrap').prepend($('<div class="comment_wrong">Please fill in all fields.</div>').fadeIn('slow').delay(1000).fadeOut('slow')); return false; } $('#comment_wrap').prepend($('<div class="comment_answer">Thank you! Your comment will be approved shortly.</div>').fadeIn('slow').delay(1000).fadeOut('slow')); $('#comment_container input[type=text]').attr('value', 'Your name...'); $('#comment_container textarea').attr('value', 'Your comment...'); } // wait for the DOM to be loaded $(document).ready(function() { // bind 'commenter' and provide a simple callback function $('#commenter').ajaxForm( { beforeSubmit: validateForm } ); }); </script> <div id="comment_wrap"> <div id="comment_container"> <ul> <form name="comment" method="post" id="commenter" action="http://www.website.co.uk/comment_posted.php?id=<?php echo $id; ?>"> <li> <input type="text" placeholder="Your name..." class="text_name_email" name="n"> </li> <li> <textarea class="text_area" name="c" placeholder="Your thoughts..."></textarea> </li> <li> <input type="submit" value="Post" class="post_comment"> </li> </form> </li> </ul> </div> </div>
  20. well, it's able to find that there is one matching query. it's just not realising that it's the maximum id in the query. the only other parts of the code that are relevant are '$commentid' and $commentrows['id'], both of which work and echo out perfecty. thanks
  21. thanks psycho, that's useful. i tried that code and it said "the above record matches one record", but still wouldn't echo the reply button.
  22. thanks jesirose. i tried those things but it has made no difference. when i echo out $max it is blank.
  23. the maximum id is not being selected
  24. hi, i'm trying to select the highest id in an array, so that if it's the highest one a reply button is displayed. my code so far is <?php $query = mysql_query("SELECT MAX(`id`) FROM `comments` WHERE `replyto` LIKE '$commentid' AND `moderate` LIKE '0'"); $maxRow= mysql_fetch_array($query); $max = $maxRow['id']; if($id == $max) { ?> <span class="comment_reply"> <a id="<?php echo $commentrows['id']; ?>" /> Reply </a> </span> <?php } ?> any help would be great!
  25. never mind! sorry for un PHP related material
×
×
  • 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.