<?php
include "db.php";
echo "<table width ='100%'>
<div id = 'Text'>";
$result = mysql_query("SELECT * from $mysql_table ORDER BY RAND() LIMIT 2");
while($row = mysql_fetch_array($result)) {
echo"
<td>
<div align='left'><strong><font color ='#FF0000'><a class = 'FootLink' href='tutorials.php?category=".$row['category']."&id=".$row['id']." '> ".$row['title']." </a>
</font></strong></div></td>
<tr>
<td>
<div align='left'> ".$row['description']."</div></td></tr>
"; // End of Template for the tutorials in a category.
} // End of grabbing information from database.
echo "</div></table>
";
?>
making tables stand side by side
Started by Bl4ck-Vip3r, Mar 31 2007 05:05 PM
4 replies to this topic
#1
Posted 31 March 2007 - 05:05 PM
i have a query pciking the rand tuts out of my db and i am displaying them at the top of the page but at the mo they stack ontop of eachother and i want them to go side by side how would i do this because if i add like another td and put the query in it then it picks the same 1. here the code
#2
Posted 31 March 2007 - 05:56 PM
<?php
include "db.php";
echo "
<div style=\"float: left\">
<table width ='100%'>
<div id = 'Text'>";
$result = mysql_query("SELECT * from $mysql_table ORDER BY RAND() LIMIT 2");
while($row = mysql_fetch_array($result)) {
echo"
<td>
<div align='left'><strong><font color ='#FF0000'><a class = 'FootLink' href='tutorials.php?category=".$row['category']."&id=".$row['id']." '> ".$row['title']." </a>
</font></strong></div></td>
<tr>
<td>
<div align='left'> ".$row['description']."</div></td></tr>
"; // End of Template for the tutorials in a category.
} // End of grabbing information from database.
echo "</div></table>
</div>
";
?>
try that
, what happened to my include file idea? lol
include "db.php";
echo "
<div style=\"float: left\">
<table width ='100%'>
<div id = 'Text'>";
$result = mysql_query("SELECT * from $mysql_table ORDER BY RAND() LIMIT 2");
while($row = mysql_fetch_array($result)) {
echo"
<td>
<div align='left'><strong><font color ='#FF0000'><a class = 'FootLink' href='tutorials.php?category=".$row['category']."&id=".$row['id']." '> ".$row['title']." </a>
</font></strong></div></td>
<tr>
<td>
<div align='left'> ".$row['description']."</div></td></tr>
"; // End of Template for the tutorials in a category.
} // End of grabbing information from database.
echo "</div></table>
</div>
";
?>
try that
#3
Posted 01 April 2007 - 03:18 AM
it worked great, but then i tried to make both sides scroll upward and it made my box expand really big :S so i gave up with the marquee and decided to have only the titles side by side ie
[tut1] [tut2] [tut3] [tut4] ...
and cheers
lol 1 last question, any ideas how i can make it so after every5 tutorials or at the end of them all, it like has a break and echos an advert like p2l used to do so eg.
after every 5
[1]
[2]
[3]
[4]
[5]
[Advert]
or after them all so if i didnt have 5 or if it was an evan number
[1]
[2]
[3]
[4]
[5]
[6]
[advert]
Nm about at the end one, ill just put it after te while lol, and for the after 5 1 should i do like
loop until mysqlnumberofrows {
query limit 5
{
}
advert code
}
[tut1] [tut2] [tut3] [tut4] ...
and cheers
after every 5
[1]
[2]
[3]
[4]
[5]
[Advert]
or after them all so if i didnt have 5 or if it was an evan number
[1]
[2]
[3]
[4]
[5]
[6]
[advert]
Nm about at the end one, ill just put it after te while lol, and for the after 5 1 should i do like
loop until mysqlnumberofrows {
query limit 5
{
}
advert code
}
Edited by Bl4ck-Vip3r, 01 April 2007 - 04:23 AM.
#4
Posted 01 April 2007 - 05:55 AM
this is of the top of my head here,
im asuming yo will need to do a row count on tutorials,
then for every 5 it loops through printing an advert
ill see what i can find
im asuming yo will need to do a row count on tutorials,
then for every 5 it loops through printing an advert
ill see what i can find
#5
Posted 01 April 2007 - 12:19 PM
<?php
$i = 1;
$advert_num = 5;
while($t = mysql_fetch_array($query)){
// Echo your tutorial data like normal
if($i == $advert_num){
// Echo advertisement
$i = 1; // Reset the variable
}
else $i++;
}
?>
Simple as that.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users
