4images Forum & Community

General / Allgemeines => Chit Chat => Topic started by: ameenov on August 09, 2005, 11:25:27 AM

Title: arrange the data like 4images
Post by: ameenov on August 09, 2005, 11:25:27 AM
I'm doing a small project in php and I would like to make the output of the database to arrange like 4image

How can I make the records order in columns and rows instead of rows only

I want it Like that:


1- ameenov 1 4- ameenov 4
2- ameenov2 5- ameenov 5
3- ameenov 3 6- ameenov 6

Instead of that:
1- ameenov 1
2- ameenov2
3- ameenov 3
4- ameenov 4
5- ameenov 5
6- ameenov 6

Thank you

Title: Re: arrange the data like 4images
Post by: TheOracle on August 09, 2005, 10:03:53 PM
The simpliest way to do this is by going to your ACP - > settings and specify the values between each columns you'd like to have on your categories table. ;)
Title: Re: arrange the data like 4images
Post by: ameenov on August 10, 2005, 10:54:27 AM
No I mean for my programing not for 4images  :wink:
Title: Re: arrange the data like 4images
Post by: TheOracle on August 10, 2005, 01:43:17 PM
Quote

not for 4images


This forum is only about 4images.
Title: Re: arrange the data like 4images
Post by: V@no on August 10, 2005, 02:00:18 PM
Code: [Select]
for ($x = 0; $x < 10; $x++) //set loop of 10 rows
{
  for ($y = 0; $y < 10; $y++) //set loop of 10 columns
  {
// code for your column data
  }
// one column data was done, now one row data here
} //repeate process up to 10 times.
Title: Re: arrange the data like 4images
Post by: ameenov on August 10, 2005, 03:30:33 PM
(This forum is only about 4images.)
I hope that you open a php free talk section :roll:
thanks

/////////

Code: [Select]
for ($x = 0; $x < 10; $x++) //set loop of 10 rows
{
  for ($y = 0; $y < 10; $y++) //set loop of 10 columns
  {
// code for your column data
  }
// one column data was done, now one row data here
} //repeate process up to 10 times.

Can you provide that in example using databse?
It would me more clearer to me
I did not get it well.
Thanks  :wink:
Title: Re: arrange the data like 4images
Post by: V@no on August 10, 2005, 11:28:59 PM
alright
Code: [Select]
<?php
define
('ROOT_PATH''./');
$fast 1;
include(
ROOT_PATH.'global.php');
include(
ROOT_PATH.'includes/sessions.php');

$max_columns 10//maximum columns
$max_rows 10//maximum rows
$max $max_columns $max_rows//total of database entries that could fit
$sql "SELECT *
        FROM "
.IMAGES_TABLE."
        LIMIT "
.$max;
if (
$result $site_db->query($sql))
{
  
$x 0//initialize current count of columns
  
$y 0//initialize current count of rows 
  
$text "<table>\n<tr>\n<td>\n";
  while (
$row $site_db->fetch_array($result)) //fetching data from database
  
{
    
$text .= $row['image_name']; //the data what you want to print
    
$text .= "\n<br />\n"//next item should go to the next row
    
if (++$y == $max_rows//increase current count of rows and check if its maxed out
    
{
      
$y 0//reset number of rows
      
$text .= "</td>\n<td>\n"//closing current column and opening new column
      
if (++$x == $max_columns//increase current count of columns and check if its maxed out
      
{
        break; 
//ok, max number of columns reached, no more room for more data
      
}
    }
  }
  
$text .= "</td>\n</tr>\n</table>";
}
echo 
$text;
?>
Title: Re: arrange the data like 4images
Post by: ameenov on August 14, 2005, 09:26:03 AM
thanks it worked but with small errors I could fix it
thanks again for your kind response