Jump to content

Barand

Moderators
  • Posts

    24,608
  • Joined

  • Last visited

  • Days Won

    831

Everything posted by Barand

  1. Are you making notes other than the player notes? (Remember, there is only you who knows what you are trying to achieve, what your process are and what your data looks like)
  2. Are you talking about making notes about players during a game? id PlayerID TeamID Timestamp Comments
  3. Just a guess, but do you have several objects with same id (#userDeleteConfirmationModal)?
  4. I would need to review your model before committing. To me, a "player" table would contain player attributes such as PlayerID, Name | Address | Phone | Dob | etc.
  5. I would datestamp the note records rather than store the season code. At least you then know exactly when you made the note. Have a "season" table to define the seasons Season From To 18-19 | 2018-11-01 | 2019-03-31 19-20 | 2019-11-01 | 2020-03-31 Then if you want this season's notes SELECT note_date , note FROM note n JOIN season s ON n.note_date BETWEEN s.From and s.To WHERE CURDATE() between s.From and s.To ORDER BY note_date
  6. try the html attribute instead of the text attribute modal.find('#active-sheets').html(activesheets)
  7. What is the object whose id = active-sheets?
  8. Escape the quotes. IF(Media='Physical', '<img src=\"Images/floppy.png\">', Media) as Media
  9. if you want to do it in the query (as you have above) then something like SELECT IF(Media='Physical', '<img src="images/floppy.png">', Media) as Media
  10. You need "<br>" for newlines in an html document ("\n" and multiple spaces are ignored unless between <pre>..</pre> tags or in a <textarea>)
  11. It certainly doesn't live up to its name.
  12. I just pasted the code you posted into my editor. As you can see from the green text, everything following is considered part of the TEXT string It should look like this
  13. It could be that the real cause is higher up in the code but isn't being noticed until the reported line. Post the code from your <<<TEXT to the error line.
  14. Strange!. Line 132 doesn't give a problem for me. However, I would write it differently, removing the concatenation by using {..}s around the array variables echo "<option value='{$row['role_id']}'>{$row['role_name']}</option>"; Alternatively, as constants are not permitted within a string, the single quotes around the keys can be omitted echo "<option value='$row[role_id]'>$row[role_name]</option>"; That one doesn't need preparing - query() is fine. No parameters.
  15. By default the separator is just a comma. IMHO it's more readable if you use GROUP_CONCAT(job_eventname SEPARATOR ', ') as eventname
  16. One of things I really liked about PHP, having previously used VB (ugh!) was the ability to directly embed variables into strings without all the confusing quoting and concatenating. Coupled with the ability to use HEREDOC syntax life became much easier when confronted with strings like this one. I would suggest... echo <<<TEXT <td><a class="btn btn-primary col-sm-12" data-toggle="modal" data-userid="$uid" href="#userModal" data-firstname="$ufn" data-lastname="$uln" data-email="$ue" data-accountlevel="$ualid" data-mobile="$um" data-role="$urid" data-active-sheets="$ename">Manage</a></td> TEXT; Alternatively, go for a string inside "...." and with single quotes around attribute values, BUT, where you have an attribute value that could contain a single quote character or apostrophe, use escaped double quotes. EG echo "<td><a class='btn btn-primary col-sm-12' data-toggle='modal' data-userid='$uid' href='#userModal' data-firstname=\"$ufn\" data-lastname=\"$uln\" data-email='$ue' data-accountlevel='$ualid' data-mobile='$um' data-role='$urid' data-active-sheets=\"$ename\">Manage</a></td>";
  17. One way ... $list=[ 12314=>'OBJ1', 321=>'OBJ2', 42142=>'OBJ3', 14314=>'OBJ4', 123=>'OBJ5', 13314=>'OBJ6' ]; function getIt($list, $min, $max) { $arr = array_filter($list, function ($k) use ($min,$max) { return $k >= $min && $k <= $max; }, ARRAY_FILTER_USE_KEY); krsort($arr); return current($arr); } echo getIt($list, 10000, 15000); // OBJ4 echo getIt($list, 15000, 20000); // false
  18. InnoDB has many advantages over MyIsam. The time MyIsam comes out top is when you have lots of data retrieval from large databases; then it's faster.
  19. HINT: I am all for 1 or 2 character aliases for tables but you would make your queries more readable with more meaningful aliases for the tables than just a, b, c, d, e EG ssm_job j ssm_venue v ssm_customer c
  20. Join twice to the user table with different aliases select a.job_manager_id , jm.username as manager , a.job_head_chef_id , hc.username as chef FROM ssm.job a JOIN user jm ON jm.user_id = a.job_manager_id JOIN user hc ON hc.user_id = a.head_chef_id
  21. For example, if you have these tables ... CREATE TABLE `test1` ( `job_id` int(11) NOT NULL AUTO_INCREMENT, `test1_descrip` varchar(45) DEFAULT NULL, PRIMARY KEY (`job_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `test2` ( `test2_id` int(11) NOT NULL AUTO_INCREMENT, `job_id` int(11) DEFAULT NULL, PRIMARY KEY (`test2_id`), KEY `idx_test2_job_id` (`job_id`), CONSTRAINT `test2_fk1` FOREIGN KEY (`job_id`) REFERENCES `test1` (`job_id`) ON DELETE CASCADE ON UPDATE NO ACTION ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `test3` ( `test3_id` int(11) NOT NULL AUTO_INCREMENT, `job_id` int(11) DEFAULT NULL, PRIMARY KEY (`test3_id`), KEY `idx_test3_job_id` (`job_id`), CONSTRAINT `test3_fk1` FOREIGN KEY (`job_id`) REFERENCES `test1` (`job_id`) ON DELETE CASCADE ON UPDATE NO ACTION ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `test4` ( `test4_id` int(11) NOT NULL AUTO_INCREMENT, `job_id` int(11) DEFAULT NULL, PRIMARY KEY (`test4_id`), KEY `idx_test4_job_id` (`job_id`), CONSTRAINT `test4_fk1` FOREIGN KEY (`job_id`) REFERENCES `test1` (`job_id`) ON DELETE CASCADE ON UPDATE NO ACTION ) ENGINE=InnoDB DEFAULT CHARSET=utf8; ... where test1 is the parent table and tables 2. 3 and 4 are the child tables, each with a foreign key referencing the primary key in the first table BEFORE +--------+---------------+ | job_id | test1_descrip | +--------+---------------+ | 20 | Job 20 | | 21 | Job 21 | | 22 | Job 22 | | 23 | Job 23 | | 24 | Job 24 | | 25 | Job 25 | +--------+---------------+ | +------------------+----------+------------------------------+ | | | +----------+--------+ +----------+--------+ +----------+--------+ | test2_id | job_id | | test3_id | job_id | | test4_id | job_id | +----------+--------+ +----------+--------+ +----------+--------+ | 8 | 21 | | 2 | 20 | | 4 | 21 | | 7 | 24 | | 3 | 21 | | 5 | 22 | +----------+--------+ | 4 | 22 | | 6 | 23 | +----------+--------+ | 7 | 24 | +----------+--------+ Delete query... DELETE FROM test1 WHERE job_id = 21; Records for job 21 also deleted from test2, test3, test4 due to the "ON DELETE CASCADE" settings in the foreign key definitions AFTER +--------+---------------+ | job_id | test1_descrip | +--------+---------------+ | 20 | Job 20 | | 22 | Job 22 | | 23 | Job 23 | | 24 | Job 24 | | 25 | Job 25 | +--------+---------------+ | +------------------+----------+------------------------------+ | | | +----------+--------+ +----------+--------+ +----------+--------+ | test2_id | job_id | | test3_id | job_id | | test4_id | job_id | +----------+--------+ +----------+--------+ +----------+--------+ | 7 | 24 | | 2 | 20 | | 5 | 22 | +----------+--------+ | 4 | 22 | | 6 | 23 | +----------+--------+ | 7 | 24 | +----------+--------+
  22. 1. array_combine(), as it says on the tin, combines two arrays. These arrays must be of equal length. Yours are not. 2. Sounds like you are attempting to insert a record but not providing the data for a required field (column 'Text'). You need to either provide a value alter the table to define a default value 3. RTFM
  23. That was established in the question ??? FROM is part of the DELETE syntax just as it is part of the SELECT syntax and has the same role - defining the table references.
  24. As with SELECT statements, INNER JOIN requires matching records. If some tables may not contain the job_id being deleted then you need LEFT JOINS DELETE ssm_job, ssm_menu_order, ssm_equipment_order, ssm_money_order FROM ssm_job LEFT JOIN ssm_menu_order USING (job_id) LEFT JOIN ssm_equipment_order USING (job_id) LEFT JOIN ssm_money_order USING (job_id) WHERE ssm_job.job_id = ?
  25. Do all four tables contain a record with job_id = 21?
×
×
  • 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.