-
Posts
24,566 -
Joined
-
Last visited
-
Days Won
822
Everything posted by Barand
-
I thought you needed start and end dates? For example ... <a href="my_pdf_report.php?sdate=2020-03-01&edate=2020-03-05">Create PDF</a>
-
With which bit do you need help ?
-
If you are putting the reports for everyone in a single file you don't need to pass an id. You are going to process all of them.
-
Sounds like you want to view the totals one by one yet have all the data in one PDF file. Yet another reason to put the PDF code in a separate file.
-
You change your query. Remove "WHERE oracleie = ?" Add "ORDER BY oracleid" Create new page after each id's totals
-
Try outputting the pdf to a file instead of the screen.
-
Because ->Output() will be sending header data tell the browser to expect PDF output. You cannot send headers after output has been sent. This is why, on March 27, I told you
-
Constraining the # of columns of an existing table
Barand replied to newbieprogrammer's topic in PHP Coding Help
Your randomNr array contains 10 elements so foreach($randomNr as $number) will give 10 columns. You need to pick a random 6 numbers out of the 10. Separate the php code from the html. Use CSS for styling the output. Example <?php $randomNr = range(0,9); $bingokaart = display($randomNr); function display ($arr) { $result = ""; for ($row = 1; $row < 7; ++$row) { $rand6 = array_rand($arr, 6); $result .= '<tr>'; foreach ($rand6 as $n) { $result .= "<td>$row$arr[$n]</td>"; } $result .= "</tr>\n"; } return $result; } ?> <!DOCTYPE html> <html> <head> <title>Sample</title> <style type="text/css"> table { border-collapse: collapse; } td { padding: 2px; } </style> </head> <body> <table border='1'> <?= $bingokaart ?> </table> </body> </html> -
You solved it.
-
Try ending the previous line with a ";"
-
That query should return a single record containing a count of all the records found What does "not working" mean? Were you expecting more records?
-
EAV models are always a PITA. Here's how I would do it. (I would actually write a function which accepts an array of attributes you want and generate the query in the function)
-
Are you trying to get to this ... +-----------+---------------+--------------------+-------------------+-------------------+---------------------+---------------+ | data_id | name | email | subject | message | time | ip_address | +-----------+---------------+--------------------+-------------------+-------------------+---------------------+---------------+ | 1 | John Dow | John [email protected] | Hello | I have no message | 2020-04-03 03:19:56 | ::1 | | 2 | Stephen | [email protected] | Hello | I have no message | 2020-04-03 03:28:33 | ::1 | +-----------+---------------+--------------------+-------------------+-------------------+---------------------+---------------+
-
After inserting a record, call last_insert_id() method to get its id. Faster than querying.
-
Find the earliest join date and create a date table from then until some future date. You could make a permanent table so you always have working dates to hand and use it for all. You would then have to specify ... WHERE date BETWEEN X AND Y
-
How accurate do you need to be? Over a period of time, working days = total days * 5 / 7. If you need absolute accuracy then you need the data on when they attended (or were absent) for every occurrence since they joined. Do you have that data? If you do have the data, then this is essentially the same problem as your other post about absent days.
-
Don't double-post
-
Compare result of MySQL statement to string in PHP
Barand replied to mattchamp97's topic in PHP Coding Help
Too many queries. Don't run queries inside loops - use JOINs. For example <?php const HOST = 'localhost'; const USERNAME = '????'; const PASSWORD = '????'; const DATABASE = '????'); function pdoConnect($dbname=DATABASE) { $db = new PDO("mysql:host=".HOST.";dbname=$dbname;charset=utf8",USERNAME,PASSWORD); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); return $db; } $db = pdoConnect(); $user = 1; $res = $con->prepare("SELECT m.moduleId , m.lecturerId , m.moduleName , m.classListCourseCode , u.accountType FROM user_info u JOIN module_details m ON u.courseCode = m.classListCourseCode WHERE u.idNum = ? "); $res->execute( [$user] ); $response = []; foreach ($res as $r) { $acc = array_pop($r); if ($acc=='student') { $response[] = $r; } } echo json_encode(array("server_response"=>$response)); ?> -
Sounds like the solution is a simple LEFT JOIN player P bookmark B +-------------+------------------+ +-------------+ | player_id | name | | player_id | +-------------+------------------+ +-------------+ | 1 | Curly | | 2 | | 2 | Larry | | 4 | | 3 | Mo | +-------------+ | 4 | Abbott | | 5 | Costello | +-------------+------------------+ player P LEFT JOIN bookmark B +-------------+------------------+-------------+ | P.player_id | P.name | B.player_id | +-------------+------------------+-------------+ | 1 | Curly | NULL | | 2 | Larry | 2 | | 3 | Mo | NULL | | 4 | Abbott | 4 | | 5 | Costello | NULL | +-------------+------------------+-------------+ Where no bookmark matches, you have NULL values for the bookmark data. So now you you know whether to put a "+" or a "-"
-
Yes, i know. You already established that. In my previous post, I suggested you might be able able to output the link with each person's total (ie once per person like the total). If you want them somewhere else then the logic will be different.
-
Here's a section of your form Becacause you have used checkboxes you are inviting the user to select one or more applicable options. In the example shown, a reasonable combination of "Fatal / Fire / Property Damage". However, because of the way you have named them in your code (all same name "checkbox"), your processing will only receive the last one. In this example that is the least important. To receive all the selected options, append "[]" to the checkbox names. <tr> <td><input type="checkbox" value="Nearmiss case" name="checkbox[]"></td> <td><input type="checkbox" value="First Aid Case" name="checkbox[]"></td> <td><input type="checkbox" value="Lost Time Injury" name="checkbox[]"></td> <td><input type="checkbox" value="Fatal" name="checkbox[]"></td> <td><input type="checkbox" value="Fire" name="checkbox[]"></td> <td><input type="checkbox" value="Emission/Discharge/Spill/Leak(Abnormal)" name="checkbox[]"></td> <td><input type="checkbox" value="Property Damage" name="checkbox[]"></td> <td><input type="checkbox" value="HIPO" name="checkbox[]"></td> </tr> This will then cause them to be POSTed as an array $_POST = Array ( [checkbox] => Array ( [0] => Fatal [1] => Fire [2] => Property Damage ) [btnSubmit] => Submit ) If you want the user to select only one, use radio buttons. Just my 0.02 worth.
-
You output totals once per user. The logic would be the same for outputting the inks, but it depends where you want to output them.
-
This is going to come as a surprise to you, but from where I am sitting I cannot see over your shoulder and look at the code on your screen. I do not what query you ran, what data your loop is processing or what your loop is outputting to the screen, or anything else it may be doing. Therefore it not possible for me to tell you what to do in your situation.
-
Are you sure the two code samples you posted are related? The first processes 21 $_POST inputs, the second has 2 input fields.
-
That query will insert 1 row. If it's inserting more than that then you are running that code more than once. Is it inside a loop that isn't shown?