473,385 Members | 1,641 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

html table trouble

I have a database with three columns. One is an atomic number, one is a
pic url, and the other is a description. What I'm having trouble doing
is putting the url in one table row and the description in another table
row right below it like this...
<tr<tdsome pic url</td<tdother pic url</td></tr>
<tr><tdsome descripts </td<tdother descript </td></tr>

whilest limiting the rows to about 10 cells each,,....

any ideas?

Aaron
Apr 26 '07 #1
6 1430
_Skare_Krow_ napisaƂ(a):
I have a database with three columns. One is an atomic number, one is a
pic url, and the other is a description. What I'm having trouble doing
is putting the url in one table row and the description in another table
row right below it like this...
<tr<tdsome pic url</td<tdother pic url</td></tr>
<tr><tdsome descripts </td<tdother descript </td></tr>

whilest limiting the rows to about 10 cells each,,....

any ideas?

Aaron
The easiest way is to use CSS - div + float property.
<?php

$arr =array(
array("file1","desc1"),
array("file2","desc2"),
array("file3","desc3"),
array("file4","desc4"),
array("file5","desc5"),
array("file6","desc6"),
array("file7","desc7"),
);

define('TABLE_COLS',4);

print "<table>".PHP_EOL;
$i=1;
while(list($key,$row) = each($arr)) {
$tmp[$i]=$row;
if($i++==TABLE_COLS) {
print "<tr>";
for($j=1;$j<=TABLE_COLS;$j++) {
print "<td>".$tmp[$j][0]."</td>";
}
print "</tr>".PHP_EOL;
print "<tr>";
for($j=1;$j<=TABLE_COLS;$j++) {
print "<td>".$tmp[$j][1]."</td>";
}
print "</tr>".PHP_EOL;
$i=1;
}
}
if($i>1) {
print "<tr>";
for($j=1;$j<=TABLE_COLS;$j++) {
print "<td>".(($j<$i)?$tmp[$j][0]:"")."</td>";
}
print "</tr>".PHP_EOL;
print "<tr>";
for($j=1;$j<=TABLE_COLS;$j++) {
print "<td>".(($j<$i)?$tmp[$j][1]:"")."</td>";
}
print "</tr>".PHP_EOL;
}
print "</table>";

--
Wiktor Walc
http://phpfreelancer.net
Apr 26 '07 #2
_Skare_Krow_ wrote:
I have a database with three columns. One is an atomic number, one is a
pic url, and the other is a description. What I'm having trouble doing
is putting the url in one table row and the description in another table
row right below it like this...
<tr<tdsome pic url</td<tdother pic url</td></tr>
<tr><tdsome descripts </td<tdother descript </td></tr>

whilest limiting the rows to about 10 cells each,,....

any ideas?

Aaron
Hi, Aaron,

Two easy ways - as you go through the result set to get your url, save
the matching description in an array. Then when you're done with your
url's, you can go through the description array and get the values.

The other way is after going through the result set to get your url, use
mysql_data_seek() to reposition the internal pointer and go through the
result set a second time to get the descriptions.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Apr 26 '07 #3
On Apr 26, 6:28 am, _Skare_Krow_ <petra2...@gmail.comwrote:
I have a database with three columns. One is an atomic number, one is a
pic url, and the other is a description. What I'm having trouble doing
is putting the url in one table row and the description in another table
row right below it like this...
<tr<tdsome pic url</td<tdother pic url</td></tr>
<tr><tdsome descripts </td<tdother descript </td></tr>

whilest limiting the rows to about 10 cells each,,....

any ideas?

Aaron
once you have your results in a 2d array, use 2 loops, one to create
the cells, which steps through the array echoing pics iterating by
one, the outer loop iterates by however many cells you used, if 10
then $i+=10, you could use array_shift with less complexity but it
might be slower.

you could use fluid (floating) css with a simple array and just set
the number of columns using css instead.

Apr 26 '07 #4
On Thu, 26 Apr 2007 00:28:45 -0500, in comp.lang.php _Skare_Krow_
<pe*******@gmail.com>
<nJ******************************@sysmatrix.netwro te:
>| I have a database with three columns. One is an atomic number, one is a
| pic url, and the other is a description. What I'm having trouble doing
| is putting the url in one table row and the description in another table
| row right below it like this...
| <tr<tdsome pic url</td<tdother pic url</td></tr>
| <tr><tdsome descripts </td<tdother descript </td></tr>
|
| whilest limiting the rows to about 10 cells each,,....
|
| any ideas?
|
| Aaron
<?php
//--- init record limit var
$start=0;

