-
Posts
24,566 -
Joined
-
Last visited
-
Days Won
822
Everything posted by Barand
-
You check if $_POST{'submit'] is set but that that check ends at line 51. All the code that is dependent on it being set needs to be inside the {..}
-
I would recommend using a datepicker component in your form, if you aren't already. Expecting all users to enter consistent date formats will lead to disappointment, also you get confusion with text field dates. Is 06-07-2015 in d-m-Y format or is it m-d-Y? With a datepicker you can display (and post) the same format every time. I usually set my datepickers to display 07-Jun-2015 format which is universally understood by users and is unambiguous. What's more it unambiguous and understood by the PHP strtotime() function and DateTime class. $d = new DateTime('07-Jun-2015'); echo $d->format('Y-m-d'); // 2015-06-07 echo date('Y-m-d', strtotime('07-Jun-2015')); // 2015-06-07
-
You are having problems yet you comment out those lines. Unbelievable!.
-
Having seen your data reminded me you need to join on SectorDate too. Mk III version SELECT * FROM ( SELECT Dep as depA , BeginTime as deptimeA , Arr as arrA , EndTime as arrtimeA , SectorDate FROM rosters WHERE Dep='MAN' AND BeginTime > '03:00' AND SectorDate = '2015-11-26' ) a LEFT JOIN ( SELECT Dep as depB , BeginTime as deptimeB , Arr as arrB , EndTime as arrtimeB , SectorDate FROM rosters ) b ON arrA = depB AND arrtimeA < deptimeB AND a.SectorDate = b.SectorDate LEFT JOIN ( SELECT Dep as depC , BeginTime as deptimeC , Arr as arrC , EndTime as arrtimeC , SectorDate FROM rosters ) c ON arrB = depC AND arrtimeB < deptimeC AND b.SectorDate=c.SectorDate WHERE 'DUB' IN (arrA, ArrB, ArrC)
-
But you still use them in your code
-
I was wondering if it was your airport roster table. There are not many departure and destination points in that table that have a value of "A" or "Z".
-
There is no need for the $table table. Just get the data from the SELECT query. For the rank, just maintain a counter as you output the rows. $sql = "SELECT a.playersid as Entry , b.name as Name , sum(a.points) as Points , sum(a.payout) as Winnings , sum(a.high_hand) as HH , sum(a.fifty_fifty) as Fty , sum(attend) as Attend FROM data a INNER JOIN players b ON a.playersid = b.playersid GROUP BY Entry ORDER BY Points DESC"; $res = mysql_query($sql); $row = mysql_fetch_assoc($res); $heads = "<tr><th>Rank</th><th>" . join('</td><td>', array_keys($row)) . "</th></tr>\n"; $rank=1; $tdata=''; do { $tdata .= "<tr><td>$rank</td><td>" . join('</td><td>', $row) . "</td></tr>\n"; $rank++; } while ($row = mysql_fetch_assoc($res)); ?> <table border='1'> <?php echo $heads, $tdata;?> </table> And stop using mysql_ functions (See my signature)
-
Can you post an sql dump of your rosters table?
-
empty cell in data in columns (display record from database)
Barand replied to sigmahokies's topic in PHP Coding Help
Have you ever considered looking at the PHP reference manual? http://uk1.php.net/manual/en/language.operators.arithmetic.php http://uk1.php.net/manual/en/language.operators.assignment.php -
Mk II version SELECT * FROM ( SELECT depart as depA , dep_time as deptimeA , arrive as arrA , arr_time as arrtimeA FROM journey WHERE depart='A' AND dep_time > '03:00' ) a LEFT JOIN ( SELECT depart as depB , dep_time as deptimeB , arrive as arrB , arr_time as arrtimeB FROM journey ) b ON arrA = depB AND arrtimeA < deptimeB LEFT JOIN ( SELECT depart as depC , dep_time as deptimeC , arrive as arrC , arr_time as arrtimeC FROM journey ) c ON arrB = depC AND arrtimeB < deptimeC WHERE 'Z' IN (arrA, ArrB, ArrC);
-
try SELECT projectid as project , SUM(IF(Status_ID=1, 1,0)) as passed , SUM(IF(Status_ID=2, 1,0)) as failed FROM tbltesttransactions GROUP BY projectid
-
Assuming no more than 2 changes en route mysql> select * from journey; +----+------------+--------+----------+--------+----------+ | id | date | depart | dep_time | arrive | arr_time | +----+------------+--------+----------+--------+----------+ | 1 | 2015-11-23 | A | 04:00:00 | Z | 06:00:00 | | 2 | 2015-11-23 | U | 13:30:00 | Z | 14:20:00 | | 3 | 2015-11-23 | A | 07:00:00 | T | 08:00:00 | | 4 | 2015-11-23 | A | 09:00:00 | U | 12:00:00 | | 5 | 2015-11-23 | T | 09:00:00 | B | 12:00:00 | | 6 | 2015-11-23 | B | 13:00:00 | Z | 15:00:00 | +----+------------+--------+----------+--------+----------+ SELECT * FROM ( SELECT depart as depA , dep_time as deptimeA , arrive as arrA , arr_time as arrtimeA FROM journey WHERE depart='A' AND dep_time > '06:00' ) a LEFT JOIN ( SELECT depart as depB , dep_time as deptimeB , arrive as arrB , arr_time as arrtimeB FROM journey ) b ON arrA = depB AND arrtimeA < deptimeB LEFT JOIN ( SELECT depart as depC , dep_time as deptimeC , arrive as arrC , arr_time as arrtimeC FROM journey WHERE arrive='Z' ) c ON arrB = depC AND arrtimeB < deptimeC; +------+----------+------+----------+------+----------+------+----------+------+----------+------+----------+ | depA | deptimeA | arrA | arrtimeA | depB | deptimeB | arrB | arrtimeB | depC | deptimeC | arrC | arrtimeC | +------+----------+------+----------+------+----------+------+----------+------+----------+------+----------+ | A | 09:00:00 | U | 12:00:00 | U | 13:30:00 | Z | 14:20:00 | | | | | | A | 07:00:00 | T | 08:00:00 | T | 09:00:00 | B | 12:00:00 | B | 13:00:00 | Z | 15:00:00 | +------+----------+------+----------+------+----------+------+----------+------+----------+------+----------+
-
If it is an existing customer then you would pass the customer_id from the form to the processing code and insert it in the task record with the other task data. If it is new customer then you add the customer record, get the last_insert_id() and use that in the task record.
-
No hard and fast rule. If all you want to do with date is display it then it doesn't really matter, though it's easier to to do it in the query. If you need to do some further processing of the date in your PHP then select the raw date (yyyy-mm-dd) in the query, as d/m/y it useless for anything other than display.
-
Customer details should be in a customer table. Just the id of the customer would go in the task record +------------+ +-----------------+ | employee | | customer | +------------+ +-----------------+ | emp_id(PK) | +----------------+ | customer_id(PK) | | emp_name | | task | | cust_name | +------------+ +----------------+ | cust_address | | | task_id(PK) | | cust_phone | | | description | +-----------------+ | | date_of_repair | | | | customer_id |>--------------------+ | +---------------+ | status | | | assignment | +----------------+ | +---------------+ | | | assign_id(PK) | | +------------------<| emp_id | | | task_id |>--------------------+ +---------------+
-
@benanamen, Pure bovine excrement! Plus you have been around here long enough to know you should use code tags (I have added them for you)
-
DATE FORMAT should not be two words, it's DATEunderscoreFORMAT eg SELECT DATE_FORMAT(t.date_of_repair, '%d/%m/%Y')
-
This should get you started SELECT dep1.SectorDate , dep1.Dep , arrs , firstBegin , lastEnd FROM ( SELECT t.SectorDate , IF(Dep='TPS', NULL, Dep) as Dep , firstBegin , lastEnd FROM rosters r JOIN ( SELECT SectorDate , MIN(BeginTime) as firstBegin , MAX(EndTime) as lastEnd FROM rosters GROUP BY SectorDate ) t ON r.SectorDate=t.SectorDate AND r.BeginTime=t.firstBegin ) dep1 LEFT JOIN ( SELECT SectorDate , GROUP_CONCAT(Arr ORDER BY BeginTime separator ', ') as arrs FROM rosters WHERE 'TPS' <> Arr GROUP BY SectorDate ) a USING (SectorDate) GROUP BY SectorDate; +------------+------+------+------------+---------+ | SectorDate | Dep | arrs | firstBegin | lastEnd | +------------+------+------+------------+---------+ | 2015-03-15 | HHN | CIA | 16:15 | 21:45 | | 2015-03-16 | | BGY | 18:30 | 20:15 | | 2015-03-17 | | BVA | 14:20 | 20:00 | | 2015-03-18 | | | 11:30 | 22:30 | +------------+------+------+------------+---------+
-
If you want the count for each team JOIN ( SELECT team_id, status, COUNT(*) AS nap FROM `team_players` WHERE status = '1' GROUP BY team_id ) AS tp ON td.team_id = tp.team_id
-
SELECT td.*, CONCAT(me.First_Name,' ', me.Surname) AS managers_full_name, me.Telephone AS managers_telephone, td.status AS status I don't see "nap" in the columns selected by the query (remember your subquery behaves as though it were another (temp) table
-
... and the subquery "tp" doesn't have a team_id to join on. All it has is a "nap" field.
-
how to create timezone select menu using PHP
Barand replied to aHMAD_SQaLli's topic in PHP Coding Help
Alternative version if you prefer to group the timezones in the menu by region $arr = timezone_identifiers_list(); $now = new DateTime(); foreach ($arr as $tz) { if (strpos($tz, '/')===false ) continue; list ($region, $city) = explode('/', $tz, 2); $d = new DateTimeZone($tz); $secs = $d->getOffset($now); $offset = number_format($secs/3600, 2); $tzArray[$region][$offset][] = $city; } ksort($tzArray); $menu = "<option value=''>- select timezone -</option>\n"; foreach ($tzArray as $region => $regzones) { $menu .= sprintf("<optgroup label='%s'>\n", $region); ksort($regzones); foreach ($regzones as $o => $cities) { foreach ($cities as $city) $menu .= sprintf("<option value='$region/$city'>GMT%+0.2f $region/$city</option>\n", $o); } $menu .= "</optgroup>\n"; } ?> <select name='tzone'> <?=$menu?> </select> -
how to create timezone select menu using PHP
Barand replied to aHMAD_SQaLli's topic in PHP Coding Help
perhaps $arr = timezone_identifiers_list(); foreach ($arr as $tz) { if (strpos($tz, '/')===false ) continue; list ($region, $city) = explode('/', $tz, 2); $d = new DateTimeZone($tz); $secs = $d->getOffset(new DateTime()); $offset = number_format($secs/3600, 2); $tzArray[$offset][$region][] = $city; } ksort($tzArray); $menu = "<option value=''>- select timezone -</option>\n"; foreach ($tzArray as $o => $regzones) { $menu .= sprintf("<optgroup label='GMT %+0.2f'>\n", $o); ksort($regzones); foreach ($regzones as $region => $cities) { foreach ($cities as $city) $menu .= "<option >$region/$city</option>\n"; } $menu .= "</optgroup>\n"; } ?> <select name='tzone'> <?=$menu?> </select> -
how to create timezone select menu using PHP
Barand replied to aHMAD_SQaLli's topic in PHP Coding Help
Forget that. You can use $tz_array = timezone_identifiers_list(); echo '<pre>',print_r($tz_array, true),'</pre>'; -
how to create timezone select menu using PHP
Barand replied to aHMAD_SQaLli's topic in PHP Coding Help
Create a database table of the timezones and build it using that http://timezonedb.com/download