Hey, well i have a query at the top of my main page to pick random tuts but the way i had it i thought it was too plain so i added like 2 tables side by side both showing random tuts, but now what happens is the 1st table picks random tuts and the 2nd one nxt to it just coppies them so i have like 2 tables both picking the same tuts so i was wondering how i could like do 2 querys and get the left side to use one and the right to use another :s
Double Query
Started by Bl4ck-Vip3r, Mar 31 2007 08:41 AM
5 replies to this topic
#1
Posted 31 March 2007 - 08:41 AM
#2
Posted 31 March 2007 - 08:44 AM
can you post the code please, ill be more then willing to help,
including tables
including tables
#3
Posted 31 March 2007 - 09:08 AM
<?php
include "db.php";
$result = mysql_query("SELECT * from $mysql_table ORDER BY RAND()");
while($row = mysql_fetch_array($result)) {
echo "
<div id = 'Text' >
<table width ='100%'>
<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>
<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>
<tr>
<td>
<div align='left'>Description: ".$row['description']."</div></td>
<td>
<div align='left'>Description: ".$row['description']."</div></td>
</table>
</div>
";
}
?>
#4
Posted 31 March 2007 - 09:25 AM
before i look further, try something simple
create 2 files with your quires,
create the table,
then just
include('file1');
in left column
and
include('file 2');
in right column
as what your doing is for every result, print to identicle columns
create 2 files with your quires,
create the table,
then just
include('file1');
in left column
and
include('file 2');
in right column
as what your doing is for every result, print to identicle columns
Edited by curthard89, 31 March 2007 - 09:26 AM.
#5
Posted 31 March 2007 - 09:39 AM
Woo thanks lol
Is there a way to get colours to alternate? like the 1st row make the title x and the 2nd make it y?
#6
Posted 31 March 2007 - 09:50 AM
lol, yer, really easy way to do this...not many people know how easy it is
we simple use sumthing simple, use this
set up a class in your css file, one called odd and one called even.
then we will use this simple piece of script
$oddeven = "odd";
if($oddeven == "odd"){
$oddeven = "even";
} else {
$oddeven = "odd";
}
so with that
we put
<?php
include "db.php";
$result = mysql_query("SELECT * from $mysql_table ORDER BY RAND()");
$oddeven = "odd"; //making sure odd even is out of the while to begin with
while($row = mysql_fetch_array($result)) {
echo"
<tr class="$oddeven"> //specifiy the class of the alternating color
all other stuff here
";
//loop through results changing it between colours
if($oddeven == "odd"){
$oddeven = "even";
} else {
$oddeven = "odd";
}
}
?>
we simple use sumthing simple, use this
set up a class in your css file, one called odd and one called even.
then we will use this simple piece of script
$oddeven = "odd";
if($oddeven == "odd"){
$oddeven = "even";
} else {
$oddeven = "odd";
}
so with that
we put
<?php
include "db.php";
$result = mysql_query("SELECT * from $mysql_table ORDER BY RAND()");
$oddeven = "odd"; //making sure odd even is out of the while to begin with
while($row = mysql_fetch_array($result)) {
echo"
<tr class="$oddeven"> //specifiy the class of the alternating color
all other stuff here
";
//loop through results changing it between colours
if($oddeven == "odd"){
$oddeven = "even";
} else {
$oddeven = "odd";
}
}
?>
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users
