tabular query output
Moderator: General Moderators
-
rubberjohn
- Forum Contributor
- Posts: 193
- Joined: Fri Feb 25, 2005 4:03 am
tabular query output
hi,
ive been away from php for a while and as a result i am struggling with formatting the out put of a query into a nice and neat table.
the query can return multiple record sets. in each set is 6 records - title, image url, price 1, price 2, % difference in prices and finally a link.
I want each record set to be displayed in a column - ie
title
image url
price 1
price 2
% difference
link
This I can (still) do, but what I am having trouble with is displaying a line fo four of these across the screen. All i am managing to do is is to get them repeating down the screen instead of accross it.
amy help would be greatly appreciated
rj
ive been away from php for a while and as a result i am struggling with formatting the out put of a query into a nice and neat table.
the query can return multiple record sets. in each set is 6 records - title, image url, price 1, price 2, % difference in prices and finally a link.
I want each record set to be displayed in a column - ie
title
image url
price 1
price 2
% difference
link
This I can (still) do, but what I am having trouble with is displaying a line fo four of these across the screen. All i am managing to do is is to get them repeating down the screen instead of accross it.
amy help would be greatly appreciated
rj
-
rubberjohn
- Forum Contributor
- Posts: 193
- Joined: Fri Feb 25, 2005 4:03 am
feyd | Please use
off the top of my head the code i am using is this...
i then echo $output.
The syntax may not be right but thats pretty much what it is - im not infront of my home pc at the minute.
Thanks
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
sorry i thought i had been specific...
i do not want the output to be like this - repeating down the screen:
title
image url
price 1
price 2
% difference
link
title
image url
price 1
price 2
% difference
link
title
image url
price 1
price 2
% difference
link
etc
i want it to display across the screen like this - this is the best i could do to get it alignedCode: Select all
title title title
image url image url image url
price 1 price 1 price 1
price 2 price 2 price 2
% difference % difference % difference
link link linkCode: Select all
$output = '<table width="200" border="1" cellspacing="1" cellpadding="1">';
sql query here
while sql query !=0{
$output .= '
<tr>
<tr>
<td>title</td>
</tr>
<tr>
<td>image url</td>
</tr>
<tr>
<td>price 1</td>
</tr>
<tr>
<td>price 2</td>
</tr>
<tr>
<td>% difference</td>
</tr>
<tr>
<td>link</td>
</tr>';
}
$output .= '</table>'The syntax may not be right but thats pretty much what it is - im not infront of my home pc at the minute.
Thanks
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]-
rubberjohn
- Forum Contributor
- Posts: 193
- Joined: Fri Feb 25, 2005 4:03 am
cheers feyd i feared it would involve something like that - i just wanted to know if there was an easier way to do it.
so it would involve collecting all the titles, urls, price 1 etc together and outputing them individually but in a way that still groups the relevant related records together - ill check out those other posts
what about using a mutli-d array?
so it would involve collecting all the titles, urls, price 1 etc together and outputing them individually but in a way that still groups the relevant related records together - ill check out those other posts
what about using a mutli-d array?
Well, I suggest that instead of relaying on PHP to rotate it and all the other processes involved here, just use PHP to output something like the below and then use CSS to make it look like the elements of the outer list are at the same row.
Code: Select all
<ul>
<li>
<ul>
<li>title</li>
<li>img url</li>
<li>price1</li>
<li>price2</li>
<li>% diff</li>
<li>link</li>
</ul>
</li>
<li>
<ul>
<li>title</li>
<li>img url</li>
<li>price1</li>
<li>price2</li>
<li>% diff</li>
<li>link</li>
</ul>
</li>
.
.
.
<li>
<ul>
<li>title</li>
<li>img url</li>
<li>price1</li>
<li>price2</li>
<li>% diff</li>
<li>link</li>
</ul>
</li>
</ul>-
rubberjohn
- Forum Contributor
- Posts: 193
- Joined: Fri Feb 25, 2005 4:03 am
-
rubberjohn
- Forum Contributor
- Posts: 193
- Joined: Fri Feb 25, 2005 4:03 am
oren cheers for that - that method looks like it would work perfectly except that some of the images vary a little in height and some of the associated text spans two lines, therefore each list would be a different height and so would not line up when displayed inline across the screen.
So i chose to use the method suggested by feyd (viewtopic.php?t=25105) as the rows will accomodate different content sizes and should line up.
im just having trouble adding additional rows above and below the image - i'll keep trying to sort it out but i'll probably be back tomorow
cheers again
So i chose to use the method suggested by feyd (viewtopic.php?t=25105) as the rows will accomodate different content sizes and should line up.
im just having trouble adding additional rows above and below the image - i'll keep trying to sort it out but i'll probably be back tomorow
cheers again