Page 6 of 6 FirstFirst ... 456
Results 51 to 58 of 58

Thread: IF / THEN statement using data from MySQL

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

    Default

    Hi,

    The Open (blue) and Closed (red) is the visual effect desured as the Pay now button only shows on Open (blue).

    I have included the PHP below of what I have done for the first couple of rows.

    Each one is slightly different as I am trying different options to work.

    I have put a new column in "Total Entered" so that I can see the total amout of players entering and then hopefully also confirm that the scipt we are using infact gets the value required.

    At this stage I am not sure it is getting the correct value or whether it gets the value at all.

    Regards
    Rob

    PHP Code:
    </style>
    </head>

    <body>
    <table id="customers">
    <tr class="th">
    <td> </td>
    <div><font style="font-size:16px" color="#5A6A83" face="Arial">UPCOMING TOURNAMENTS ARE LISTED BELOW</font></div></button>
    </tr>

    <tr>
      <th>HOST</th>
      <th>GOLF COURSE</th>
      <th>DATE</th>
      <th>DAY</th>
      <th>TOTAL ENTERED</th>
      <th>ENTRY STATUS</th>
      <th>ENTER</th>
      
      </tr>

    <tr class="alt2">
    <td>HETTIE ELS</td>
    <td>KEMPTON PARK</td>
    <td>05 JANUARY 2011</td>
    <td>WEDNESDAY</td>
    <td>*</td>
    <?php

    $connect 
    mysql_connect("localhost""e****_****""*****") or
    die (
    "Hey loser, check your server connection.");
    mysql_select_db("e****_Members");

    // name of tournament you wish to count entries from
    // maybe from a form entry?
    $tournament 'KEMPTON PARK - 05/01/2011';
    //  count the total entries with that tournament name
    $c mysql_query ("SELECT count(*) from `_Form_Nr_4` WHERE `I_wish_to_play` = '$tournament'");
    // add these two lines here:
    $c mysql_fetch_row($c);
    $c $c[0];
    $c $_GET['v']; 

    // these lines take the result (a mysql resource)
    // and turn it into an array - something we can actually use
    // in php. The entry count is in the first index ( index 0 ). 
    $openORclosed $c >= 'Closed' 'Open';
    echo 
    "<td>";
    if (
    $openORclosed != 'Open') {

    ?>
    <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 - KEMPTON PARK - 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">
    <?php 
    } else {
    echo 
    $openORclosed;
    }
    ?>
    </tr>

    <tr class="alt">
    <td>THE GOLF SCHOOL OF EXCELLENCE</td>
    <td>GLENDOWER</td>
    <td>27 FEBRUARY 2011</td>
    <td>?</td>
    <td>*</td>

    <?php
    // name of tournament you wish to count entries from
    // maybe from a form entry?
    $tournament 'GLENDOWER - 27/02/2011';
    //  count the total entries with that tournament name
    $c mysql_query ("SELECT count(*) from `_Form_Nr_4` WHERE `I_wish_to_play` = '$tournament'");
    // add these two lines here:
    $c mysql_fetch_row($c);
    $c $c[0];
    $c $_GET['v']; 

    // these lines take the result (a mysql resource)
    // and turn it into an array - something we can actually use
    // in php. The entry count is in the first index ( index 0 ). 
    $openORclosed $c >= 'Closed' 'Open';
    echo 
    "<td>";
    if (
    $openORclosed != 'Open') {
    ?>

    <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">
    <?php 
    } else {
    echo 
    $openORclosed;
    }
    ?>

    </tr>



    <tr class="alt2">
    <td>?</td>
    <td>GARDENER ROSS</td>
    <td>27 MARCH 2011</td>
    <td>?</td>
    <td>*</td>
    <?php
    // name of tournament you wish to count entries from
    // maybe from a form entry?
    $tournament 'GARDENER ROSS - 27/03/2011';
    //  count the total entries with that tournament name
    $c mysql_query ("SELECT count(*) from `_Form_Nr_4` WHERE `I_wish_to_play` = '$tournament'");
    // add these two lines here:
    $c mysql_fetch_row($c);
    if(
    $c >= 0){
    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 - 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>

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

    Default

    If I change the < or > sign in the
    PHP Code:
    if($c >= 1
    but not the value the I can get the Open (Blue) or Closed (Red) to change as is veiwed on the l ink

    That is th eonly change I make to get this change hence my belief that the value of 80 is not being read.

    Regards
    Rob

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

    Default

    I recommend knowing the data you are working with before working with it.

    echo $c; and see if the value is what it should be.

    Also this $c = $_GET['v']; shouldn't be there anymore that was an example to demonstrate the c value was processing correctly.
    Corrections to my coding/thoughts welcome.

  4. #54
    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 bluewalrus View Post
    PHP Code:
    $quey1="select surname, i_wish_to_play  from _Form_Nr_3 ORDER BY `i_wish_to_play` ASC, `surname` ASC "
    add any other columns you need. Not sure if mysql requires the '' around columns.
    It does not require single quotes ( ' ). Using them will mess things up. It is good practice, however, to use backticks ( ` ) around column names to distinguish them from normal SQL keywords (an unlikely confusion, but good practice anyway).

    I don't know about using ORDER BY on both columns. At best, the first one wouldn't matter (the second one would override it), and at worst, it might cause an error.

    Do you know for certain that you are getting a result from your query?

    Try echo $c
    Edit: bluewalrus beat me to it
    or var_dump($c); and see what it returns. If nothing, try echo mysql_error();

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

    Default

    Hi Guys,

    Thanks for the replies and guidance into writting improved script.

    The query is something I have used succesfully on other pages - however I will endevour to make improvements.

    In terms of knowing which data I am working with - I am sure which data it is as i have recovered similar data on a page which is veiwable at this link

    I will try your other proposals.

    Regards
    Rob

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

    Default

    Hi,

    I have included the - echo $c; and it does pick up the value as per the MySQL database.

    In my file, the value should appear between <td>*</td> however this would then be before the value of $c is determined.

    Please could you advise how I can get the value of $c to appear under this column in the table?


    PHP Code:
    <tr class="alt2"
    <
    td>HETTIE ELS</td
    <
    td>KEMPTON PARK</td
    <
    td>05 JANUARY 2011</td
    <
    td>WEDNESDAY</td
    <
    td>*</td

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

    Default

    Do the query first then

    PHP Code:
    <tr class="alt2"> 
    <td>HETTIE ELS</td> 
    <td>KEMPTON PARK</td> 
    <td>05 JANUARY 2011</td> 
    <td>WEDNESDAY</td> 
    <td><?php echo $c;?></td>
    Corrections to my coding/thoughts welcome.

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

    Default

    Hi,

    Thanks - some progress - this effectively doe sthe task of putting the $c value into the column but now all the columns are jumbled - that is the order changed.

    It is probably because I have put something in th ewrong place - can you advise that the "Pay Now" button appears at the end.

    PHP Code:
    <tr class="alt2">
    <?php

    $connect 
    mysql_connect("localhost""e****_r***""*****") or
    die (
    "Hey loser, check your server connection.");
    mysql_select_db("eghfya_Members");

    // name of tournament you wish to count entries from
    // maybe from a form entry?
    $tournament 'KEMPTON PARK - 05/01/2011';
    //  count the total entries with that tournament name
    $c mysql_query ("SELECT count(*) from `_Form_Nr_4` WHERE `I_wish_to_play` = '$tournament'");
    // add these two lines here:
    $c mysql_fetch_row($c);
    $c $c[0];

    // these lines take the result (a mysql resource)
    // and turn it into an array - something we can actually use
    // in php. The entry count is in the first index ( index 0 ). 
    $openORclosed $c >= 'Closed' 'Open';
    echo 
    "<td>";

    if (
    $openORclosed != 'Open')
    {
    ?>
    <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 - KEMPTON PARK - 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">

    <?php 
    } else {
    echo 
    $openORclosed;
    }
    ?>

    <td>HETTIE ELS</td>
    <td>KEMPTON PARK</td>
    <td>05 JANUARY 2011</td>
    <td>WEDNESDAY</td>
    <td><?php echo $c;?></td>
    </tr>

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
  •