473,809 Members | 2,469 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1447
_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_C OLS',4);

print "<table>".PHP_E OL;
$i=1;
while(list($key ,$row) = each($arr)) {
$tmp[$i]=$row;
if($i++==TABLE_ COLS) {
print "<tr>";
for($j=1;$j<=TA BLE_COLS;$j++) {
print "<td>".$tmp[$j][0]."</td>";
}
print "</tr>".PHP_EOL;
print "<tr>";
for($j=1;$j<=TA BLE_COLS;$j++) {
print "<td>".$tmp[$j][1]."</td>";
}
print "</tr>".PHP_EOL;
$i=1;
}
}
if($i>1) {
print "<tr>";
for($j=1;$j<=TA BLE_COLS;$j++) {
print "<td>".(($j<$i) ?$tmp[$j][0]:"")."</td>";
}
print "</tr>".PHP_EOL;
print "<tr>";
for($j=1;$j<=TA BLE_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*******@attgl obal.net
=============== ===
Apr 26 '07 #3
On Apr 26, 6:28 am, _Skare_Krow_ <petra2...@gmai l.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*******@gmai l.com>
<nJ************ *************** ***@sysmatrix.n etwrote:
>| 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($resul t); $i++)
{
$row1 .= "<td><img src'".$result[$i]->pic_url."'</td>";
$row2 .= "<td>".$res ult[$i]->pic_desc."</td>";
}
?>

<table>
<tr><?php echo $row1;></tr>
<tr><?php echo $row2;></tr>
</table>
---------------------------------------------------------------
jn******@yourpa ntsyahoo.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*******@gmai l.com>
<nJ************ *************** ***@sysmatrix.n etwrote:
>| 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($resul t); $i++)
{
$row1 .= "<td><img src'".$result[$i]->pic_url."'</td>";
$row2 .= "<td>".$res ult[$i]->pic_desc."</td>";
}
?>

<table>
<tr><?php echo $row1;></tr>
<tr><?php echo $row2;></tr>
</table>
---------------------------------------------------------------
jn******@yourpa ntsyahoo.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
2480
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 HTML as text, which I do, then I have trouble because the XSLT processor (SAXON) outputs everything as one continuous line. How can I make the HTML output from SAXON readable? Is there a command in the XSLT language that forces line breaks? ...
0
1397
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 2. Turn an attribute a color when it falls below a certain level.
71
6520
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 a step beyond Notepad (not a WYSIWYG tool). Thanks.
1
1519
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. Auto-farmatting feature been worked well. It was make right indents, quotes and ect. Just like below:
3
1757
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, and a table (Access Table in fact) that has on it a field called HIREID. I wish to select records where the two match! It sounds simple, but I am having trouble setting up the text box name so that it is recognized in the query. Can someone...
0
6438
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 when putting xml between the <textarea></textarea> tags. The textarea and the submit buttons are located inside <form> tags. When a button is pressed it calls a jsp page to do the processing needed. For some xml content it works nicely....for others i...
6
6531
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 asp: <table width="640" border="0" cellspacing="3" cellpadding="3"> <tr class="mcsmalltextbold"> <td>First Name</td> <td>Last Name</td> <td>Phone Number</td>
2
2434
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 top of the screen doesn't stay flush with the top of the screen. I've tried changing the alignment, but have had no luck. I'm not using a stylesheet and am wondering if maybe that's the problem. Also, below the head, I have another table that...
15
5283
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 show - text boxes, input boxes, buttons, hyperlinks ie the usual. The data is not obtained directly from a database.
0
9722
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10643
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10378
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10391
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10121
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7664
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5690
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4333
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.