Jump to content

Barand

Moderators
  • Posts

    24,563
  • Joined

  • Last visited

  • Days Won

    822

Everything posted by Barand

  1. I'd go with something like this below. Players can change clubs so hold the start and end dates that they are at the club. (The end date for player at current club would be 9999-12-31)
  2. @Psycho, Worked for me mysql> SELECT * FROM domain; +----+-------------------+ | id | domain_name | +----+-------------------+ | 1 | hello-world.co.uk | | 2 | hello.co.uk | | 3 | hello-zulu.co.uk | +----+-------------------+ mysql> SELECT * FROM domain -> ORDER BY SUBSTRING_INDEX(domain_name, '.', 1); +----+-------------------+ | id | domain_name | +----+-------------------+ | 2 | hello.co.uk | | 1 | hello-world.co.uk | | 3 | hello-zulu.co.uk | +----+-------------------+
  3. try SELECT domains_url ... ORDER BY SUBSTRING_INDEX(domains_url,'.',1)
  4. I find the easiest way is <table> <?php while ($row = mysql_fetch_row($result)) { echo "<tr><td>" . join('</td><td>',$row) . "</td></tr>\n"; } ?> </table>
  5. checkdate() $doby = '2014'; $dobm = '02'; $dobd = '29'; if (checkdate($dobm,$dobd,$doby)) { echo "Date OK"; } else { echo "Date error"; }
  6. $years = range($startYear, $startYear+4); if(!in_array($curYear, $validYears)){
  7. Then where I used "tablefield", use "channel" in the query
  8. After re-reading your post title I am thinking you may want something like this instead, to search for text within the field SELECT tablefield , COUNT(*) as total FROM asterisk_cdr WHERE tablefield LIKE '%given string%' GROUP BY tablefield This should show you how to use it in a PHP script
  9. SELECT COUNT(*) as total FROM asterisk_cdr WHERE tablefield = 'given string'
  10. try if (condition1) { $this->setBarColor(array(new Color(42, 171, 1))); } elseif (condition2) { $this->setBarColor(array(new Color(42, 71, 1))); } elseif (condition3) { $this->setBarColor(array(new Color(42, 71, 211))); }
  11. Instead of reversing, this would give more natural result $name = "First Middle Last"; $arr = explode(' ', $name); $bySurname = array_pop($arr) . ', ' . join(' ', $arr); //--> Last, First Middle
  12. First thing to do is echo "$tqs" ; to view the update query that is being submitted
  13. That should do it. You get that result because you are viewing a page on localhost from localhost.
  14. yes
  15. Examples --OK SELECT id, name, colour FROM fruit UNION SELECT id, manufacturer, colour FROM car ORDER BY colour -- WRONG: SELECT id, name, colour FROM fruit UNION SELECT id, manufacturer, colour, engine_size FROM car ORDER BY colour -- OK SELECT id, name, colour, NULL as size FROM fruit UNION SELECT id, manufacturer, colour, engine_size FROM car ORDER BY colour
  16. You are appending the results of the second part to the first and combining into a single set of results, so you need to make sure you select the same column structure. For example, you cannot select 5 columns in the first part and 6 in the second. Also corresponding column should be of the same type.
  17. Use a UNION SELECT parent.* FROM `content` as parent JOIN followers ftable on ( (ftable.parent_id=parent.sid AND ftable.userposts='1') OR (ftable.`parent_id`=parent.pageid AND ftable.topic='1') OR (ftable.parent_id=parent.pageid AND ftable.page='1') ) AND ftable.userid=:userid WHERE parent.deleted='0' UNION SELECT parent.* FROM `comments` as parent JOIN followers ftable on ftable.parent_id=parent.postid AND ftable.comments='1' AND ftable.userid=:userid WHERE parent.deleted='0' ORDER BY parent.posted DESC You will have to ensure the same column structure is returned by each part of the UNION
  18. Are the words you can't find in this list http://dev.mysql.com/doc/refman/5.5/en/fulltext-stopwords.html
  19. It looks you you copy/pasted three different scripts in the forlorn hope they will magically work together. 1. Your first piece of code (the form) has two "selects" each with the name "game". They need different names. 2. You second code block is expecting form data called "item" and "quantity", neither of which are in the form. 3. Your third code uses variables "company", "game", "slots" and "price". None of those are defined anywhere else.
  20. As well as engine size you have many different body styles too (hatchback, coupe, saloon, convertible, estate). Then there's transmission types ... As I said, my model was a starting point.
  21. I have no idea what is causing the issue. All you have given us is a query that apparently doesn't produce what you expect. I don't know your table structure, what the input data is to your query, what output the query is giving from that data what you expect the query to be giving. So pretty much in the dark
  22. Frank_b The requirement is which part fits which model and for which years for that model to avoid "many duplicate rows where only the year and vehicle model changes. This would definitely work, but would eventually lead to a very large and messy database". so to find exhaust for a 2010 Golf SELECT p.part_code , p.partname FROM model_part mp JOIN model m USING (model_id) JOIN part p USING (part_id) JOIN part_type pt USING (part_type_id) WHERE m.name = "GOLF" AND pt.description = "EXHAUST" AND "2010" BETWEEN mp.from_year AND mp.to_year Although, in practice, you would have dropdowns to select type and model and use the IDs in the query
  23. this should get you started
  24. The main problem you have given yourself is the foreman's name in the employee records does not match any field in the foreman's own record. In the employee record it is "COBB TY" whereas in Cobb's record you have "COBB" and "TY" in separate fields. Which is why you should use IDs to link records.
  25. It was precisely to avoid this problem when I advised you to normalize you data correctly here http://forums.phpfreaks.com/topic/291641-store-the-id-number-inside-one-array-inside-for-loop/?do=findComment&comment=1493641
×
×
  • 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.