I am using FPDF to view/print data in PHP.
There is only one page I can see on my browser. But, When I try to print that page. I get one extra blank page from printer. Why FPDF submits one extra page every time? Is there any setting that I need to do?
Thanks.
Related
My html has a table cell which shows the content of a text file (read in by javascript) containing the names of former visitors. This works perfectly.
There is also a form for inserting the visitor's name.
On submit an external php is started which adds the new name to the text file. This is working perfectly too.
At the moment the form begins with this:
<form method="post" action="write2txt.php" target="_blank">
But what I want is: After submit the html simply should refresh to show the updated visitor list.
Don't use target="_blank" in your form, since that displays the results in a new window. Change write2txt.php so that after it writes to the file, it sends back a redirect to the original page's URL, instead of producing its own output.
<?php
// code to update file
header("Location: form.php");
exit();
This will make the browser reload the original page, which will get the updated contents of the file.
If you don't want to use AJAX, this is the general idea of how you have to do it.
(read in by javascript) & no ajax, means what?
Hints
javscript files are catched, keep that in mind
why not adding the date with php in the first place
if the table and the adding is in one file, adding should before outputing the table
if you have seperate file redirect back with header('Location: www.xyz.com');
After reading your last comment above, use:
header('Location: www.xyz.com');
after adding to update automaticly
I am tying to put some user data from the database using php.
The database contains so many record and i am displaying it using mysql_fetch_row() and this gives me the fields of first row.
Now the problem is a have two buttons namely next and previous. And when a click next the fields in the next row has to be obtained the they should be inserted into page without loading the page once again. I am facing problem with this.
I am using php for server side programming and html, css for client side programming.
I think that no one will give you the answer. Too many to write. You need to read about ajax (this is the technology that will allow you to do some action without page reloading).
You need to write javascript(you can use some library like jquery) function which will open some php page with the data that you want and then update your site.
Here you have some nice tutorial:
http://www.w3schools.com/jquery/jquery_ajax_intro.asp
I have a flash banner working with xml and I want a control page for it. For example, when I change banner width from control page also banner change at the same time and same page without refresh. So that occur a preview for flash banner. PHP,HTML and banner available. But how can I get data from form instantly
if "instantly" means without refreshing the page, you need to search for AJAX.
here's a starting point for you:
http://net.tutsplus.com/tutorials/javascript-ajax/submit-a-form-without-page-refresh-using-jquery/
or, directly from flash:
Flash - AJAX call
You need to re-write the code with AJAX, modify all size-related properties for the swf. The script will monitor the form, and onChange (not onSubmit), read the values, remove the previous code and write a new one. I don't think that simply changing the values of the previous object will work on the fly.
I have written a function that fetches a Facebook photo albums and image details for a portfolio website based mainly around images. Now the facebook class requires me to do this before any headers are output on my page.
The function (fb_get_albums) fetches data from facebook is stored as a session array.
Everything works fine, but it takes a few seconds to load, during which the screen is basically blank.
Is there anyway so that I can display my content first, and only then proceed to fetch the data? If I try this, I get the error 'headers already sent...'
<?php
session_start();
require_once 'classes/fb-sdk/src;
fb_get_albums( "fb-username" );
?>
<!DOCTYPE html>
<html>....</html>
?>
You could display the page content first and using Javascript SDK, fetch the images and display it. If the fetching process usually takes more time, then display a rotating loader image so as to inform the user that it might take some time to finish. You could create different types of loader using this online tool: ajaxload.info
If you do not wish to use the Javascript SDK, then try creating a separate page that would do the fetching of images. So, after the page is loaded, when user presses a button or something, issue an AJAX request to fetch the images from the second page.
That is, page1.php contains the basic contents of your page with a button. When use presses that button, using AJAX, page2.php is accessed, which would output the image locations or other details back to the caller.
BTW, did you tried debugging the code so as to find the delay caused in fetching images?
Also, in your present code, there is a small typo:
require_once 'classes/fb-sdk/src/facebook.php';
I mean, the path wasn't complete and was missing an ending single quotes character.
Wish you good luck.
I've created a PHP web form which when all the data is present has 2 submit buttons (Continue and Print). Continue calculates details based on the entered information and displays it on the page. Print performs the same calculations, but then creates a PDF in a new window.
When I click Print the original page still loads (which is fine) but the styling is altered.
To see what I mean head to this page and for speed enter "1" in all text boxes except Position (which must be text). After you've clicked Continue, click Print to generate a PDF, then look back at the original web page to see altered styling.
Any ideas would be useful.
Thanks,
Adrian
Assuming you mean the tables overrunning the footer, get rid of the height: 100%; on #prodselector_text, solves the issue for me.