Page 3 of 6 FirstFirst 12345 ... LastLast
Results 21 to 30 of 58

Thread: IF / THEN statement using data from MySQL

  1. #21
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    basically, yes.

    however, this:
    PHP Code:
    <?php 
    if($num_rows >= 80){ 
    echo 
    '<td><font style="font-size:11px" color="Red" face="Arial">CLOSED</td> 
    <td>&nbsp;</td>'


    else { 
    echo 
    '<td><b><font style="font-size:11px"  color="Blue" face="Arial">OPEN</b></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 - Glendower - 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> 
    '
    ;
    would be more efficient like this:
    PHP Code:
    $openORclosed $num_rows >= 80 'CLOSED' 'OPEN';

    echo 
    '<td><font style="font-size:11px" color="Red" face="Arial">'.$openORclosed.'</td>';

    if(
    $openORclosed 'CLOSED'){
    echo 
    '<td>&nbsp;</td>';
    }else { 
    echo 
    '
    <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 - Glendower - 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> 
    '

    (BTW, these pages are dynamic, because PHP is creating them with different values depending on the situation. "static" means they never change.)

  2. #22
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    If 2 users (a & b) come to your page and load this page when there are 79 users entered you will receive 81 entries for that tournament.

    User A loads register page and it loads open because 79 entries are there.
    User A loads another tab and googles something.
    User B loads register page (while User A is googling) and it loads open because 79 entries are there.
    User A submits the forum to become the 80th register.
    User B submits and becomes the 81 register.

    To stop this you will also need this conditional statement on the submission process page as well, before executing the SQL (insert).
    Corrections to my coding/thoughts welcome.

  3. #23
    Join Date
    May 2007
    Location
    South Africa
    Posts
    175
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Hi Guys,

    Thanks for the replies.

    In reply - the rush to enter is not too much of a problem as we have a reserve of 16 places built into each event.

    The events take place throughout the year and thus if you are 79 or 80 is not going to be to much of a problem.

    It is really the masses that always wake up late - to enter that we want to prevent from messing around with a rather structured environment.

    Know that we have a more efficient method of rewittting the code - I just need help with the code that will count and then bring about the closed status.

    Regards
    Rob

  4. #24
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    Quote Originally Posted by Rob (SA) View Post
    ... I just need help with the code that will count and then bring about the closed status.
    Actually, that's one of the things that's a little confusing - you say you all you need help with is the code for counting the entries, but then in other posts you say you already have the code that counts the number of entries.

    I just want to make sure I'm not missing any details about your question that might be important.

  5. #25
    Join Date
    May 2007
    Location
    South Africa
    Posts
    175
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Hi,

    I understand.

    On my page the script counts the amount of entries that have been received per tournament.

    My challenge is I do not know how to do this on the script reflected below.

    Secondly the number - which is now 12 is the number that is critical (as the entries grow)

    The script I am trying to develop is thus something that will recognise that number and thus cause the OPEN and CLOSED effect.

    I hope this helps

  6. #26
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    so, your desired workflow looks like this:

    page 1 counts the number of entries.

    page 1 displays the number of entries.

    page 2 checks page 1 to get the count.

    page 2 uses the count to determine if a particular tournament is open or closed.

    ??

    if so, you should know that it will be complicated, inefficient, and unreliable. page 2 should check the database on its own, and open or close the tournament based on that.

  7. #27
    Join Date
    May 2007
    Location
    South Africa
    Posts
    175
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Hi,

    I will try explain as you have presented it:

    Page 2 - is the entryform and this is th epage where all data for the player is entered.This information is then sent to the Database (MySQL)


    Page 1 - is a page where the transaction (OPEN)(CLOSED) is to happen. This is in fact the first page as you will not be able to enter, press the (PAY NOW ) button if the tournament is (CLOSED). This page directs to the Page 2 on selction of the PAY NOW button.

    In this link (Page 1) you are normally directed to the payment option (Page 4) and then to the entry form (Page 2). The players will thus select page 1, be directed to the payment system, on payment then only can they enter (Page 2)

    Page 3 - is a page which shows all the entries and where a script is that currently counts the amount of entries per event and also lists the players that have enterd in alphabetical order per event. No addtional work is required on this page or on page 2. It is only the idea (EXAMPLE) of counting that I have presented to give you guys perhaps some idea of how the counting was happeing , so that you could think a way around the same process to happen on PAGE 1.

    The script I am looking for must thus be on page 1 and if it is done using a query then I need to make that query work for 30 differrent instances as their are only 30 tournaments due to method I have adopted here (Page 1) not being effecient, I agree (My knowledge of writting PHP has limited me here)..

    I hope this helps

    Regards
    Rob
    Last edited by Rob (SA); 10-26-2010 at 04:02 AM.

  8. #28
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    I see.

    It looks like the answers we've given ought to work with the way you have things set up. Post back if you have any problems. good luck

  9. #29
    Join Date
    May 2007
    Location
    South Africa
    Posts
    175
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Hi,

    Thanks for the replies.

    I am in need of help wit the script - the majority of our discussions is to understand what pages do - in context to my project.

    Please help with the script if you can

    Regards
    Rob

  10. #30
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    Bluewalrus and myself have given you quite a few suggestions and examples. I don't think you're lacking anything, as far a concept or coding goes.

    Have you tried out any of our examples? What further questions do you have?

Bookmarks

Posting Permissions

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