Jump to content

Archived

This topic is now archived and is closed to further replies.

miligraf

Output order

Recommended Posts

I have this code for some affiliates thing, it shows all of them:

[code]<?
include "connect.php";

$result = mysql_query("SELECT * FROM affiliates ORDER BY id");
while($row = mysql_fetch_row($result))
    {
        $id = $row[0];
        $countout = $row[1];
        $countin = $row[2];
        $ws_name = $row[3];
        $ws_link = $row[4];
        $ws_button = $row[5];
?>
<div align="center"><a href="afiliado.php?outid=<?php echo $id; ?>" target="_blank">
  <img src="<?php echo $ws_button; ?>" width=88 height=31 alt="<?php echo $ws_name; ?>" border="0"></a>
  <br>
  <span class='style20 Estilo3'>Entraron:</span> <?php echo "<span class='style20 Estilo3'> $countin </span>";?> | <span class='style20 Estilo3'>Salieron:</span> <?php echo "<span class='style20 Estilo3'> $countout </span>";?></div>
  <?
}
?>[/code]

the thing is that it shows all of them in one column, i want it so it shows them in a row.

gracias.

Share this post


Link to post
Share on other sites
ummm.... i don't get it. are you asking an html question? as in, you want it formatted on the screen differently?

Share this post


Link to post
Share on other sites
i get the output like this:

affiliate1
affiliate2
affiliate3

and i want it to be:

affiliate1 affiliate2 affiliate3

Share this post


Link to post
Share on other sites
Well... you have a div in there plus a <br>. You may have to take one or both out to get it to stay on one line.

Share this post


Link to post
Share on other sites
that div just makes in centered but it doesnt affect it so that it will show only 1 column, the <br> is for getting the In and Out clicks in the next line:

affiliate 1 button
In: | Out:

ive noticed that when you retreive information from a table, it always puts it in a single column and not in rows...i want to change this.

thx

Share this post


Link to post
Share on other sites
Putting a div around a line of data will put each on a seperate line, creating a column. You can open the div before the loop and close it after the loop is done to center the data.

Share this post


Link to post
Share on other sites
ok, i deleted the div and it looks like this:

[a href=\"http://www.miligraf.com/web/afiliados/afiliados.php\" target=\"_blank\"]http://www.miligraf.com/web/afiliados/afiliados.php[/a]

when i put the div, it looks the same but just centered :(

Share this post


Link to post
Share on other sites
take out the <br> if you want it ALL on one line.

however, I think it looks like you want it to do this:

[code]
affiliate 1  affiliate 2  affiliate 3
In: | Out:  In: | Out:    In: | Out:
[/code]

that's what you want, right?

add the things in bold:
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]

[b]<table><tr>[/b]
<?
include "connect.php";
$result = mysql_query("SELECT * FROM affiliates ORDER BY id");

while($row = mysql_fetch_row($result))
{
$id = $row[0];
$countout = $row[1];
$countin = $row[2];
$ws_name = $row[3];
$ws_link = $row[4];
$ws_button = $row[5];
?>
[b]<td>[/b]
<div align="center"><a href="afiliado.php?outid=<?php echo $id; ?>" target="_blank">
<img src="<?php echo $ws_button; ?>" width=88 height=31 alt="<?php echo $ws_name; ?>" border="0"></a>
<br>
<span class='style20 Estilo3'>Entraron:</span> <?php echo "<span class='style20 Estilo3'> $countin </span>";?> | <span class='style20 Estilo3'>Salieron:</span> <?php echo "<span class='style20 Estilo3'> $countout </span>";?></div>
[b]<td>[/b]
<?
}
?>
[b]</tr></table>[/b]
[/quote]

Share this post


Link to post
Share on other sites
you got me Crayon, but they all keep appearing in one line...its not like if they dont have more space they will appear in the next line/row. i tried different things but they kep appearing in same row.

lets say theres only space for 3 in a row/line, so they would have to appear like this but they dont, they keep appearing in the same row/line:

affiliate 1 affiliate 2 affiliate 3
In: | Out: In: | Out: In: | Out:

affiliate 4 affiliate 5 affiliate 6
In: | Out: In: | Out: In: | Out:

affiliate 7 affiliate 8 affiliate 9
In: | Out: In: | Out: In: | Out:

gracias.

Share this post


Link to post
Share on other sites
If you want to set a limit on the number to use before it goes to the next line, you'll have to include a counter and then close the <tr> and then reopen one.

[code]<table>
<?
include "connect.php";
$result = mysql_query("SELECT * FROM affiliates ORDER BY id");
$rowcount = 0;
while($row = mysql_fetch_row($result))
{
if($rowcount == 0)
     echo "<tr>"; // start row
$id = $row[0];
$countout = $row[1];
$countin = $row[2];
$ws_name = $row[3];
$ws_link = $row[4];
$ws_button = $row[5];
?>
<td>
<div align="center"><a href="afiliado.php?outid=<?php echo $id; ?>" target="_blank">
<img src="<?php echo $ws_button; ?>" width=88 height=31 alt="<?php echo $ws_name; ?>" border="0"></a>
<br>
<span class='style20 Estilo3'>Entraron:</span> <?php echo "<span class='style20 Estilo3'> $countin </span>";?> | <span class='style20 Estilo3'>Salieron:</span> <?php echo "<span class='style20 Estilo3'> $countout </span>";?></div>
<td>
if(++$rowcount == 3) // increment and compare to max row count
{
     echo "</tr>";  // close row
    $rowcount = 0;  // reset counter
}
<?
}
if($rowcount < 3)
   echo "</tr>";  // just to have valid code
?>
</table>[/code]

I hope that makes sense.

Share this post


Link to post
Share on other sites
thx a lot ober, it worked as i wanted it! and thx for all the ones who helped too.

Share this post


Link to post
Share on other sites

×

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.