CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2008

    for loop using the variable count

    im using PHP & MYSQL

    MOD still dont get it

    i searched on the net and found a sql function SELECT COUNT,

    how can i use it and used its variable in a FOR LOOP

    again this is my code

    PHP Code:

    $result mysql_query ("SELECT date, invoice_no, customer, address, business_style, tin, total_sales, tax, total_amount, prepared_by, approved_by, released_by
                            FROM cash_invoice AS ci
                            WHERE ci.invoice_no = '

    $row mysql_fetch_array($result))
    $date $row["date"];
    $invoice_no $row["invoice_no"];
    $customer $row["customer"];
    $address $row["address"];
    $business_style $row["business_style"];
    $tin $row["tin"];
    $total_sales $row["total_sales"];
    $tax $row["tax"];
    $total_amount $row["total_amount"];
    $prepared_by $row["prepared_by"];
    $released_by $row["released_by"];
    $approved_by $row["approved_by"];
    $pdf=new FPDF();
    //Arial bold 15
    //Document Number
    $prod ="SELECT p.description, ip.qty, ip.unit_price, ip.total, ip.invoice_no
                        FROM invoice_products as ip
                        LEFT JOIN product as p on p.prod_id = ip.prod_id
                        LEFT JOIN cash_invoice as ci ON ci.invoice_no = ip.invoice_no
                        WHERE ip.invoice_no='

    //New Line
    //Arial bold 15

    Last edited by PeejAvery; January 6th, 2009 at 07:09 AM. Reason: Added PHP tags.

  2. #2
    PeejAvery's Avatar
    PeejAvery is offline Super Moderator Power Poster
    Join Date
    May 2002

    Re: for loop using the variable count

    Rather than using SELECT COUNT which is having a MySQL return the number of rows, why don't you just use mysql_num_rows(). This will use PHP to count the returned rows right into a PHP variable.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  3. #3
    Join Date
    Dec 2008

    Re: for loop using the variable count

    got it MOD! tnx!

Posting Permissions

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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.