Jump to content

Recommended Posts

Hi everyone, greetings from Brazil.

I am an average php coder, much more a designer than an programer, and i am in a looper trouble..

Can anyone try to help me?

 

Here is my code:

 

            <table border="1">
            <tr>
                <?php //pega cada uma das operadoras do campo operadoras
                $operadoras = $opers_trazOperadoras ;
                $logos = explode(",",$operadoras);
                $x = 0 ;
                foreach ($logos as $v)
                {
                    mysql_select_db($database_webroker, $webroker);
                    $query_trazLogoOperadora = "SELECT * FROM tb_operadora WHERE tb_operadora.id_operadora = " . $v ;
                    $trazLogoOperadora = mysql_query($query_trazLogoOperadora, $webroker) or die(mysql_error());
                    $row_trazLogoOperadora = mysql_fetch_assoc($trazLogoOperadora);
                    $totalRows_trazLogoOperadora = mysql_num_rows($trazLogoOperadora);
                ?>
                        <td><img src="http://www.we-broker.com.br/admin/imagens_upload/<?php echo $row_trazLogoOperadora['logo']; ?>">
                        <?php do { ?>
                            <?php
                            } while ($x++ < 4); {
                            echo $x ;?>
                                </td></tr><tr>
                            <?php } $x = 0 ;
                        }
                  ?>
            </table>

 

The URL for this code is: http://valsegs.we-broker.com.br/operadorasPATO.php

Tks!

Link to comment
https://forums.phpfreaks.com/topic/291108-while-loop-inside-a-foreach/
Share on other sites

You didn't ask a question!!

 

This code:

 

<?php do { ?>
<?php
 } while ($x++ < 4); {
echo $x ;?>
 </td></tr><tr>
  <?php } $x = 0 ;
  }

is ridiculous.

 

Try this - note that I turned on error checking so you can see what error you have:

 

<?php
session_start();
error_reporting(E_ALL | E_NOTICE);
ini_set('display_errors', '1');
//
do
{
}
while ($x++ < 4);
{
 echo $x;
 echo "</td></tr><tr>";
}
$x = 0 ;
}

You don't need all those php on and php off tags.

You don't need a do statement with no contents

You don't put a semi at the end of the while line - it leaves you with no contents again.

 

I think you want:

 

<?php
session_start();
error_reporting(E_ALL | E_NOTICE);
ini_set('display_errors', '1');
//
while ($x = 0;$x < 4; $x++)
{
 echo "<tr><td>$x</td></tr>";
}

This will give you a set of 4 table rows with one cell counting from 0 to 3.

Well, like I said, I am more designer than coder, so I thank you all for the answers.

The question that i didn´t aks is: What i am doing wrong, because it is not working.

 

Now, i´ll try all your suggestions and let´s see what happens!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

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.