Page 1 of 1
array that organises query output in sequences..
Posted: Tue Dec 06, 2005 5:57 am
by paulng
with reference fo the following topic: display database record at random and ranking then by order.
viewtopic.php?t=35433&highlight=
I have two tables and I would like to display the output of the code reffered in the topic above as shown in the table below.
Here is my tables and how I would like to organise my result:
Code: Select all
<table width="600" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><div align="center">first result </div></td>
<td><div align="center">second result </div></td>
</tr>
</table>
<br>
<table width="600" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><div align="center">the rest on the result to be displyed here repetedly</div></td>
</tr>
</table>
can anyone help? if you need further explain please post a message and I will try to elaborate.
Posted: Tue Dec 06, 2005 9:55 am
by pickle
So you've figured out how to retrieve the data, and you're just wondering how to display it? Something like this should work:
Code: Select all
echo "<table><tr>";
while($row = mysql_fetch_assoc($result))
{
echo <<<CELL
<td>
$row['first_cell']
</td>
CELL;
}
echo "</tr></table>";
Posted: Tue Dec 06, 2005 10:14 am
by paulng
pickle,
Thanks for your reply, but I figured you didnt understand my question, I posted a question for help for a query that was displying it output as well as ranking them (e.g 1 to 10). let say if item1 is ranked 2 item2 is ranked 5 and item6 is ranked 5 item7 is ranked 2
this will output :
item 1 && item7 :random
item2
item6
this was achieved in the code from the previous posted question, however it is easy to display these out put using one cell. if you pay attention to the table I provided where the first item of the array will display in the first cell , the second item in the second cell and the rest in the row below.
not sure if it is now clear on what i want to achieve....Thanks!
Posted: Tue Dec 06, 2005 11:57 am
by Grim...
Okay, that's
less clear to me now

Posted: Tue Dec 06, 2005 12:16 pm
by Burrito
so if they are ranked the same, you want to display them randomly?
if so, you could put the identical rankings into an array and then use
array_rand() to grab them out randomly.
Posted: Mon Dec 12, 2005 4:57 am
by paulng
all I want is to a type of recordset that display the first output in the first table first cell, the second output in the first table second cell. and the remaining result to be displayed inthe second table which has only one cell.
the random ranking functionality has been achieved using this code:
Code: Select all
$sql_query = "SELECT * FROM $tablevar WHERE FIND_IN_SET('download',DisplayOn) AND StartDate <= '$currdate' AND EndDate >= '$currdate' ORDER BY RAND()";
$rs_data = mysql_query($sql_query) or die ("could not execute query: " . mysql_error());
while($data = mysql_fetch_assoc($rs_data))
{
$arr_data[$data['DisplayOrder']] = $data;
}
ksort($arr_data);
foreach($arr_data as $item)
but this code works with only what cell which replicates in self..