SitePoint Sponsor |
|
User Tag List
Results 1 to 18 of 18
-
Jan 4, 2001, 06:16 #1
- Join Date
- Jul 2000
- Location
- Nowhere
- Posts
- 278
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
As the subject says, how can I print the mysql result in two or more html columns? Do I have to play around with for-loops and the limit? What have or would you have done?
-
Jan 4, 2001, 08:55 #2
- Join Date
- Aug 1999
- Location
- East Lansing, MI USA
- Posts
- 12,937
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Code:while ( $row = mysql_fetch_array($result) ) { print("<tr> <td>$row[author]</td> <td>$row[title]</td> </tr>"); }
Chris Beasley - I publish content and ecommerce sites.
Featured Article: Free Comprehensive SEO Guide
My Guide to Building a Successful Website
My Blog|My Webmaster Forums
-
Jan 4, 2001, 08:58 #3
- Join Date
- Nov 2000
- Location
- Hong Kong
- Posts
- 1,508
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Following on to this post, what if you have only one field:
"category"
which had to be in too columns??
-
Jan 4, 2001, 09:07 #4
- Join Date
- Jul 2000
- Location
- Nowhere
- Posts
- 278
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
thanx aspen, but this is what I already know
what I wanted to do is split the result into columns and then print them. So it may look like the php/cgi category's page of HotScripts. Any idea?
-
Jan 4, 2001, 10:13 #5
- Join Date
- Aug 1999
- Location
- East Lansing, MI USA
- Posts
- 12,937
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hmm what I showed was the results split in 2 columns.. Maybe you need to explain in more detail exactly what it is you want. I looked at hotscripts and don't see what you mean.
Is it that you want two tables of results side by side?
Chris Beasley - I publish content and ecommerce sites.
Featured Article: Free Comprehensive SEO Guide
My Guide to Building a Successful Website
My Blog|My Webmaster Forums
-
Jan 4, 2001, 10:29 #6
- Join Date
- Aug 2000
- Location
- San Diego, CA
- Posts
- 5,460
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
DIMA
$numcols = 2;
$count = 1;
print '<tr>';
while ($row = mysql_fetch_array($result)) {
if ($count % $numcols = 0) {
print '<td>yourdata</td></tr><tr>';
}
else {
print '<td>yourdata</td>';
}
$count++;
}
print '</tr></table>';Please don't PM me with questions.
Use the forums, that is what they are here for.
-
Jan 4, 2001, 15:53 #7
- Join Date
- Jul 2000
- Location
- Nowhere
- Posts
- 278
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hmm.. okay, again: I want to print out the result in at least two columns. For example an index from A to Z. In the first column it should print the first half (A-M) and the second has the other half. Just like the categories at Hotscripts (http://www.hotscripts.com/PHP/Scripts_and_Programs/). So it's not a long list of categories but instead split up in two parts.
How can I do that in PHP? I'm thinking of working with LIMIT in the sql-query...
-
Jan 4, 2001, 16:56 #8
- Join Date
- Aug 2000
- Location
- San Diego, CA
- Posts
- 5,460
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Maybe its you that is being unclear!
$count = 1;
print '<table border="1"><tr><td>';
for ($i=1;$i<19;$i++) {
while ($row = mysql_fetch_array($result)) {
if ($count == 10) {
print '</td><td>yourdata<br>';
}
else {
print 'yourdata<br>';
}
$count++;
}
print '</td></tr></table>';
Please don't PM me with questions.
Use the forums, that is what they are here for.
-
Jan 4, 2001, 17:03 #9
- Join Date
- Jul 2000
- Location
- Nowhere
- Posts
- 278
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hey thanks! That's what I needed
Sorry, for being not precise...
-
Jan 7, 2001, 08:26 #10
- Join Date
- Nov 2000
- Location
- Hong Kong
- Posts
- 1,508
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
DIMA is making two columns with two different fields. How would i put two colums with one field? Making sure that data is repeated.
Example
-----------------------
|Bob | Jack |
|Peter | Jill |
|Jane | Henry |
|Mike | Jemima |
-----------------------
?
-
Jan 7, 2001, 11:53 #11
- Join Date
- Aug 2000
- Location
- San Diego, CA
- Posts
- 5,460
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Use my first post on this subject
Please don't PM me with questions.
Use the forums, that is what they are here for.
-
Jan 7, 2001, 12:28 #12
- Join Date
- Nov 2000
- Location
- Hong Kong
- Posts
- 1,508
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Using your first post i get:
http://www.codingclick.com/subcats.php?cid=1
-
Jan 7, 2001, 13:13 #13
- Join Date
- Aug 2000
- Location
- San Diego, CA
- Posts
- 5,460
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
This is my first post see it a little further up from where you tried
DIMA
$numcols = 2;
$count = 1;
print '<table><tr>';
while ($row = mysql_fetch_array($result)) {
if ($count % $numcols = 0) {
print '<td>yourdata</td></tr><tr>';
}
else {
print '<td>yourdata</td>';
}
$count++;
}
print '</tr></table>';
Please don't PM me with questions.
Use the forums, that is what they are here for.
-
Jan 7, 2001, 13:15 #14
- Join Date
- Nov 2000
- Location
- Hong Kong
- Posts
- 1,508
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Results here:
http://www.codingclick.com/subcats.php?cid=1
-
Jan 7, 2001, 13:32 #15
- Join Date
- Aug 2000
- Location
- San Diego, CA
- Posts
- 5,460
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Can we see the code you used to create that? Its a little hard to debug things when only seeing the output to the screen
Please don't PM me with questions.
Use the forums, that is what they are here for.
-
Jan 7, 2001, 13:38 #16
- Join Date
- Nov 2000
- Location
- Hong Kong
- Posts
- 1,508
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
print "<table border='1'><tr>";
$numcols = 2;
$count = 1;
print "<tr>";
while ($cat = mysql_fetch_array($write)) {
$id = $cat["ID"];
$name = $cat["SubCat"];
$cid = $cat["CID"];
$description = $cat["Description"];
if ($count % $numcols = 0) {
print "<td><p><a href='list.php?cid=$cid&sid=$id'><font size='+1'><b>$name</b></font></a> " .
"<br><font size='1'>$description</font></td></tr><tr>";
}
else {
print "<td><p><a href='list.php?cid=$cid&sid=$id'><font size='+1'><b>$name</b></font></a> " .
"<br><font size='1'>$description</font></td>";
}
$count++;
}
print "</tr></table>";
-
Jan 7, 2001, 13:46 #17
- Join Date
- Aug 2000
- Location
- San Diego, CA
- Posts
- 5,460
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Try
if ($count % $numcols == 0) {
instead of
if ($count % $numcols = 0) {
Please don't PM me with questions.
Use the forums, that is what they are here for.
-
Jan 7, 2001, 13:50 #18
- Join Date
- Nov 2000
- Location
- Hong Kong
- Posts
- 1,508
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
That's it.
Thanx allot.
This one is going into the records. Brilliant script.
Bookmarks