Link to home
Start Free TrialLog in
Avatar of Amita Singh
Amita SinghFlag for India

asked on

while loop in html mail format

i want my record in loop but when i use while loop it fetch 5 records but in my db 6 records. and i want number in list (like 1 ,2...) when i use $i= 1; and $i++ code show error. i don't fine where i wrong.
$i =1;
		while($invoicedata = mysql_fetch_array($invoicesql)){
			echo "<pre>";
			print_r($invoicedata);
		$htmlContent .= '<tr>
			<td style="border: 1px solid #ccc; line-height: 22px; padding: 2px; width: 20%;">1</td>
			<td style="text-align:center; border: 1px solid #ccc; line-height: 22px; padding: 2px; width: 60%;" >'.$invoicedata['item_name'].'</td>
			<td style="border: 1px solid #ccc; line-height: 22px; padding: 2px; width: 20%;text-align:right;">'.$invoicedata['item_price'].'</td>
			
		</tr>';
		$i++;
		}

Open in new window

Avatar of Ganesh Anand
Ganesh Anand
Flag of Bahrain image

May be the comment added will help:

$i =1;
            while($invoicedata = mysql_fetch_array($invoicesql)){
                  echo "<pre>";

  echo "<tr><td>".($pre['item_name','item_price'])."</td></tr>";
}
                  print_r($invoicedata);
            $htmlContent .= '<tr>
                  <td style="border: 1px solid #ccc; line-height: 22px; padding: 2px; width: 20%;">1</td>
                  <td style="text-align:center; border: 1px solid #ccc; line-height: 22px; padding: 2px; width: 60%;" >'.$invoicedata['item_name'].'</td>
                  <td style="border: 1px solid #ccc; line-height: 22px; padding: 2px; width: 20%;text-align:right;">'.$invoicedata['item_price'].'</td>
                  
            </tr>';
            $i++;
            }
Avatar of Amita Singh

ASKER

Thanx for Reply,

its not work. my code is.
$i =1;
		while($invoicedata = mysql_fetch_array($invoicesql)){
			
		$htmlContent .= '<tr>
			<td style="border: 1px solid #ccc; line-height: 22px; padding: 2px; width: 20%;">1</td>
			<td style="text-align:center; border: 1px solid #ccc; line-height: 22px; padding: 2px; width: 60%;" >'.$invoicedata['item_name'].'</td>
			<td style="border: 1px solid #ccc; line-height: 22px; padding: 2px; width: 20%;text-align:right;">'.$invoicedata['item_price'].'</td>
			
		</tr>';
		$i++;
		}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of ste5an
ste5an
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thank you Stefan,
i found my error. its work now perfect.
Thank you both of you for helping me.