Jump to content

Criar ciclo for dentro de variavel


filipe1221
 Share

Recommended Posts

filipe1221

tenho este corpo de email

queria colocar um ciclo for/while dentro desta variável $html para rodar os dados da BD na tabela

$html = "
<table border='1' width='50%' align='center'>
<tr>
<td width='25%'><strong>Produto</strong></td>
<td width='25%'><strong>Cod</strong></td>
<td width='25%'><strong>Quatidade</strong></td>
<td width='25%'><strong>Unidade</strong></td>
</tr>
</table>
";

Obrigado

Edited by filipe1221
Link to comment
Share on other sites

filipe1221

Tentei isto mas nao resultou

$html = "
<table border='1' width='50%' align='center'>
<tr>
<td width='25%'><strong>Produto</strong></td>
<td width='25%'><strong>Cod</strong></td>
<td width='25%'><strong>Quatidade</strong></td>
<td width='25%'><strong>Unidade</strong></td>
</tr>
<tr>".
$res = mysql_query("select * from carrinho where id_utilisador='$id'");
 while($escrever=mysql_fetch_array($res)){
 $id_s=$escrever['id'];."
<td width='25%'><strong>";$id_s."</strong></td>
<td width='25%'><strong>".$id_s."</strong></td>
<td width='25%'><strong>".$id_s."</strong></td>
<td width='25%'><strong>".$id_s."</strong></td>
".}."</tr>
</table>
";
Edited by filipe1221
Link to comment
Share on other sites

HappyHippyHippo

achas que o código no teu segundo post faz algum sentido ?

$html = "
<table border='1' width='50%' align='center'>
 <tr>
   <th width='25%'><strong>Produto</strong></th>
   <th width='25%'><strong>Cod</strong></th>
   <th width='25%'><strong>Quatidade</strong></th>
   <th width='25%'><strong>Unidade</strong></th>
 </tr>";

$res = mysql_query("select * from carrinho where id_utilisador='$id'");
while($escrever=mysql_fetch_array($res))
{
 $html .= "
 <tr>
   <td width='25%'><strong>{$escrever['nome']}</strong></td>
   <td width='25%'><strong>{$escrever['codigo']}</strong></td>
   <td width='25%'><strong>{$escrever['quantidade']}</strong></td>
   <td width='25%'><strong>{$escrever['unidade']}</strong></td>
 </tr>"
}

$html .= "</table>";
IRC : sim, é algo que ainda existe >> #p@p
Link to comment
Share on other sites

E acho que já devias de largar o HTML3.2, já é coisa de século passado.

"[Os jovens da actual geração]não lêem porque não envolve um telecomando que dê para mirar e atirar, não falam porque a trapalhice é rainha e o calão é rei" autor: thoga31

Life is a genetically transmitted disease, induced by sex, with death rate of 100%.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.