SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Wizard
    Join Date
    Dec 2004
    Location
    At My Desk!!
    Posts
    1,642
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    End of a while loop?

    I want to add a button to the last table entry that my while loop pulls out?

    What code can i use to do this?

    thanks in advance
    "Am I the only one doing ASP.NET in Delphi(Pascal)?"

  2. #2
    SitePoint Addict
    Join Date
    Apr 2001
    Location
    Michigan
    Posts
    284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you could show us some code it would help

  3. #3
    SitePoint Wizard
    Join Date
    Dec 2004
    Location
    At My Desk!!
    Posts
    1,642
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    here is my code, the form at the bottom is the button that i want displayin after the lsat table has been displayed:

    PHP Code:
    <?php



    $Connect 
    mysql_connect('localhost''***''***');

    mysql_select_db('shadesofjapan'$Connect);

    if (
    $_POST['RemoveItem'] == TRUE)
        {
        
            
    $Result mysql_query("DELETE FROM shoppinglist WHERE AutoId ='" $AutoIdForm "'") or die (mysql_error);
        
        }
        
            if (
    $_POST['RemoveItem'] == TRUE AND $Result == TRUE)
            {
                
    ?>
                <script type="text/javascript">
                alert ("Item Successfully Removed")
                </script>
                <?php
            
    }

    $Result mysql_query("SELECT AutoId, ProductName, Finish, Size, Price, Quantity FROM shoppinglist WHERE UserId = '" $_SESSION['UserId'] . "'") or die('Error: '.mysql_error()); 


    if (
    mysql_num_rows($Result) != 0)
    {

                        


        while (
    $MyRow mysql_fetch_array($Result))
        {
            
    $AutoId $MyRow['AutoId'];
            
    $ProductName $MyRow['ProductName'];
            
    $Finish $MyRow['Finish'];
            
    $Size $MyRow['Size'];
            
    $Price $MyRow['Price'];
            
    $Quantity $MyRow['Quantity'];
            
            
            
    $Result1 mysql_query("SELECT sum(Price)as Price FROM shoppinglist WHERE UserId = '" $_SESSION['UserId'] . "'");
            while (
    $MyRow1 mysql_fetch_array($Result1))
            {
            
    $TotalPrice $MyRow1['Price'];
            
    $EntryPrice number_format($TotalPrice2);
            }
            
            
    ?>
              <form name="form1" method="post" action="">
              <table width="607" height="197"  border="0">
                <tr>
                  <td><h2>Product Name: <font color="#FF0000"><? echo $MyRow['ProductName']; ?></font></h2> </td>
                </tr>
                <tr>
                  <td><h2>Finish: <font color="#FF0000"><? echo $MyRow['Finish']; ?></font></h2> </td>
                </tr>
                <tr>
                  <td><h2>Size: <font color="#FF0000"><? echo $MyRow['Size']; ?></font></h2> </td>
                </tr>
                <tr>
                  <td><h2>Price: &pound;<font color="#FF0000"><? echo $MyRow['Price']; ?></font></h2> </td>
                </tr>
                <tr>
                  <td><h2>Quantity: <font color="#FF0000"><? echo $MyRow['Quantity']; ?></font></h2> </td>
                </tr>
                <tr>
                  <td height="83"><div align="center">
                       <input type="submit" name="RemoveItem" value="Remove Item">
                </div></td>
                </tr>
              </table>
              <p>
               <input type='hidden' name='AutoIdForm' value='<? echo $AutoId?>' />
           

              </form>
            
    <?php
    $AutoIdForm 
    $_POST['AutoIdForm']; 
        
        }
        
            echo 
    $EntryPrice;            
    }
    else
    {
        echo
    "<center><h2>You have not selected any items to order</h2></center>";
    }


        
    ?>





    </div>
    <div id="Layer5" style="position:absolute; left:196px; top:292px; width:607px; height:26px; z-index:5">
      <div align="center">----------------------------------------------------------------------</div>
    </div>
    <div id="Layer6" style="position:absolute; left:2px; top:2px; width:800px; height:167px; z-index:6"><img src="images/mainlogo.png" width="800" height="167"></div>
    <div id="Layer7" style="position:absolute; left:192px; top:611px; width:607px; height:25px; z-index:7"> 
    <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
      <div align="center">
      <input type="hidden" name="cmd" value="_xclick">
      <input type="hidden" name="business" value="shadesofjapan@webnoob.com">
      <input type="hidden" name="item_name" value="Items">
      <input type="hidden" name="amount" value="<? echo $EntryPrice?>">
      <input type="hidden" name="no_note" value="1">
      <input type="hidden" name="currency_code" value="GBP">
      <input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but23.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
      </div>
    </form>

    </div>



    </body>
    </html>
    "Am I the only one doing ASP.NET in Delphi(Pascal)?"

  4. #4
    SitePoint Enthusiast michelangelo's Avatar
    Join Date
    May 2005
    Posts
    75
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use mysqlnumrows to find out how many rows there will be, and put a $counter++ in your main while loop. When "if ($counter == $number_of_rows)" then you know it's the last row that's going to be output.


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
  •