Author Topic: arrange the data like 4images  (Read 9001 times)

0 Members and 1 Guest are viewing this topic.

Offline ameenov

  • Newbie
  • *
  • Posts: 41
    • View Profile
arrange the data like 4images
« 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


TheOracle

  • Guest
Re: arrange the data like 4images
« Reply #1 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. ;)

Offline ameenov

  • Newbie
  • *
  • Posts: 41
    • View Profile
Re: arrange the data like 4images
« Reply #2 on: August 10, 2005, 10:54:27 AM »
No I mean for my programing not for 4images  :wink:

TheOracle

  • Guest
Re: arrange the data like 4images
« Reply #3 on: August 10, 2005, 01:43:17 PM »
Quote

not for 4images


This forum is only about 4images.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: arrange the data like 4images
« Reply #4 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.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline ameenov

  • Newbie
  • *
  • Posts: 41
    • View Profile
Re: arrange the data like 4images
« Reply #5 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:

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: arrange the data like 4images
« Reply #6 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;
?>
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline ameenov

  • Newbie
  • *
  • Posts: 41
    • View Profile
Re: arrange the data like 4images
« Reply #7 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