1

I have a variable ($email_body) which has the body of an email in it. just before this variable i am running this PHP:

$sql3="SELECT * from billing_pdf_archive where sequence = '".$result["sequence"]."' ";
$rs3=mysql_query($sql3,$conn);
while($result3=mysql_fetch_array($rs3))
{
    $invoices_list_data[] = $result3["invoice_number"];
}
$invoices_list = implode('<br>',$invoices_list_data);

i want to make it list all the rows found (invoice_number column) in the $email_body variable

so i have tried:

$email_body = $invoices_list;

but its only displaying one row

how can i do this?

6
  • I don't see $email_body in your code :) Commented Oct 11, 2013 at 11:20
  • $invoices_list variable already has all the invoice_number found in the table. Commented Oct 11, 2013 at 11:21
  • no it doesn't - thats why i am having a problem Commented Oct 11, 2013 at 11:22
  • @user2710234 have you checked your query, does it return result(s)? Commented Oct 11, 2013 at 11:24
  • if i echo $invoices_list it returns one row but if i run the query in the database it returns more Commented Oct 11, 2013 at 11:25

1 Answer 1

1

I think your problem probably lies in debugging the query. First try and debug your code step by step.

$sql3="SELECT * from billing_pdf_archive where sequence = '".$result["sequence"]."' ";

echo $sql3;

The above should output your sql statement. Something like

SELECT * FROM billing_pdf_archive WHERE sequence = 'val'

Try connecting to your database and running it in mysql query browser. Does it return multiple results? If so continue to next step.

$rs3=mysql_query($sql3,$conn);
while($result3=mysql_fetch_array($rs3))
{
    var_dump($result3);
    $invoices_list_data[] = $result3["invoice_number"];
}

The above should output values. If it does then you are on your way to next step. Your implode should join the values up.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.