-
Posts
24,563 -
Joined
-
Last visited
-
Days Won
822
Everything posted by Barand
-
Create records based on values from other tables
Barand replied to UltimateNova's topic in MySQL Help
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) -
@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 | +----+-------------------+
-
try SELECT domains_url ... ORDER BY SUBSTRING_INDEX(domains_url,'.',1)
-
Help outputting data from mySQL Database using PHP for a website
Barand replied to louiscb's topic in PHP Coding Help
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> -
checkdate() $doby = '2014'; $dobm = '02'; $dobd = '29'; if (checkdate($dobm,$dobd,$doby)) { echo "Date OK"; } else { echo "Date error"; }
-
$years = range($startYear, $startYear+4); if(!in_array($curYear, $validYears)){
-
Then where I used "tablefield", use "channel" in the query
- 9 replies
-
- search code
- string
-
(and 1 more)
Tagged with:
-
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 replies
-
- search code
- string
-
(and 1 more)
Tagged with:
-
SELECT COUNT(*) as total FROM asterisk_cdr WHERE tablefield = 'given string'
- 9 replies
-
- search code
- string
-
(and 1 more)
Tagged with:
-
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))); }
-
Simple Staff List WORD PRESS plugin - order staff members by last name
Barand replied to Ajax30's topic in PHP Coding Help
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- 7 replies
-
- word press
- simple staff list
-
(and 2 more)
Tagged with:
-
First thing to do is echo "$tqs" ; to view the update query that is being submitted
-
Printing the IP Address From Which the Site is Viewed on Screen?
Barand replied to glassfish's topic in PHP Coding Help
That should do it. You get that result because you are viewing a page on localhost from localhost. -
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
-
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.
-
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
-
Are the words you can't find in this list http://dev.mysql.com/doc/refman/5.5/en/fulltext-stopwords.html
-
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.
-
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.
-
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
-
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
-
-
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.
-
SQL Query to Select a Row By an ID Number "Out Of" a Column?
Barand replied to glassfish's topic in PHP Coding Help
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