Current location: Hot Scripts Forums » Programming Languages » PHP » query results in multiple columns


query results in multiple columns

Reply
  #1 (permalink)  
Old 10-08-03, 10:06 AM
SnowCrash SnowCrash is offline
New Member
 
Join Date: Oct 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
query results in multiple columns

I currently have a database which contains a series of image file names. Currently I can produce a single column of thumbnails without any problems. However, what I would like to do is have the data in 2 columns rather than one.

Here is a page with both examples http://www.c3s.co.uk/temp01.php

PHP Code:

<?php require_once('Connections/main.php'); ?>

<?php
$maxRows_test 
10;
$pageNum_test 0;
if (isset(
$_GET['pageNum_test'])) {
  
$pageNum_test $_GET['pageNum_test'];
}
$startRow_test $pageNum_test $maxRows_test;

mysql_select_db($database_main$main);
$query_test "SELECT * FROM work_in_progress";
$query_limit_test sprintf("%s LIMIT %d, %d"$query_test$startRow_test$maxRows_test);
$test mysql_query($query_limit_test$main) or die(mysql_error());
$row_test mysql_fetch_assoc($test);

if (isset(
$_GET['totalRows_test'])) {
  
$totalRows_test $_GET['totalRows_test'];
} else {
  
$all_test mysql_query($query_test);
  
$totalRows_test mysql_num_rows($all_test);
}
$totalPages_test ceil($totalRows_test/$maxRows_test)-1;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<table width="300" border="0" cellspacing="0" cellpadding="0">
  <?php do { ?>
  <tr>
    <td><img src="http://www.c3s.co.uk/wip/<?php echo $row_test['wip_image']; ?>_tn.jpg"></td>
  </tr>
  <?php } while ($row_test mysql_fetch_assoc($test)); ?>
</table>
</body>
</html>
<?php
mysql_free_result
($test);
?>
This has all been done in Dreamweaver. Can anyone help with this (I hope the question is clear)

Thxs
Reply With Quote
  #2 (permalink)  
Old 10-08-03, 02:14 PM
Chroder Chroder is offline
Newbie Coder
 
Join Date: Sep 2003
Location: Toronto, Ontario
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Change this:
Quote:
<?php do { ?>
<tr>
<td><img src="http://www.c3s.co.uk/wip/<?php echo $row_test['wip_image']; ?>_tn.jpg"></td>
</tr>
<?php } while ($row_test = mysql_fetch_assoc($test)); ?>
To something like this:

PHP Code:

<tr>


<?php
$perrow 
2;
$counter 0

do {
$counter++;
if(
$counter $perrow)
{
    echo 
"</tr><tr>";
    
$counter 0;
}

 
?>
    <td><img src="http://www.c3s.co.uk/wip/<?php echo $row_test['wip_image']; ?>_tn.jpg"></td>
  <?php } while ($row_test mysql_fetch_assoc($test));?>

</tr>
__________________
DevBox.net | DevBoxForums.com
Reply With Quote
  #3 (permalink)  
Old 10-09-03, 03:08 AM
SnowCrash SnowCrash is offline
New Member
 
Join Date: Oct 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Fantastic - this works an absolute treat.

Many Thanks
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Make a query that makes a field a link to the entire row mdhall PHP 8 10-09-03 06:18 PM
Which way to display results from mysql Peter_web PHP 2 09-13-03 05:39 PM
creating calculated fields in mysql resource after query Abu Mami PHP 0 07-31-03 06:47 AM
Using CDONTS to email Checkbox results AkaMadDiSk ASP 1 07-23-03 05:32 PM
Want to make 3 Columns from my results.. cebuy PHP 9 06-20-03 12:49 PM


All times are GMT -5. The time now is 06:35 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.