Jump to content

Output order


miligraf

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.
Link to comment
https://forums.phpfreaks.com/topic/9106-output-order/
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
Link to comment
https://forums.phpfreaks.com/topic/9106-output-order/#findComment-33648
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]
Link to comment
https://forums.phpfreaks.com/topic/9106-output-order/#findComment-33700
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.
Link to comment
https://forums.phpfreaks.com/topic/9106-output-order/#findComment-33724
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.
Link to comment
https://forums.phpfreaks.com/topic/9106-output-order/#findComment-33752
Share on other sites

Archived

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

×
×
  • 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.