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
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
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.
Link to comment
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 :(
Link to comment
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
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
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
Share on other sites

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.