Jump to content


Photo

Output order


  • Please log in to reply
10 replies to this topic

#1 miligraf

miligraf
  • Members
  • PipPipPip
  • Advanced Member
  • 74 posts

Posted 05 May 2006 - 04:26 AM

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

<?
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> 
  <?
}
?>

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

gracias.

#2 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 05 May 2006 - 04:34 AM

ummm.... i don't get it. are you asking an html question? as in, you want it formatted on the screen differently?
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#3 miligraf

miligraf
  • Members
  • PipPipPip
  • Advanced Member
  • 74 posts

Posted 05 May 2006 - 07:04 AM

i get the output like this:

affiliate1
affiliate2
affiliate3

and i want it to be:

affiliate1 affiliate2 affiliate3

#4 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 05 May 2006 - 02:34 PM

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.

Info: PHP Manual


#5 miligraf

miligraf
  • Members
  • PipPipPip
  • Advanced Member
  • 74 posts

Posted 05 May 2006 - 05:38 PM

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

#6 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 05 May 2006 - 06:12 PM

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.

Info: PHP Manual


#7 miligraf

miligraf
  • Members
  • PipPipPip
  • Advanced Member
  • 74 posts

Posted 05 May 2006 - 06:58 PM

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 :(

#8 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 05 May 2006 - 07:57 PM

take out the <br> if you want it ALL on one line.

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

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

that's what you want, right?

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

<table><tr>
<?
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];
?>
<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>
<?
}
?>
</tr></table>
[/quote]
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#9 miligraf

miligraf
  • Members
  • PipPipPip
  • Advanced Member
  • 74 posts

Posted 05 May 2006 - 08:34 PM

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.

#10 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 05 May 2006 - 10:07 PM

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.

<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>

I hope that makes sense.

Info: PHP Manual


#11 miligraf

miligraf
  • Members
  • PipPipPip
  • Advanced Member
  • 74 posts

Posted 05 May 2006 - 10:32 PM

thx a lot ober, it worked as i wanted it! and thx for all the ones who helped too.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users