Ask a Question related to PHP Development, Design and Development.
-
Brian #1
Re: Reloading a page
You're asking a javascript question in a PHP newsgroup?
Try this instead of your script.
<html>
<body onLoad="javascript:window.location('http://www.abc.com/abc.php');">
</body></html>
I usually use window.location instead of .reload.
Steve Robbins <srobbins@no.spam.charter.net> wrote in
news:slrnbgmc28.ttq.srobbins@localhost.localdomain :
>
> I am putting a page together that has two text boxes, a button, and a
> table that shows the content of a table. When the button is clicked,
> the content of the text boxes is written to the database and the page
> should be redrawn with the new content of the table. Simple enough.
>
> My problem is that when the button is clicked, I get the text boxes
> cleared and the old data in the table. If I reload the page manually,
> I see the new data.
>
> Here is my last attempt in which I tried going to a javascript routine
> to reload the page. This replaces trying the PHP "Header" function to
> get the page to reload. Any suggestions on how to handle this are
> appreciated.
>
> if($btnInsert)
> {
> $txtPage = $_POST['txtPage'];
> $txtCommonName = $_POST['txtCommonName'];
>
> # the below is one line in my code but broken into two lines
> # for the newsgroup
> $sql = "insert into page_translate set page = \"$txtPage\",
> commonname = \"$txtCommonName\"";
>
> $result = mysql_query($sql);
> ?>
> <script language="JavaScript" type="text/JavaScript">
> window.reload()
> </script>
> <?
> }
>
>
>Brian Guest
-
CF MX 6.1 Adminstrator Page keeps Reloading
I've just currently updated my CF MX 6.0 to CF MX 6.1. (single-IP) The installation was successful and initially I could set up the various DSN... -
Explorer crashes when reloading a page
Hello Every Time I reload a Page with Shockwave3D-Content in it - Explorer crashes at the moment the 3D member appears on Stage? (not only with... -
go to anchors in HTML without reloading the page.
Hi I have a simple question, but I am afraid the answer won't be that simple : I have flash movie that is 1200 pixels high and at the bottom I... -
Without reloading the page
Newbie question here. I'm making a Web database application where I want to get the best performance possible. I like the way Remote... -
how to load an IMAGE without reloading the whole page?
HI Is it possible to load a new image onclick instead of reloading a whole new page? I've got a photo gallery that I want to make a bit more... -
David Mackenzie #2
Re: Reloading a page
On Tue, 08 Jul 2003 20:55:47 -0000, Steve Robbins
<srobbins@no.spam.charter.net> wrote:
Re-loading the page by Javascript or other means shouldn't be>My problem is that when the button is clicked, I get the text boxes
>cleared and the old data in the table. If I reload the page manually,
>I see the new data.
>
>if($btnInsert)
>{
> $txtPage = $_POST['txtPage'];
> $txtCommonName = $_POST['txtCommonName'];
>
> # the below is one line in my code but broken into two lines
> # for the newsgroup
> $sql = "insert into page_translate set page = \"$txtPage\",
> commonname = \"$txtCommonName\"";
>
> $result = mysql_query($sql);
> ?>
> <script language="JavaScript" type="text/JavaScript">
> window.reload()
> </script>
> <?
>}
neccessary.
Where is your query for your table in relation to the above code?
David Mackenzie Guest
-
David Mackenzie #3
Re: Reloading a page
On Wed, 09 Jul 2003 13:23:02 -0000, Steve Robbins
<srobbins@no.spam.charter.net> wrote:
<snip function>>On Wed, 09 Jul 2003 13:17:24 +0100, David Mackenzie
><dcm@tarbrax.freeserve.co.uk> wrote:>>> On Tue, 08 Jul 2003 20:55:47 -0000, Steve Robbins
>><srobbins@no.spam.charter.net> wrote:
>>>>>>>My problem is that when the button is clicked, I get the text boxes
>>>cleared and the old data in the table. If I reload the page
>>>manually, I see the new data.
>>>
>>>if($btnInsert) { $txtPage = $_POST['txtPage']; $txtCommonName =
>>>$_POST['txtCommonName'];
>>>
>>> # the below is one line in my code but broken into two lines # for
>>> the newsgroup $sql = "insert into page_translate set page =
>>> \"$txtPage\", commonname = \"$txtCommonName\"";
>>>
>>> $result = mysql_query($sql); ?> <script language="JavaScript"
>>> type="text/JavaScript"> window.reload() </script> <?
>>>}
>> Re-loading the page by Javascript or other means shouldn't be
>> neccessary.
>>
>> Where is your query for your table in relation to the above code?
>The query is in a function that takes the results and fills a table.
>Here it is(again the first line is word wrapped for the newsreaders):
This may seem like an obvious question, but are you querying the
database after your insert statement above?
--
David (please modify address to david@ before replying!)
David Mackenzie Guest
-
Steve Robbins #4
Re: Reloading a page
On Wed, 09 Jul 2003 15:34:59 +0100, David Mackenzie
<dcm@tarbrax.freeserve.co.uk> wrote:Yes. The basic layout of the page is:> This may seem like an obvious question, but are you querying the
> database after your insert statement above?
Create form.
Draw table with db contents.
When there is information in the text boxes and submit is clicked:
Query to insert data
Redraw page(Here is where I seem to be losing it as the table has all
the old data but not the new record. If I manually reload the page, it
is then correct).
Steve Robbins Guest
-
Steve Robbins #5
Re: Reloading a page
On Wed, 09 Jul 2003 16:52:57 +0100, David Mackenzie
<dcm@tarbrax.freeserve.co.uk> wrote:That did it. Now to make sure I am following the logic, I believe the>
> You are querying and displaying your table before inserting the new
> record. Move your if($btnInsert){} block to before your draw table
> block.
>
> Remember that PHP is executed entirely server-side, so you don't have
> to wait until you've outputted your form before checking the $_POST[]
> array.
>
> If you check the POST vars before creating the form, you can output
> messages to the user if the data fails any validation.
piece I didn't know was that when you click on a form button, the page
is reloaded and processed and that is how the "if" statement related to
the button is run.
This was/is my first run into forms and I was wondering how the if
statement was referenced and that would make sense.
Thanks! If I understood that right, then I think a lot more will make
sense now.
Steve Robbins Guest
-
David Mackenzie #6
Re: Reloading a page
On Wed, 09 Jul 2003 17:23:26 -0000, Steve Robbins
<srobbins@no.spam.charter.net> wrote:
Once you get your head round the client-server programming model it>On Wed, 09 Jul 2003 16:52:57 +0100, David Mackenzie
><dcm@tarbrax.freeserve.co.uk> wrote:>>>
>> You are querying and displaying your table before inserting the new
>> record. Move your if($btnInsert){} block to before your draw table
>> block.
>>
>> Remember that PHP is executed entirely server-side, so you don't have
>> to wait until you've outputted your form before checking the $_POST[]
>> array.
>>
>> If you check the POST vars before creating the form, you can output
>> messages to the user if the data fails any validation.
>That did it. Now to make sure I am following the logic, I believe the
>piece I didn't know was that when you click on a form button, the page
>is reloaded and processed and that is how the "if" statement related to
>the button is run.
>
>This was/is my first run into forms and I was wondering how the if
>statement was referenced and that would make sense.
>
>Thanks! If I understood that right, then I think a lot more will make
>sense now.
becomes easier.
I'm primarily a VB programmer and I found the event-driven model
confusing at first but now I'm used to it.
Good Luck!
--
David (please modify address to david@ before replying!)
David Mackenzie Guest



Reply With Quote

