Re: Refresh web page?

From: Date: Sat, 09 Sep 2000 18:03:10 +0000
Subject: Re: Refresh web page?
References: 1 2 3  Groups: php.db 
Request: Send a blank email to php-db+get-2768@lists.php.net to get a copy of this message
You must associate it to a "page event" and call the function . Try to define a function : // This works fine to me. function myReload(){ if(condition) url = "stuf1"; else url ="defaulturl.html" ; window.location = url ; } I hope this helps. Jayme. -----Mensagem Original----- De: Andy Wallace <linxit@btconnect.com> Para: <php-db@lists.php.net> Enviada em: quinta-feira, 7 de setembro de 2000 17:21 Assunto: Re: [PHP-DB] Refresh web page? > Ah, I see. So it's basically > > "Show page A unless Submit has been hit, > else show page B instead" > > I could do it that way, I suppose, but it's quite a long page - it'd be > easier to have a refresh() function. > > I knows it's OT, but is there a javascript function I could use instead? I > tried <script>location.reload();</script> but that didn't seem to work > either :-( > > Thanks for your help. > > Andy > ----- Original Message ----- > From: "Cody Caughlan" <codyc@cisco.com> > To: "Andy Wallace" <andyw@datent.com> > Sent: Thursday, September 07, 2000 8:23 PM > Subject: Re: [PHP-DB] Refresh web page? > > > > I would have your structure be something like this: > > > > <? > > #DB Insert Code.. > > if($action == "Submit") > > { > > do your SQL insert here... > > } > > ?> > > <? > > # at this point do a select to get all your data from the DB > > $row = mysql_fetch_array($yourSelect_Pointer); > > while(list($key,$val) = each($row)) > > { > > ${$key} = $val; > > } > > ?> > > <HTML > > <FORM ACTION="$PHP_SELF" METHOD=POST> > > > > <INPUT TYPE=TEXT NAME=firstName VALUE=\"$firstName\"> > > > > <INPUT TYPE=SUBMIT NAME=action VALUE="Submit"> > > > > </HTML> > > > > > > --- > > What I am doing is this, in order: > > 1) If this is the 1st time the page is being access the if($action) part > > fails > > because its not true, so nothing is inserted... > > 2) after that it does a DB select and gets all the data > > since you probably only getting one row you can iterate through all the > > values > > in that row using mysql_fetch_array, > > by doing the list() function with each() you can set each column field > > with its value > > so if you have a Database field called firstName then that is made into > > a variable with the same > > name and its value is whatever it is in the database > > Look at the construct ${someVar} its really handy! > > 3) Then when you do your HTML put the VALUE part in in your tags and set > > it to your variable > > the first time this page is accessed, if no data exists because lets > > say you use a key which wont exist > > until after the person hits submit then all these variables are empty > > and the user doesnt see any > > pre-filled out fields.. > > > > Do you understand what I am saying? Its easy if you get the hang of it > > but I can see how what I said above > > makes no sense... > > > > good luck > > /cody caughlan > > > > Andy Wallace wrote: > > > > > > Hi, > > > > > > Can someone help me out here? > > > > > > I've got a web page with embedded php scripts which read and update a > MySQL > > > database. Default values in a form are taken from the db, and altered > values > > > are written back. > > > > > > How do I refresh the page so that the form entries reflect the changes > made? > > > Currently when I submit the changed values the database is correctly > updated > > > but the page is redisplayed with the old defaults back in place, making > > > users think the update has failed. > > > > > > I'm sure I'm missing something obvious, but I've spent hours browsing > > > through the docs without finding anything useful. > > > > > > TIA, Andy > > > > > > -- > > > PHP Database Mailing List (http://www.php.net/) > > > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > > > For additional commands, e-mail: php-db-help@lists.php.net > > > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > > > -- > > > > > > > > Cody Caughlan -codyc@cisco.com- Cisco Systems > > Web/Database Engineer phone: (408) 525-6029 > > Enterprise Line of Business pager: (408) 951-9949 > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > For additional commands, e-mail: php-db-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.db (#2768) next »