//--- open connection to db and table

//--- get page number from url/post var
//--- and update the $start var

//--- create the query
$sql = "SELECT * FROM table LIMIT {$start},{start + 10}";
//--- execute query
$row1=""; $row2="";
for($i=0; $i<count($result); $i++)
{
$row1 .= "<td><img src'".$result[$i]->pic_url."'</td>";
$row2 .= "<td>".$result[$i]->pic_desc."</td>";
}
?>

<table>
<tr><?php echo $row1;></tr>
<tr><?php echo $row2;></tr>
</table>
---------------------------------------------------------------
jn******@yourpantsyahoo.com.au : Remove your pants to reply
---------------------------------------------------------------
Apr 26 '07 #5
Jeff North wrote:
On Thu, 26 Apr 2007 00:28:45 -0500, in comp.lang.php _Skare_Krow_
<pe*******@gmail.com>
<nJ******************************@sysmatrix.netwro te:
>| I have a database with three columns. One is an atomic number, one is a
| pic url, and the other is a description. What I'm having trouble doing
| is putting the url in one table row and the description in another table
| row right below it like this...
| <tr<tdsome pic url</td<tdother pic url</td></tr>
| <tr><tdsome descripts </td<tdother descript </td></tr>
|
| whilest limiting the rows to about 10 cells each,,....
|
| any ideas?
|
| Aaron

<?php
//--- init record limit var
$start=0;

//--- open connection to db and table

//--- get page number from url/post var
//--- and update the $start var

//--- create the query
$sql = "SELECT * FROM table LIMIT {$start},{start + 10}";
//--- execute query
$row1=""; $row2="";
for($i=0; $i<count($result); $i++)
{
$row1 .= "<td><img src'".$result[$i]->pic_url."'</td>";
$row2 .= "<td>".$result[$i]->pic_desc."</td>";
}
?>

<table>
<tr><?php echo $row1;></tr>
<tr><?php echo $row2;></tr>
</table>
---------------------------------------------------------------
jn******@yourpantsyahoo.com.au : Remove your pants to reply
---------------------------------------------------------------
thanks everyone.. i've got enough info to try out.. i will post back
with my success or failure :P

aaron
Apr 26 '07 #6
_Skare_Krow_ wrote:
I have a database with three columns. One is an atomic number, one is a
pic url, and the other is a description. What I'm having trouble doing
is putting the url in one table row and the description in another table
row right below it like this...
<tr<tdsome pic url</td<tdother pic url</td></tr>
<tr><tdsome descripts </td<tdother descript </td></tr>

whilest limiting the rows to about 10 cells each,,....

any ideas?

Aaron
Oh and you guys are so much nicer and more helpful than the javascript
group...

aaron
Apr 26 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: jaydog | last post by:
Hello... I'm new to XSL, and I've written a XSLT file that converts a XML file to HTML format. When viewed in a browser, it appears exactly as I would like. However, if I want to look at the...
0
by: kmunderwood | last post by:
I am having trouble excluding select xml out to HTML using xsl I want to ignore some xml and turn others red I can not find the right way to both: 1. Only show the <tag> that want to, and...
71
by: tomy_baseo | last post by:
I'm new to HTML and want to learn the basics by learning to code by hand (with the assistance of an HTML editor to eliminate repetitive tasks). Can anyone recommend a good, basic HTML editor that's...
1
by: Dymov Vlad | last post by:
Hello, All! I have some trouble with subject. Maybe it is not trouble at all, but i need a good advise. I have just tried to write simple ASPX page in HTML view. Everything was good....
3
by: John Baker | last post by:
Hi:7 Newby here to ASP, and using the ASP.NET Web Matrix development tool. While that tool looks great for a Newby, I have run into a snag. I have an HTML Text Box which I have named HireInput,...
0
by: lawrenceS59 | last post by:
Hi all, I'm fairly new to web development so bare with me. The html page that i've created isn't working and i can't figure out why. I'm guessing there are some rules that need to be followed...
6
by: Bill | last post by:
Hi All, New to the whole .Net and C# thing but trying. In classic asp this was simple to fill a table with dynamic content and hyperlinks. Here is an example of what I am trying to do in classic...
2
beacon
by: beacon | last post by:
I'm having trouble with a personal web page that I'm designing for work. I'm not well versed in HTML and could use some assistance. Currently, when I open the browser, the table in the head at the...
15
by: lxyone | last post by:
Using a flat file containing table names, fields, values whats the best way of creating html pages? I want control over the html pages ie 1. layout 2. what data to show 3. what controls to...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.