Results 1 to 18 of 18

Thread: If then script using information from MySQL
      
   

  1. #1
    Rob (SA)'s Avatar
    Rob (SA) is offline Lieutenant Colonel
    Join Date
    Nov 2006
    Location
    Centurion, South Africa
    Posts
    580

    Question If then script using information from MySQL

    Hi folks,

    I am in urgent help.

    I have data of members in a MySQL database which is populated from a form.

    What I would like is an if /then script that once the toatl members =80 then a note will appear "yes" or "no"

    Thus informing them that they can continue with thier process or not.

    Much like a shopping cart I guess that would say stock is avaialbe or not when selecting an item

    I hope someone can help

  2. #2
    navaldesign's Avatar
    navaldesign is offline General & Forum Moderator
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,115

    Default Re: If then script using information from MySQL

    You need something like:

    $query = "SELECT * form tablename WHERE ......your where clasue";
    $result = mysql_query($query, $db);
    $num_rows = mysql_num_rows($result);
    if($num_rows >= 80){
    //Code to be executed if more than 80;
    }
    Navaldesign
    Logger Lite: Low Cost, Customizable, multifeatured Login script
    Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
    DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
    Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!


  3. #3
    Rob (SA)'s Avatar
    Rob (SA) is offline Lieutenant Colonel
    Join Date
    Nov 2006
    Location
    Centurion, South Africa
    Posts
    580

    Thumbs up Re: If then script using information from MySQL

    Hi George,

    Thanks for the reply.

    Whist the information from the tournament happens on one page - is it possible then to include this on another page

    If this be the case do I insert the formula one on th elater page or do it for each row that is shown?

    Thanks again for your help

  4. #4
    navaldesign's Avatar
    navaldesign is offline General & Forum Moderator
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,115

    Default Re: If then script using information from MySQL

    You should include this in the Start of Page of the initial page they need to fill in.
    So if the 80 positions are already covered, it will not even allow them to start, and will display a "Sorry, tournament Closed" or similar message.
    Navaldesign
    Logger Lite: Low Cost, Customizable, multifeatured Login script
    Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
    DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
    Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!


  5. #5
    Rob (SA)'s Avatar
    Rob (SA) is offline Lieutenant Colonel
    Join Date
    Nov 2006
    Location
    Centurion, South Africa
    Posts
    580

    Thumbs up Re: If then script using information from MySQL

    Hi George,

    Thats exactly what I am looking to do - but at the same time they can se the entry status is OPEN / CLOSED.

    I would like the CLOSED to show as RED text.

    If at all possible when the entry status is "CLOSED" and the "PAY NOW" button selected it will show a pop up note - "Sorry entries for this event are closed".

    That should all happen on this page

  6. #6
    navaldesign's Avatar
    navaldesign is offline General & Forum Moderator
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,115

    Default Re: If then script using information from MySQL

    Rob,

    what I provided is the code that you need to use in order to see how many players have already payed for a tournament. It is obvious that the "where" clause must be customized by you to retrieve this info for each tournament.

    Once you have the number of players and the number of allowed players for all tournaments (if different per tournament, otherwise 80 for all), you simply add the if...then statement in your "echo"... code so it will display (or will NOT display) whatever you want.

    In example instead of OPEN/CLOSED it will display OPEN or CLOSED (depending on IF ($num_rows >= 80)...) and will NOT display the Pay Now button. So no need for popup.
    Navaldesign
    Logger Lite: Low Cost, Customizable, multifeatured Login script
    Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
    DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
    Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!


  7. #7
    Rob (SA)'s Avatar
    Rob (SA) is offline Lieutenant Colonel
    Join Date
    Nov 2006
    Location
    Centurion, South Africa
    Posts
    580

    Thumbs up Re: If then script using information from MySQL

    Hi George,

    I have managed to get a page to show how many players are in each tournament but seems to always add one less than there actually are.

    The code that you have presented I am sure wil work but it is understanding where I would place such code on this page as I dont have any echo statements.

    The last proposal is perfect.

    That is if the tournament reflects OPEN then the PAY NOW button will be visible. Alternatively if the status is CLOSED then the PAY NOW button should not show.

    Can you help me sort this please?

  8. #8
    Rob (SA)'s Avatar
    Rob (SA) is offline Lieutenant Colonel
    Join Date
    Nov 2006
    Location
    Centurion, South Africa
    Posts
    580

    Default Re: If then script using information from MySQL

    Here is an example of what I have.

    I dont mind doing the entry of script as long as I could see an example of where and how

    PHP Code:
    <tr class="alt">
    <
    td>HUMEWOOD</td>
    <
    td>18</td>
    <
    td>06 MARCH 2011</td>
    <
    td>?</td>
    <
    td>OPEN/CLOSED</td>
    <
    td><form action="https://www.payfast.co.za/eng/process" method="post"
    <
    input type="hidden" name="cmd" value="_paynow"
    <
    input type="hidden" name="receiver" value="junior@hayesgolf.co.za"
    <
    input type="hidden" name="item_name" value="Payment - Humewood - Glacier Series"
    <
    input type="hidden" name="item_description" value="payment"
    <
    input type="hidden" name="amount" value="120.00"
    <
    input type="hidden" name="return_url" value="http://www.gnjgf.co.za/entryform.php"
    <
    input type="hidden" name="cancel_url" value="http://www.gnjgf.co.za/Glacier_Main.html"
    <
    input type="submit" style="width:66px;height:20px;background-color:#B5CCE4;font-size:10px; font-family: arial, sans-serif;" value="PAY NOW"
    </
    td>
    </
    tr>
    <
    tr class="alt2">
    <
    td>GARDENER ROSS</td>
    <
    td>18</td>
    <
    td>27 MARCH 2011</td>
    <
    td>?</td>
    <
    td>OPEN/CLOSED</td>
    <
    td><form action="https://www.payfast.co.za/eng/process" method="post"
    <
    input type="hidden" name="cmd" value="_paynow"
    <
    input type="hidden" name="receiver" value="junior@hayesgolf.co.za"
    <
    input type="hidden" name="item_name" value="Payment - Gardener Ross - Glacier Series"
    <
    input type="hidden" name="item_description" value="payment"
    <
    input type="hidden" name="amount" value="120.00"
    <
    input type="hidden" name="return_url" value="http://www.gnjgf.co.za/entryform.php"
    <
    input type="hidden" name="cancel_url" value="http://www.gnjgf.co.za/Glacier_Main.html"
    <
    input type="submit" style="width:66px;height:20px;background-color:#B5CCE4;font-size:10px; font-family: arial, sans-serif;" value="PAY NOW"
    </
    td>
    </
    tr

  9. #9
    navaldesign's Avatar
    navaldesign is offline General & Forum Moderator
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,115

    Default Re: If then script using information from MySQL

    Is this a static page ? not a dynamic one ?
    Navaldesign
    Logger Lite: Low Cost, Customizable, multifeatured Login script
    Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
    DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
    Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!


  10. #10
    navaldesign's Avatar
    navaldesign is offline General & Forum Moderator
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,115

    Default Re: If then script using information from MySQL

    <tr class="alt">
    <td>HUMEWOOD</td>
    <td>18</td>
    <td>06 MARCH 2011</td>
    <td>?</td>
    <?php
    if($num_rows >= 80){
    echo '<td>CLOSED</td>
    <td>&nbsp;</td>';
    }
    else {
    echo '<td>OPEN</td>
    <td><form action="https://www.payfast.co.za/eng/process" method="post">
    <input type="hidden" name="cmd" value="_paynow">
    <input type="hidden" name="receiver" value="junior@hayesgolf.co.za">
    <input type="hidden" name="item_name" value="Payment - Humewood - Glacier Series">
    <input type="hidden" name="item_description" value="payment">
    <input type="hidden" name="amount" value="120.00">
    <input type="hidden" name="return_url" value="http://www.gnjgf.co.za/entryform.php">
    <input type="hidden" name="cancel_url" value="http://www.gnjgf.co.za/Glacier_Main.html">
    <input type="submit" style="width:66px;height:20px;background-color:#B5CCE4;font-size:10px; font-family: arial, sans-serif;" value="PAY NOW">
    </td>
    ';
    }
    ?>
    </tr>
    Navaldesign
    Logger Lite: Low Cost, Customizable, multifeatured Login script
    Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
    DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
    Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!


  11. #11
    Rob (SA)'s Avatar
    Rob (SA) is offline Lieutenant Colonel
    Join Date
    Nov 2006
    Location
    Centurion, South Africa
    Posts
    580

    Default Re: If then script using information from MySQL

    Hi George,

    This page is a static one - by this I understand that I have pepared the info as shown in the link below.

    A bit laborious but I managed to get the page to work without having to know too much PHP.

    Hence no echo statements.

    The actual entry form which you helped me create would only appear after the "PAY NOW" or payment is made.

    The page where the total entries per tournament are calculated is a dynamic one - that is the information is done by means of queries and the page populated with that information

  12. #12
    navaldesign's Avatar
    navaldesign is offline General & Forum Moderator
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,115

    Default Re: If then script using information from MySQL

    Rob,

    If you want to use a IF ... THEN statement, the page needs to be dynamic (PHP driven) even for this part only

    So you need, for each row, to execute a query with the code I provided and the the necessary WHERE clause, to retrieve the number of players and then use the code example I provided above to echo the Status and the payment button.

    Making this in a completely static page is out of the question (from me) as it would take me ages to build and update. Why should I, when all info is in the database, and the correct script can make decisions and display what needs be displayed ?
    Navaldesign
    Logger Lite: Low Cost, Customizable, multifeatured Login script
    Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
    DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
    Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!


  13. #13
    Rob (SA)'s Avatar
    Rob (SA) is offline Lieutenant Colonel
    Join Date
    Nov 2006
    Location
    Centurion, South Africa
    Posts
    580

    Default Re: If then script using information from MySQL

    HI George,

    That portion of script works well.

    I have tested the script in an OPENn staus which can now be seen.

    Is it posssible that with this IF THENn opton working the PAY NOW button will show or not show?

  14. #14
    Rob (SA)'s Avatar
    Rob (SA) is offline Lieutenant Colonel
    Join Date
    Nov 2006
    Location
    Centurion, South Africa
    Posts
    580

    Thumbs up Re: If then script using information from MySQL

    Hi George,

    Reading the script / insert you have presented I understand that the option of the button when closed will not show - Thanks that will really work.

    Regarding the other option of doing everything in the static page - that I will do - I would benever expect you to do that.

    What I was trying to request is an example of the query in order I can go make all these changes in the static page.

    Your help so far is really going to help me

  15. #15
    navaldesign's Avatar
    navaldesign is offline General & Forum Moderator
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,115

    Default Re: If then script using information from MySQL

    Quote Originally Posted by Rob (SA) View Post
    HI George,

    That portion of script works well.

    I have tested the script in an OPENn staus which can now be seen.

    Is it posssible that with this IF THENn opton working the PAY NOW button will show or not show?
    Yes, the code I provided will show (depending on status) Open or Close and will or will not display the Pay Now button.
    Navaldesign
    Logger Lite: Low Cost, Customizable, multifeatured Login script
    Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
    DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
    Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!


  16. #16
    Rob (SA)'s Avatar
    Rob (SA) is offline Lieutenant Colonel
    Join Date
    Nov 2006
    Location
    Centurion, South Africa
    Posts
    580

    Question Re: If then script using information from MySQL

    Thanks George.

    Do I now do the same thing with the orginal code presented - for each and every - static detail.

    Then change each script for the unique instance?

  17. #17
    navaldesign's Avatar
    navaldesign is offline General & Forum Moderator
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    12,115

    Default Re: If then script using information from MySQL

    Sorry, not sure I understand what you mean.

    The code to retrieve the number of entries (if that's what you mean) should be repeated for each row (tournament)
    Navaldesign
    Logger Lite: Low Cost, Customizable, multifeatured Login script
    Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
    DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
    Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!


  18. #18
    Rob (SA)'s Avatar
    Rob (SA) is offline Lieutenant Colonel
    Join Date
    Nov 2006
    Location
    Centurion, South Africa
    Posts
    580

    Default Re: If then script using information from MySQL

    Hi George,

    Thanks - You understand it correctly. Because it is static I have to enter the original code (each query) in each "row" - this would then have to be modified to suit the row.

    Secondly - I have been entering and ammending the information for each row but it is not seemingly reaching a limit to the amount I can enter to the html file.

    I am not sure for the reason it does so?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49