Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation since 03/19/2024 in all areas

  1. I like to use data attribute on these occasions. NOTE: use a class name for the selects and another for the inputs. Don't use ids. Maintain a count of how many comments the user adds and increment each time they add a new one. When creating a new select and input, give them both a data-id attribute with the value of the count. When emoji selected, get the value of the select's data-id. Look for the input with the same data_id and insert the emoji.
    1 point
  2. Ensure all columns used in the joins are indexed. For example, adding an index on plant.branchid gave atime of 0.03 seconds. +----------------+----------------+---------------+---------------+----------+---------------+ | Category | Budget | Billing | PTarget | PBilling | CTarget | +----------------+----------------+---------------+---------------+----------+---------------+ | Batching Plant | 210,236,000.00 | 17,732,014.85 | 14,716,520.00 | 0.00 | 17,519,666.00 | | Concrete Pump | 125,428,000.00 | 18,451,593.09 | 8,779,960.00 | 0.00 | 10,452,333.00 | | TM | 71,957,300.00 | 7,340,912.62 | 5,037,011.00 | 0.00 | 5,996,442.00 | | SLM | 30,373,660.00 | 1,678,367.08 | 2,126,156.00 | 0.00 | 2,531,139.00 | | Projects | 95,000,000.00 | 306,795.76 | 6,650,000.00 | 0.00 | 7,916,667.00 | +----------------+----------------+---------------+---------------+----------+---------------+ 5 rows in set (0.03 sec)
    1 point
  3. Are you looking for something like this? <!DOCTYPE html> <html lang='en'> <head> <meta charset='utf-8'> <script src="https://code.jquery.com/jquery-3.6.4.min.js"></script> <title>Example</title> <style type='text/css'> p.desc { background-color: black; color: white; padding: 15px; width: 400px; } </style> </head> <body> <div id='target'> <!-- descriptions go here--> </div> <script type='text/javascript'> const texts = [ "Description One", "Decription Two", "Description Three" ] $.each(texts, function(key,txt) { let para = $("<p>", {class:"desc", html:txt}) $("#target").append(para) }) </script> </body> </html>
    1 point
  4. the session.save_path setting in the php.ini is pointing to a now non-existent/non-accessible folder. you need to see of there is already an appropriate folder within your account's directory tree /home/rgxb6tc5wk5q/... for session data files and set the session.save_path setting to point to it, and if a folder doesn't exist, create it and set the session.save_path setting to point to it. when your account was created/moved they should have had templates setup to do this automatically.
    1 point
  5. i recommend that you make a new file with the code necessary to load the phpmailer script and with your sendEmailNotification() function in it, setup some test data, and call the sendEmailNotification() function and get the email to work. once you get the email to work on its own, then make sure that your full code is actually calling the sendEmailNotification() function, by echoing/logging a value at the completion of the email code. you are performing a redirect right after the INSERT query. it's possible that the sms code will take enough time to make the curl request that the browser can abort the current request and halt code execution before your code gets to the email code. it's also possible that the curl code is throwing an error and your code never gets to the email code. any such redirect needs to be at the end of the post method form processing code, it should only occur if there are no user/validation errors, and it should be to the exact same URL of the current page to cause a get request for that page. here's a list of things that will simplify the code, making it easier to see what the code is trying to do - you should only catch and handle database exceptions for user recoverable errors, such as when inserting/updating duplicate user submitted data. for all other insert/update query error numbers, just rethrow the exception and let php handle it and for all other type of queries, let php catch and handle any database exception. for the INSERT query you should be catching and testing for a duplicate index error number. if an applicant can only register once, the applicant_id column should be defined as a unique index, so that only one record per applicant_id can be inserted. if an applicant can only register for a single exam_date_id, the combined applicant_id and exam_date_id columns need to be defined as a composite unique index. if you set the default fetch mode to assoc when you make the database connection, you won't have to specify it in each fetch statement. don't copy variables to other variables for nothing. just use the original variables that data is in.
    1 point
  6. Hi all, My name is Lokesh Joshi and I am new here.
    1 point
  7. If I understood correctly (although I can't see what your data looks like) you may want something like this... TEST DATA TABLE: items TABLE: weapons +----------+--------+ +----+----------+--------+-------+ | playerid | itemid | | id | playerid | weapid | level | +----------+--------+ +----+----------+--------+-------+ | 2 | 2 | | 1 | 2 | 1 | 2 | | 2 | 3 | | 2 | 3 | 1 | 2 | | 2 | 4 | +----+----------+--------+-------+ | 3 | 2 | +----------+--------+ QUERY and RESULTS (Find which players have an item that is 1 greater than current weapon level) SELECT w.playerid , w.weapid , w.level , COALESCE(i.itemid, 'You don\'t have an item for upgrade') as item FROM weapons w LEFT JOIN items i ON w.playerid = i.playerid AND i.itemid = w.level + 1; +----------+--------+-------+------------------------------------+ | playerid | weapid | level | item | +----------+--------+-------+------------------------------------+ | 2 | 1 | 2 | 3 | | 3 | 1 | 2 | You don't have an item for upgrade | +----------+--------+-------+------------------------------------+
    1 point
  8. probably because of this... It's better to use the same column names.
    1 point
  9. As for your problem with joins on icon_ids, I wouldn't bother. Create an array of icons from the icon table $res = $pdo->query("SELECT icon_id, icon_code FROM icon"); $icons = array_column($res->fetchAll(), 'icon_code', 'icon_id'); then use the $card['Icon'] to access key to this array when outputting $icon_code = $icons[$card['Icon']];
    1 point
  10. As the data I was given has no data for RAGUL's empno in any tables (except usertable) I cannot verify any of my theories on what may be wrong. Also for branch 2 I have only this... +---------+---------------+---------------+----------------+-----------------+------------------+----------------+-----------------+ | month | name | CustomerTotal | CustomerActual | ProductionTotal | ProductionActual | MarketingTotal | MarketingActual | +---------+---------------+---------------+----------------+-----------------+------------------+----------------+-----------------+ | 2024-03 | Palanikumar B | | | | | 1 | | | 2024-02 | NAVEENKUMAR P | | | | | 1 | | +---------+---------------+---------------+----------------+-----------------+------------------+----------------+-----------------+ For branch 5... +---------+------------------+---------------+----------------+-----------------+------------------+----------------+-----------------+ | month | name | CustomerTotal | CustomerActual | ProductionTotal | ProductionActual | MarketingTotal | MarketingActual | +---------+------------------+---------------+----------------+-----------------+------------------+----------------+-----------------+ | 2024-02 | Nethaji.MK | | | | | 1 | | | 2024-02 | T.Anandakrishnan | | | | | 1 | | | 2024-02 | Sivanraj.A | | | | | 1 | | | 2024-02 | kannan.r | | | | | 1 | | | 2024-01 | thayyanayaki | 5 | 5 | 2 | 2 | | | | 2024-02 | thayyanayaki | 5 | 5 | 2 | 2 | | | | 2024-03 | thayyanayaki | 5 | 5 | 2 | 2 | 1 | | | 2024-04 | thayyanayaki | 5 | 3 | 2 | 1 | | | | 2024-01 | Vignesh.M | | | | | 1 | 1 | | 2024-02 | Vignesh.M | | | | | 1 | | | 2024-02 | N.Manikandan | | | | | 1 | | | 2024-02 | Dinesh.C | | | | | 1 | | +---------+------------------+---------------+----------------+-----------------+------------------+----------------+-----------------+ The previous queries (your and mine) would only report on whatever empno, branch and month values existed in the production table (the one that isn't LEFT JOINED). This version removes that reliance ... SELECT u.Month , Name , CustomerTotal , CustomerActual , ProductionTotal , ProductionActual , MarketingTotal , MarketingActual FROM ( WITH RECURSIVE allmonths (id, month) as ( SELECT 1, '2024-01' UNION ALL SELECT id+1, concat('2024-', lpad(id+1,2,'0')) FROM allmonths WHERE id < 4 ) SELECT empNo as empId , fname as name , month , ? as branch FROM usertable, allmonths -- WHERE role IN (4, 5) ) u LEFT JOIN ( SELECT count(*) as CustomerTotal , sum(VisitType = 'No Due' OR VisitDate != '') as CustomerActual , month , empid , branch FROM customerdata GROUP BY month,branch,empid ) ca ON u.month = ca.month AND u.empid = ca.empid AND u.branch = ca.branch LEFT JOIN ( SELECT count(*) as ProductionTotal , sum(MCubicmeter OR MHourmeter) as ProductionActual , month , empid , branch FROM production GROUP BY month, branch, empid ) pa ON u.month = pa.month AND u.empid = pa.empid AND u.branch = pa.branch LEFT JOIN ( SELECT count(*) as MarketingTotal , month , empid , branch FROM marketing_target GROUP BY month, branch, empid ) mt ON u.month = mt.month AND u.empid = mt.empid AND u.branch = mt.branch LEFT JOIN ( SELECT count(*) as MarketingActual , month , empid FROM marketing_data GROUP BY month, empid ) ma ON u.month = ma.month AND u.empid = ma.empid AND u.branch = mt.branch HAVING CustomerTotal OR CustomerActual OR ProductionTotal OR ProductionActual OR MarketingTotal OR MarketingActual ORDER BY u.empid, u.month;
    1 point
  11. I find data attributes useful for associating inputs for the same record. I get the data-id of the select field then change other fields with the same data-id. Here's an example <php $employees = [ [ 'id'=>21, 'name'=>'Curly', 'status'=>1, 'title'=>'Sales Manager', 'salary'=>65000 ], [ 'id'=>22, 'name'=>'Larry', 'status'=>1, 'title'=>'Sales Assistant', 'salary'=>45000 ], [ 'id'=>33, 'name'=>'Mo', 'status'=>1, 'title'=>'Sales Assistant', 'salary'=>45000 ], [ 'id'=>46, 'name'=>'Tom', 'status'=>1, 'title'=>'Sales Assistant', 'salary'=>45000 ], [ 'id'=>47, 'name'=>'Dick', 'status'=>1, 'title'=>'Trainee', 'salary'=>25000 ], [ 'id'=>51, 'name'=>'Harry', 'status'=>1, 'title'=>'Trainee', 'salary'=>25000 ] ]; $tdata = ''; foreach ($employees as $e) { $tdata .= "<tr> <td>{$e['name']}</td> <td><select name='emp[{$e['id']}][status]' class='status' data-id='{$e['id']}'>" . statusOptions($e['status']) . "</td> <td><input type='text' name='emp[{$e['id']}][title]' class='title' data-id='{$e['id']}' value='{$e['title']}'></td> <td><input type='text' name='emp[{$e['id']}][salary]' class='salary' data-id='{$e['id']}' value='{$e['salary']}'></td> </tr>"; } function statusOptions($current) { $stats = [1 => "Working", 2 => "Not Working"]; $opts = "<option value=''>- select status -</option>"; foreach ($stats as $s => $desc) { $sel = $s == $current ? 'selected' : ''; $opts .= "<option $sel value='$s'>$desc</option>"; } return $opts; } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Example</title> <script src="https://code.jquery.com/jquery-3.6.4.min.js"></script> <script type='text/javascript'> $(function() { $(".status").change(function() { let id = $(this).data("id") if ( $(this).val() == 2 ) { $(".title[data-id="+id+"]").attr("disabled", true) $(".salary[data-id="+id+"]").attr("disabled", true) } else { $(".title[data-id="+id+"]").attr("disabled", false) $(".salary[data-id="+id+"]").attr("disabled", false) } }) }) </script> <style type='text/css'> table { border-collapse: collapse; width: 80%; margin: 30px auto; } th { text-align: left; padding: 8px; color: white; background-color: black; } td { padding: 4px 8px; } </style> </head> <body> <h1>Example</h1> <form method='POST'> <table border='1'> <tr> <th>Name</th> <th>Status</th> <th>Job Title</th> <th>Salary</th> </tr> <?= $tdata ?> <tr><td colspan='4'><input type='submit'></tr> </table> </form> </body> </html>
    1 point
  12. Then use the actual name of your PDO connection object instead of $pdo. My apologies for not being psychic.
    0 points
This leaderboard is set to New York/GMT-04:00
×
×
  • 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.