-
Posts
24,605 -
Joined
-
Last visited
-
Days Won
830
Everything posted by Barand
-
how would i query these tables for availables for room reservation
Barand replied to lovephp's topic in PHP Coding Help
you are still making exactly the same mistake -
Not instantly obvious, as there is data entered in the form that is not in that table and data in that table that is not in the form. So the extra data in the table has to come from somewhere. I guess there is more to this process than "The teacher fills in a form". More confusing as "grupo" has become a time field in the "apoios" table. You can probably do something with day of week from apoios date field but not sure what your day data looks like in the timetable data. From what you have said so far (not much) there is little data in common between those two tables from the process as described so far. Where, for instance, does the timetable (primary key ???) appear from. If you wanted someone to write a program to handle this process, do you think that they could do it from the description you have given me, namely
-
how would i query these tables for availables for room reservation
Barand replied to lovephp's topic in PHP Coding Help
Look more carefully at the condition dates in my post You have Sn < From AND En > To Use DATE types and not DATETIME as unwanted time values can distort comparisons -
So having filled in a form, what happens to that data?
-
If you are using LEFT JOIN, yes. Try it with an index on factor_times.status PS. shouldn't this be "<"
-
Good question, and one that is impossible for us to answer from the scant information you have given us. Define "register a summary". What are the processes and data involved in the registration?
-
You would put it in the SELECT clause. Also note you cannot use aliases in WHERE clauses SELECT groups.grid , groups.code1 , products.codeDX , products.CodeSX , products.prodid , products.groupid , CONCAT (code1, ".", codeDX) AS op1 , CONCAT (code1, ".", codeSX) AS op2 FROM groups LEFT JOIN products ON groups.grid = products.groupid WHERE (CONCAT(code1, ".", codeDX) LIKE '%$trimm%' OR CONCAT(code1, ".", codeSX) LIKE '%$trimm%' ) ORDER BY groups.grid
-
Need Help to make advance search in PHP website Project
Barand replied to AMITKUMAR's topic in PHP Coding Help
None of these values you mention in the results (12869, CST, HWH, Weekly, DURG, KHARAGPUR) appear in the data dump you provided, so there is no way your query produced those results. You say stationid1 = DURG, yet the ids are numeric in the data. And what about the other 5 values in the query? So, when you can you can provide accurate, meaningful information I will help. Until then I am not going to waste any more of my time -
Need Help to make advance search in PHP website Project
Barand replied to AMITKUMAR's topic in PHP Coding Help
You still haven't said what values you used when your query doesn't work -
how would i query these tables for availables for room reservation
Barand replied to lovephp's topic in PHP Coding Help
A couple of notes on your tables you should have a table containing "room_status", each row having and an id and status description the id of the status should be stored in the room table, not the description. the status should not be in the reservation table (it's a property of a room) You would use the status table to construct your room status menu. -
how would i query these tables for availables for room reservation
Barand replied to lovephp's topic in PHP Coding Help
If you look at the attached diagram, it shows that room 2, 3, 4 and 5 are not available between dates From and To. The condition that these rooms have in common is Sn < To AND En > From -
Need Help to make advance search in PHP website Project
Barand replied to AMITKUMAR's topic in PHP Coding Help
As we have have no idea about how your data is stored what data you have in your table what values you pass to the query what makes you think we can help? We cannot look over your shoulder to see what you are doing. If you post an SQL dump of "entry_ir_route" table then I'll have a look. [edit] Also what are the values in those variables you are using in the query? -
Does that make it clearer what he means by duplicate json_decode() ?
-
Need Help to make advance search in PHP website Project
Barand replied to AMITKUMAR's topic in PHP Coding Help
From what you said I would expect tables like this +-----------+ +-----------+ +-----------+ | station | | timetable | | train | +-----------+ +-----------+ +-----------+ | stationid |---+ | tt_id | +-----| trainid | | name | +-----<| stationid | | | type | +-----------+ | trainid |>---+ +-----------+ | time | +-----------+ so if your train schedule looks like this +-------------+-------+-------+-------+ | Station | T1 | T2 | T3 | +-------------+-------+-------+-------+ | Station A | 10:00 | 11:00 | 12:00 | | Station B | 10:20 | - | - | | Station C | 10:50 | - | 12:45 | | Station D | 11:10 | - | - | | Station E | 11:30 | 12:15 | 13:25 | +-------------+-------+-------+-------+ then the ttable data would be +-------+-----------+---------+----------+ | tt_id | stationid | trainid | time | +-------+-----------+---------+----------+ | 1 | A | 1 | 10:00:00 | | 2 | B | 1 | 10:20:00 | | 3 | C | 1 | 10:50:00 | | 4 | D | 1 | 11:10:00 | | 5 | E | 1 | 11:30:00 | | 6 | A | 2 | 11:00:00 | | 7 | E | 2 | 12:15:00 | | 8 | A | 3 | 12:00:00 | | 9 | C | 3 | 12:45:00 | | 10 | E | 3 | 13:25:00 | +-------+-----------+---------+----------+ and your query would be SELECT trainid FROM ttable a INNER JOIN ttable b USING (trainid) WHERE a.stationid = 'A' AND b.stationid = 'C'; +---------+ | trainid | +---------+ | 1 | | 3 | +---------+ -
SET colname1 = :value1, colname2=:value2, .....
-
Turn error reporting on then the reason becomes obvious. $media->group->content doesn't exist for the third item
-
You need to use find records where col1 or col2 is equal to the least number WHERE (SELECT LEAST(MIN(COL1),MIN(COL2))FROM yourtable) IN (COL1, COL2)
-
Set up the array structure that you need for your chart data then process your input, accumulating the data for each hour // // INPUT DATA // $input = [ ['0900', '2000', 1, 5], ['1000', '2200', 1, 3] ]; // // PREPARE ARRAYS TO STORE CHART DATA // $init = array_fill_keys(range(0,23), 0); $data = [ 0 => ['name'=>'Supervisors', 'data'=>$init ], 1 => ['name'=>'Staff', 'data'=>$init ] ]; // // PROCESS THE INPUT // foreach ($input as $row) { list($start, $end, $sup, $staff) = $row; for ($hr=$start/100; $hr<$end/100; $hr++) { $data[0]['data'][$hr]+=$sup; $data[1]['data'][$hr]+=$staff; } } // // CHECK CHART DATA // echo '<pre>',print_r($data, true),'</pre>'; result Array ( [0] => Array ( [name] => Supervisors [data] => Array ( [0] => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 [6] => 0 [7] => 0 [8] => 0 [9] => 1 [10] => 2 [11] => 2 [12] => 2 [13] => 2 [14] => 2 [15] => 2 [16] => 2 [17] => 2 [18] => 2 [19] => 2 [20] => 1 [21] => 1 [22] => 0 [23] => 0 ) ) [1] => Array ( [name] => Staff [data] => Array ( [0] => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 [6] => 0 [7] => 0 [8] => 0 [9] => 5 [10] => 8 [11] => 8 [12] => 8 [13] => 8 [14] => 8 [15] => 8 [16] => 8 [17] => 8 [18] => 8 [19] => 8 [20] => 3 [21] => 3 [22] => 0 [23] => 0 ) ) )
-
desc is a reserved word, it needs to be in backticks (or, better, renamed)
-
buttons are not working on a login system
Barand replied to Michael_Baxter's topic in PHP Coding Help
Your form does not have a submit button, just a button, unless your formhash() function submits the form. -
here's one way $arr = [ '2016-02-24 16:55', '2016-02-24 17:55', '2016-02-24 19:55', '2016-02-24 23:55', '2016-02-24 00:35', '2016-02-24 01:34' ]; for ($i=1, $j=0, $k=count($arr); $i<$k; $i++, $j++) { $dj = new DateTime($arr[$j]); $di = new DateTime($arr[$i]); if ($di < $dj) { $arr[$i] = $di->modify('+1 days')->format('Y-m-d H:i'); } } echo '<pre>',print_r($arr, true),'</pre>'; /* RESULT ************* Array ( [0] => 2016-02-24 16:55 [1] => 2016-02-24 17:55 [2] => 2016-02-24 19:55 [3] => 2016-02-24 23:55 [4] => 2016-02-25 00:35 [5] => 2016-02-25 01:34 ) ****************************/
-
Replace the AND in the ORDER BY with a comma ...ORDER BY t2.`turma` , t1.`nome` ASC
-
http://php.net/manual/en/features.file-upload.multiple.php
-
... WHERE date BETWEEN CURDATE() - INTERVAL 1 MONTH AND CURDATE() - INTERVAL 14 DAY