468,249 Members | 1,512 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,249 developers. It's quick & easy.

how to close table

hello and please excuse me again for my clumsy english.

As I wrote few weeks ago, I'm not programer, but I have to create one
script. that is a gallery script, and after successful work on flatfile
gallery script I'w decided to build mysql script.
frontend is almost done, everything is working fine, except ending of
tables..

I will try to describe and draw what I mean:

if I have 8 pics to be shown, and if choose to have 4 columns in row,
table will close fine:
<table>
<tr><td>IMG</td><td>IMG</td><td>IMG</td><td>IMG</td></tr>
<tr><td>IMG</td><td>IMG</td><td>IMG</td><td>IMG</td></tr>
</table>

but, if I have 9 pics, i will have "hole" in my table:

<table>
<tr><td>IMG</td><td>IMG</td><td>IMG</td><td>IMG</td></tr>
<tr><td>IMG</td><td>IMG</td><td>IMG</td><td>IMG</td></tr>
<tr><td>IMG</td></tr>
</table>

now... how to draw those missing <td>&nbsp;</td>?
or to create <td colspan=\"$somenumber\"> ?

how to calculate that $somenumber ?
(that solution with colspan is easier, but I would like to learn both
solutions)

here is one part of my code:
(I believe that it can be written much nicer, but again, I'm just
starting with your language... php I mean.)

function collect_authors() {
global $incl, $incp, $tbrd, $PHP_SELF, $i;

print "<table border=\"$tbrd\" cellspacing=\"0\"
cellpadding=\"$incp\"><tr>\n";

// subfunction get AUTOR
$query1 = "SELECT AutorID,AutorName,AutorPrez,AutorPict FROM
autor";
$result1 = mysql_query ($query1) or die ("shit, f*query failed
($query1)");
while (list($AutorID,$AutorName,$AutorPrez,$AutorPict) =
mysql_fetch_array($result1)) {
// takeing picture size and calculating squized
thumbnail
list($width, $height, $type, $attr) =
getimagesize("faces/$AutorPict");
$smal = $width / 50;
$heih = floor($height / $smal + 0.5);
print "<td align=\"right\" valign=\"top\">\n\n".
"<table width=\"100%\" border=\"0\"
cellspacing=\"2\" cellpadding=\"0\">\n<tr>\n<td colspan=\"2\"
align=\"left\" valign=\"bottom\">\n".
"<a class=\"autor\"
href=\"$PHP_SELF?AutorID=$AutorID\"><br>$AutorName
$AutorPrez</a>\n</td>\n</tr>\n".
"<tr>\n<td align=\"right\" valign=\"top\">\n".
"<p>\n<img class=\"pict\" src=\"faces/$AutorPict\"
alt=\"$AutorName\" width=\"50\" height=\"$heih\">\n</p>\n".
"</td>\n<td align=\"left\" valign=\"top\">\n";

// subfunction get ALBUM
$query2 = "SELECT AlbumID,AlbumName FROM album WHERE
AutorID=$AutorID";
$result2 = mysql_query ($query2) or die ("shit, f*query
failed ($query2)");
while (list($AlbumID,$AlbumName) =
mysql_fetch_array($result2)) {
print "<p>\n<a class=\"album\"
href=\"$PHP_SELF?AlbumID=$AlbumID\">$AlbumName</a>\n</p>\n";
}
print "</td>\n</tr>\n</table>\n\n</td>\n";
$i++;
if ($i % $incl == 0) {
print "</tr>\n<tr>\n";
}
}
print
"</table>\n\n";
}

tnx for any help.

--
Jan_ko?
--
Jul 17 '05 #1
1 2374
function collect_authors() {
global $incl, $incp, $tbrd, $PHP_SELF, $i;

print "<table border=\"$tbrd\" cellspacing=\"0\"
cellpadding=\"$incp\"><tr>\n";

// subfunction get AUTOR
$query1 = "SELECT AutorID,AutorName,AutorPrez,AutorPict FROM
autor";
$result1 = mysql_query ($query1) or die ("shit, f*query failed
($query1)");
while (list($AutorID,$AutorName,$AutorPrez,$AutorPict) =
mysql_fetch_array($result1)) { ---snip $i++;
if ($i % $incl == 0) {
print "</tr>\n<tr>\n";
}
} if ($i % incl) {
print "<td colspan="($i % $incl)"></td>";
} print
"</table>\n\n";
}

tnx for any help.

Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by kevin dalby | last post: by
3 posts views Thread by Asit | last post: by
19 posts views Thread by Lauren Wilson | last post: by
reply views Thread by bonita | last post: by
1 post views Thread by oliver gargour | last post: by
4 posts views Thread by Martin Arvidsson, Visual Systems AB | last post: by
1 post views Thread by =?Utf-8?B?TG91aXM=?= | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.