miligraf Posted May 5, 2006 Share Posted May 5, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/9106-output-order/ Share on other sites More sharing options...
.josh Posted May 5, 2006 Share Posted May 5, 2006 ummm.... i don't get it. are you asking an html question? as in, you want it formatted on the screen differently? Quote Link to comment https://forums.phpfreaks.com/topic/9106-output-order/#findComment-33490 Share on other sites More sharing options...
miligraf Posted May 5, 2006 Author Share Posted May 5, 2006 i get the output like this:affiliate1affiliate2affiliate3and i want it to be:affiliate1 affiliate2 affiliate3 Quote Link to comment https://forums.phpfreaks.com/topic/9106-output-order/#findComment-33502 Share on other sites More sharing options...
ober Posted May 5, 2006 Share Posted May 5, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/9106-output-order/#findComment-33577 Share on other sites More sharing options...
miligraf Posted May 5, 2006 Author Share Posted May 5, 2006 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 buttonIn: | 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 Quote Link to comment https://forums.phpfreaks.com/topic/9106-output-order/#findComment-33648 Share on other sites More sharing options...
ober Posted May 5, 2006 Share Posted May 5, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/9106-output-order/#findComment-33664 Share on other sites More sharing options...
miligraf Posted May 5, 2006 Author Share Posted May 5, 2006 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 :( Quote Link to comment https://forums.phpfreaks.com/topic/9106-output-order/#findComment-33680 Share on other sites More sharing options...
.josh Posted May 5, 2006 Share Posted May 5, 2006 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 3In: | 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] Quote Link to comment https://forums.phpfreaks.com/topic/9106-output-order/#findComment-33700 Share on other sites More sharing options...
miligraf Posted May 5, 2006 Author Share Posted May 5, 2006 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 3In: | Out: In: | Out: In: | Out:affiliate 4 affiliate 5 affiliate 6In: | Out: In: | Out: In: | Out:affiliate 7 affiliate 8 affiliate 9In: | Out: In: | Out: In: | Out:gracias. Quote Link to comment https://forums.phpfreaks.com/topic/9106-output-order/#findComment-33724 Share on other sites More sharing options...
ober Posted May 5, 2006 Share Posted May 5, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/9106-output-order/#findComment-33752 Share on other sites More sharing options...
miligraf Posted May 5, 2006 Author Share Posted May 5, 2006 thx a lot ober, it worked as i wanted it! and thx for all the ones who helped too. Quote Link to comment https://forums.phpfreaks.com/topic/9106-output-order/#findComment-33759 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.