-
Posts
6,906 -
Joined
-
Last visited
-
Days Won
99
Everything posted by ginerjm
-
Assistance wanted - Convert HTML output to PDF
ginerjm replied to gordonisnz's topic in PHP Coding Help
If you are talking about producing true 'monthly reports' for people who read reports all the time, fancy is not the way to do it. Yes - fancy looks nice on a web page but when you are showing people raw data it is best to have it in a clean simple format that makes it easy to examine and identify trends in columns of figures or whatever you are summarizing a month's worth of activity for. FPDF does a great job of letting you query some data and then produce organized tabular (or not) reports in a black and white (with maybe some accents of color) format for people who have to drill thru them regularly. Learning FPDF is simply a matter of laying out in your mind how you want to organize the data, recognizing the widths of the columns you will have and then creating a row of (what are called) cells wherein you place individual fields from your query. 1 - do a query to get 5 columns of data 2 - plan how wide each col needs to be 3 - begin a loop on the query results Then while($row = $qrslts(PDO::FETCH_ASSOC)) { echo "$pdf->cell($col1_w, $cell_h, {$row['col1'], 1, 0, 'L'); echo "$pdf->cell($col2_w, $cell_h, {$row['col2'], 1, 0, 'C'); echo "$pdf->cell($col3_w, $cell_h, {$row['col3'], 1, 0, 'C'); echo "$pdf->cell($col4_w, $cell_h, {$row['col4'], 1, 0, 'R'); echo "$pdf->cell($col5_w, $cell_h, {$row['col5'], 1, 1, 'R'); // jump to new line } This would put your query results into a well organized table structure having no borders. You can easily add the borders and modify the column widths by altering the values I have used. If you have data that is bigger than a simple column FPDF offers a 'mutlicell' function to allow the data to overflow into multiple rows. Takes a bit of practice but as you can see there really isn't a lot to it. -
Are you sure you have all of the values for the send? Nothing missing? Is your 'from' address set in those headers and does it belong to your domain?
-
Assistance wanted - Convert HTML output to PDF
ginerjm replied to gordonisnz's topic in PHP Coding Help
Don't know. But you could google it. FPDF is a tool written to use php and a set of its own functions that generate cells that you define the size of and you can locate using an x/y grid on a page. Doesn't have a lot of font choices so if you have some fancy html you're gonna have to think about it. -
And you want us to tell you ??? Would be nice if you told US what the error says.
-
Assistance wanted - Convert HTML output to PDF
ginerjm replied to gordonisnz's topic in PHP Coding Help
Why don't you use php to generate the pdf instead of producing html and then trying to convert it? FPDF is a pretty good tool for generating a pdf. -
updating from PHP 7.4 to 8.1: call to a member function () on null
ginerjm replied to wkilc's topic in PHP Coding Help
Your construct is using a variable that is not defined with an argument in the method's header. Was the original just like that? -
updating from PHP 7.4 to 8.1: call to a member function () on null
ginerjm replied to wkilc's topic in PHP Coding Help
The new version of php requires a class definition to use a different method of creating/initializing/instantiating a class. The old way was to use the class name in a call to create a 'new' class which executed a method by that name. Now you must use a method named '__construct' to create a new one. You will have to look at your class definition for the method using the class's name and rename that as __construct. -
updating from PHP 7.4 to 8.1: call to a member function () on null
ginerjm replied to wkilc's topic in PHP Coding Help
Whatever has created the reference to $this has not set it to something of that class. That's what the message is telling you. Basically $this or $this->response does not exist. -
Now that you've read my post let's try something to clarify what you are trying to do. Instead of trying to relate your current coding attempts to us just try to tell us what you are actually faced with. In English without reference to forms, submits, pages, fields or any other 'programming' references. Just the facts. As in Day 1 of your task assignment or whatever this is.
-
Without trying to decipher your pictures I will offer this. A form is submitted from a page when a submit action occurs. It only happens once. Whatever is part of that form containing the submit action (button, input , js code) will be passed to the receiving script and that's it. I would be wholly surprised if anyone else tells you of something else. Does that give you something to consider?
-
Need this code to demote user role if points fall below minimum
ginerjm replied to Cybercli's topic in PHP Coding Help
Add some echos to diagnose what is happening . What does that extract line do for you here? Change new role to be a blank (or assign 'contributor') to start. Then assign the new role when your test finds one that fits. If new role is not blank at the end of the loop then post it. -
Need this code to demote user role if points fall below minimum
ginerjm replied to Cybercli's topic in PHP Coding Help
I may be missing something but it appears that your function will do what you want already. You are testing the new balance against the min values for each category. Whatever min value is identified as what s/b a new role you are assigning at the end already. -
Wow! And I thought I was tough on people on the forums. BUT you are right. Leon here does seem to throw stuff at us without any thought as to what he is showing us. Perhaps he will slow down and think a bit more next time. And to blame it on being tired is a terrible excuse. (if you're that beat, stop and sleep on it and then think some more) To talk about error messages and line numbers but not show us the messages or the actual line that each is pointing to is kind of a waste of time.
-
Adding a block of code to a script using the include or require construct is a normal method of building a program. It allows you to create something to accomplish a task whether it is a boilerplate of html or css or JS or plain old PHP. You write it, perfect it and use it where it is then needed. Kind of like the use of function as mentioned earlier in this topic. It's not rocket science and doesn't really have to involve any mystery as it seems to be doing in your post. It is not a way of shortening your script since when it is used it builds your script to the exact same length. It is simply a way of making something and using it wherever it is needed. Just like a function, which quite often is added to a script via the include statement as well. Does that answer your concerns?
-
Whyy are you using both GET and POST items?
-
I beg to differ. What you asked for is being produced by my code when I run it. $val = "\\f192"; while(substr($val,0,1) == '\\') $val = substr($val,1); $result = '\\u{' . $val; echo "Result is now: $result"; You say these are database values. Are the extra slashes perhaps part of an addslashes function put there when the data was saved and needs to be stripped out when it is read back in? PS I don't see the use of $child_icon anywhere else but the very first line of your example. How then does it impact your code later on?
-
Of course now that I have provided a somewhat clumsy approach to answering your question I have to ask - Why? Where are you getting this value that is prone to misunderstanding because of the double slashes? Is this homework?
-
Harder than I thought. How's this? $val = '\\f192'; while(substr($val,0,1) == '\\') $val = substr($val,1); $result = '\\u{' . $val; echo "Result is $result";
-
I"m gonna take a stab at this. Since the backslash is a common 'escape' key, try replacing the double backslash with a triple one.
-
And that is not at all what I was referring to. Never mind. Just wasting my time here.
-
Or is it because you aren't learning but rather continuing to copy other people's work as your own? How hard can it be to catch on to not leaving php mode?
-
So why do you continue?
-
So close. You need to learn that you DO NOT NEED TO LEAVE PHP MODE just to output a line or two of html. $files = glob("images/*.{jpg,png,gif,svg,jpeg,bmp,webp}", GLOB_BRACE); $cnt = count($files); $i = 0; echo "<div class='slideshow-container'>"; foreach ($files as $filename) { $i++; echo " <div class='mySlides fade'> <div class='numbertext'>$i / $cnt</div> <img src='$filename' style='width:20%;'> </div> "; } Entirely in php mode! HTH