Jump to content

Barand

Moderators
  • Posts

    24,337
  • Joined

  • Last visited

  • Days Won

    795

Everything posted by Barand

  1. It could be that the user does not have the privileges to create database Try connecting as that user and SHOW GRANTS
  2. Sample of function selection menu <?php function aaa() {echo "You selected function 'aaa'<hr>";} function bbb() {echo "You selected function 'bbb'<hr>";} function ccc() {echo "You selected function 'ccc'<hr>";} if (isset($_GET['choice'])) { $func = $_GET['choice']; // call chosen function $func(); } ?> <form> Choose a function <select name="choice"> <option value="aaa">a</option> <option value="bbb">b</option> <option value="ccc">c</option> </select> <br><br> <input type="submit" value="Submit" name="btnSub"> </form>
  3. I ran your code for 2013-10-27 (day UK DST changes) and still got Cursor = 2013-10-27 00:00:00 Cursor = 2013-10-27 00:15:00 Cursor = 2013-10-27 00:30:00 Cursor = 2013-10-27 00:45:00 Cursor = 2013-10-27 01:00:00 Cursor = 2013-10-27 01:15:00 Cursor = 2013-10-27 01:30:00 Cursor = 2013-10-27 01:45:00 Cursor = 2013-10-27 02:00:00 Cursor = 2013-10-27 02:15:00 Cursor = 2013-10-27 02:30:00 Cursor = 2013-10-27 02:45:00 Cursor = 2013-10-27 03:00:00 Cursor = 2013-10-27 03:15:00 Cursor = 2013-10-27 03:30:00 Cursor = 2013-10-27 03:45:00 so that kills the DST theory
  4. try $dt = new DateTime("2012-10-07 00:00:00"); $di = new DateInterval('PT15M'); $dp = new DatePeriod($dt, $di, 16); foreach ($dp as $d) { echo $d->format('Y-m-d H:i') . '<br>'; } Output 2012-10-07 00:00 2012-10-07 00:15 2012-10-07 00:30 2012-10-07 00:45 2012-10-07 01:00 2012-10-07 01:15 2012-10-07 01:30 2012-10-07 01:45 2012-10-07 02:00 2012-10-07 02:15 2012-10-07 02:30 2012-10-07 02:45 2012-10-07 03:00 2012-10-07 03:15 2012-10-07 03:30 2012-10-07 03:45 2012-10-07 04:00
  5. isset() is for checking if a variable has been assigned a value. I don't know what your $html->find() function returns if the string isn't found but that is what you should be checking for. If it returns "false" you can if (!$html->find('blah') { ... }
  6. Looks like you need to get $hid from $_POST['id'] when you process the form
  7. - Look at all the business processes that will be required - Look at the data that will be required to support those processes. - Construct a relational data model. - Validate that the model is viable for the processes - Then start coding
  8. Alternatively, save this version of the query as a VIEW, say "current_version" and use the view instead of the table when required SELECT v.* FROM version v JOIN ( SELECT nidt, noeud, MAX(version) as maxversion FROM version GROUP BY nidt, noeud ) latest USING (nidt, noeud) LEFT JOIN ( SELECT nidt, noeud, MAX(version) as maxoper, 1 AS isoper FROM version WHERE etat_fonct = 'OPERATIONAL' GROUP BY nidt, noeud ) oper USING (nidt, noeud) WHERE (isoper AND (etat_fonct='OPERATIONAL') AND (version = maxoper)) OR (isoper IS NULL AND version = maxversion)
  9. use DELETE vtest FROM vtest JOIN ( SELECT nidt, noeud, MAX(version) as maxversion FROM version GROUP BY nidt, noeud ) latest USING (nidt, noeud) LEFT JOIN ( SELECT nidt, noeud, MAX(version) as maxoper, 1 AS isoper FROM version WHERE etat_fonct = 'OPERATIONAL' GROUP BY nidt, noeud ) oper USING (nidt, noeud) WHERE (isoper AND ((etat_fonct<>'OPERATIONAL') OR (version < maxoper))) OR (isoper IS NULL AND version < maxversion)
  10. Quote text and date values. Do not quote numeric values. MySQL won't error if you quote numbers but you give it the overhead of converting strings to numeric types.
  11. This query should give the records to be deleted from your test data SELECT v.nidt, v.noeud, v.version, v.id FROM version v JOIN ( SELECT nidt, noeud, MAX(version) as maxversion FROM version GROUP BY nidt, noeud ) latest USING (nidt, noeud) LEFT JOIN ( SELECT nidt, noeud, MAX(version) as maxoper, 1 AS isoper FROM version WHERE etat_fonct = 'OPERATIONAL' GROUP BY nidt, noeud ) oper USING (nidt, noeud) WHERE (isoper AND ((etat_fonct<>'OPERATIONAL') OR (version < maxoper))) OR (isoper IS NULL AND version < maxversion) You could write these results to a temporary table then join the version table to that to either DELETE or UPDATE a deleted_flag. Alternatively you could LEFT JOIN to this query (as a subquery) to select the active records. According to the query, these should be deleted: nidt noeud version id 00000001B2 16 11 2 00000001B2 17 11 3 00000001B2 18 10 5 00000001F3 16 11 11
  12. PS. your table needs a unique/primary key ALTER TABLE `version` ADD COLUMN `id` INT NOT NULL AUTO_INCREMENT FIRST , ADD PRIMARY KEY (`id`) ;
  13. Images of your data are difficult to load into a test table. A dump would be easier.
  14. In what way? You can insert data into one table that is selected from another.
  15. That looks good - I see you found the VALUES() function needed for multiple updates
  16. To use ON DUPLICATE KEY you first need a unique key. Userid is not unique so the unique key would need to be (userid, days). Then when you try to add, say, (3, 'Monday') again there would be a duplicate so you can update the time fields
  17. To compare dates you need the elements of the date in YMD order ie CONCAT(ryear,rmonth,rday). Use MySQL DATE type fields for date storage (format yyyy-mm-dd)
  18. Helped you once but you rejected it. Why should I help more?
  19. try something like this $db = new mysqli(HOST, USERNAME, PASSWORD, 'test' ); $pid = 5; $sql = "SELECT productName, category_id FROM product WHERE product_id = $pid"; $res = $db->query($sql); list($prod, $catid) = $res->fetch_row(); $trail = array($prod); getBreadcrumbs($catid, &$trail, $db); $trail = array_reverse($trail); echo join(' ยป ', $trail) . '<br>'; function getBreadcrumbs($catid, &$trail, $db) { $sql = "SELECT name, parent, level FROM category WHERE category_id = $catid"; $res = $db->query($sql); if ($res->num_rows > 0) { list($name, $parent, $level) = $res->fetch_row(); $trail[] = $name; if ($level > 1) getBreadcrumbs($parent, $trail, $db); } }
  20. I normalized the data into table randomn. id int, seq int ball int then SELECT CONCAT_WS(',', A,B,C) as balls, COUNT(*) as occ FROM ( SELECT a.id, a.ball as A, b.ball as B, c.ball as C FROM randomn a JOIN randomn b ON a.id = b.id AND a.seq < b.seq JOIN randomn c ON c.id = b.id AND b.seq < c.seq ) as X GROUP BY balls ORDER BY occ DESC
  21. Ah, at last! Webdev, you have now given us a clue about what you are looking for. That last post (+ sample data) is one you should have made a page back.
  22. So there are. Guess we need clarification from Webdev. Could do with some regarding what he's actually trying to do too. I confess to being confused about his requirements. So far I am assuming he is looking for repetitions of 3 balls drawn in sequence
×
×
  • 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.