You are here: Re: Best approach to run queries only when user chooses « All PHP « IT news, forums, messages
Re: Best approach to run queries only when user chooses

Posted by Gordon Burditt on 10/24/05 20:21

>I am trying to run a few INSERT queries only if the user clicks 'continue'
>in a <a href> The queries takes variables created from SELECT queries. I
>have tried to acheive this by putting The INSERT queries into a function at
>the top of my php file and having the SELECT queries below it. I have a
>message that pops up that includes a link to the function but I cant get

You can't have a link to a PHP function. Code inside a function
will not be executed unless something calls it. You CAN have a SUBMIT
button for a form, which the user can fill in and click on.

>this to work and am not sure of the best approach. Can anyone help?
>My striped down code is below. Im not even sure if you can just use a
>function to contain code that doesnt return a value. Mine just runs some
>INSERT INTO queries

A function does not have to return a value, and in any case, you
could always supply a dummy value to return.

After a user clicks on the SUBMIT button to a form, you look at
what's in $_GET and $_POST to decide whether or not to call the
function, like the name of the submit button or whether the fields
in the form were filled in.

Gordon L. Burditt

>
>*******************************************************************
><?php
>function PurchaseQuestions(){
>
>various INSERT INTO queries here
>
><h1>Confirmation</h1><br>
><p><a href="logout.php"> Logout</a> or return to <a href="Questions.php">
>Questions Database</a></p><br><br><br>
>Congratulations <b><?php echo $_SESSION[username] ?></b>, your order has
>been completed.</p>
>
><?php
>}
>?>
>
>
><?php
>$OrderDate = date('d/m/Y');
>
>Three SELECT queries here which provides variables for the
>PurchaseQuestions() function
> ?>
> <h1>Order Status</h1>
> <p>You have requested <?php echo $QuestSel; ?> questions at a total cost
>of <strong>£<?php echo $QuestSel*.8; ?></strong>
> If you wish to proceed with the transaction click <a href=<?php echo
>PurchaseQuestions() ?>> Continue</a>.<br>
> <?php
>
> }
>
>?>
><?php
>mysql_close($conn);
>?>
>
>

 

Navigation:

[Reply to this message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация