Jump to content

mikosiko

Members
  • Posts

    1,327
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by mikosiko

  1. pid != 0? in the tables descriptions that you posted before is not a pid field post the sentence that you tried
  2. modify it to a regular query imply only use GROUP BY if that not solve what you want... post examples of your data and the desired output
  3. group_concat(f_name seperator ', ') forums SEPERATOR ? ... http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html#function_group-concat Blue beat me
  4. correction... the select should be: SELECT a.ID, a.Title, b.Category, a.URL FROM Movies AS a JOIN Categories b ON a.Category = b.ID ORDER BY b.Category
  5. that is not what the OP want:
  6. the first thing you must do is fix your Movie Table This: should be: that mean that you must change your table definition and be sure that the field "category" have the same datatype/length that the corresponding in the table Categories and also that you define a FOREIGN KEY on that field. after that a SELECT like this will pull the data from both tables ordered by category SELECT a.ID, a.Title, b.Category, a.URL FROM Movies AS a JOIN Categories b ON a.ID = b.ID ORDER BY b.Category the rest is only write the logic to display the info in the way that you want (lot of examples here in the forum).
  7. genzedu... read my signature.... what do you want... the fish or learn how to fishing? .... part of be a programmer (and sometime the most important) is learn how to debug your own code... specially when you are getting help and clues from others... if you are not capable or you don't know how to do it... just say so and ask
  8. wow PFM,,, but that is fact no completely helpful... not a solution
  9. use UNION http://dev.mysql.com/doc/refman/5.1/en/union.html restriction:
  10. yup... I saw the PDO part later... see my previous post ^^^ modified
  11. DELETED ... just realize that you are using PDO... here is something: http://www.php.net/manual/en/pdostatement.bindparam.php one of the comments there: This works ($val by reference): <?php foreach ($params as $key => &$val) { $sth->bindParam($key, $val); } ?> This will fail ($val by value, because bindParam needs &$variable): <?php foreach ($params as $key => $val) { $sth->bindParam($key, $val); } ?>
  12. No really... doesn't make sense... doesn't "smell" good ... what are you trying to do exactly?... maybe the description of your 2 tables and a little explanation of your objectives will help you to get another point of view
  13. no tested in my side... but try foreach ($values as $key => $val) { $key = (int) $key + 1; $val = "'" . $val . "'"; .... } or using " instead of '
  14. did you "echo" $_fields and $_values what echo shows?
  15. this is one way to do it SELECT @rownum:=@rownum+1 AS rownum, a.* FROM <YOUR TABLE> AS a, (SELECT @rownum:=0); but... why you need to do this?
  16. same answer that was given to him here http://www.phpfreaks.com/forums/mysql-help/you-have-an-error-in-your-sql-syntax-321480/msg1514672/#msg1514672
  17. answer is here http://www.phpfreaks.com/forums/faqcode-snippet-repository/
  18. mikosiko

    sum

    the answer is in my previous answer Ah.. and I forgot to modify your original select which also has the SUM in the wrong position SELECT news_id, news, date, time, user_id, session_id, username, password, email, user_access FROM news INNER JOIN users USING (user_id), SUM(news_id) AS comments FROM news_comments GROUP BY news_id ORDER BY date to be valid should be SELECT news_id, news, date, time, user_id, session_id, username, password, email, user_access, SUM(news_id) AS comments FROM news INNER JOIN users USING (user_id) GROUP BY news_id ORDER BY date add the other join and replace the SUM for a COUNT(news_comments.news_id)
  19. mikosiko

    sum

    just to make you select valid...here SUM(news_id) AS comments FROM news_comments take out FROM news_comments but I don't think you are doing what you apparently want... seems to me that you want to count the records in the table news_comments.. in such case you select is incorrect... you need to join the table news_comments too, replace SUM by COUNT and identify the field upon you are counting on properly (news_id is in both tables, news and news_comments right?)
  20. the answer is... depend here is an old article about it but still very much covering the possibles scenarios (read the comments too..one of them in special give more insights to the topic) http://www.mysqlperformanceblog.com/2007/04/10/count-vs-countcol/
  21. @isedeasy To get better help - What is the EXPLAIN result for that sentence? - Post Tables structure and Index definitions... complement with number of rows in each table
  22. agree with Fenway and Muddy... post your code to get better help... just guessing.... to execute your Transaction are you using an Stored Procedure or Function?... something like: <?php $query = "CALL your_procedure()"; mysql_query($query); .... .... $query2 = "SELECT a,b,s .... "; mysql_query($query2); // The error could be triggered here depending on what you did // before this query with the results of the previous one ?> if is something like this what are you doing then the error is caused because you are no processing all the results produced by the SP (at least 2).
  23. you can use: isset() and/or empty() lot of examples around
×
×
  • 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.