how can i thumbnail data in php

Looking to hire a PHP developer for a paid position? Looking for a paid PHP job? Want to post your resume? Let the job hunt begin...

Moderator: General Moderators

Post Reply
manojsemwal1
Forum Contributor
Posts: 217
Joined: Mon Jun 29, 2009 4:13 am
Location: India

how can i thumbnail data in php

Post by manojsemwal1 »

hello friend can somebody tell me how can i print data in rows wise ..like

my data is print like..
1
2
3
4
5
6
but i want
1 2 3 4 5 6 7
8 9 10 11 12 13
14,...
means after some restriction it will be break....

manoj
jamkelvl
Forum Newbie
Posts: 9
Joined: Thu Jun 25, 2009 3:23 pm

Re: how can i thumbnail data in php

Post by jamkelvl »

You could do it with a loop and some if statements but that's a lot of work.

For example if $i is greater than or equal to 6 then start a new line.

Do it with CSS in my opinion.
manojsemwal1
Forum Contributor
Posts: 217
Joined: Mon Jun 29, 2009 4:13 am
Location: India

Re: how can i thumbnail data in php

Post by manojsemwal1 »

Thanks for quick reply...

pl can u send me the css file for that...

regards,

manoj
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: how can i thumbnail data in php

Post by onion2k »

Why can't you write it yourself?
User avatar
genconv
Forum Commoner
Posts: 34
Joined: Sun Jul 05, 2009 9:27 am

Re: how can i thumbnail data in php

Post by genconv »

You could do it with a loop and some if statements but that's a lot of work.
It's simple:

Code: Select all

 
<?php
$numbers = range(1,100);
 
foreach($numbers as $number){
    echo $number . ' ';
    if($number%5 == 0){
        echo '<br />';
    }
}
 
and if you want 10 numbers per line:

Code: Select all

 
<?php
$numbers = range(1,100);
 
foreach($numbers as $number){
    echo $number . ' ';
    if($number%10 == 0){
        echo '<br />';
    }
}
 
manojsemwal1
Forum Contributor
Posts: 217
Joined: Mon Jun 29, 2009 4:13 am
Location: India

Re: how can i thumbnail data in php

Post by manojsemwal1 »

i Had tried your example is working fine but while printing form database its not print properly...

<?php
$sql = "select CourseId, CourseAbbr from coursetb";
$rs = mysql_query($sql) or die(mysql_errormsg());
$count=mysql_num_rows($rs);
$n=0;
$i = 1;
while ($n < $count )
{
$courseId = mysql_result($rs,$n,0);
$course = mysql_result($rs,$n,1);
$numbers = range(1,$count);
echo $number;
foreach($numbers as $number)
{
echo"<input type = checkbox name=courseid[] value=$courseId >&nbsp;$course ";
if($number%5 == 0)
{
echo '<br />';
}
}

$n++;
}
?>

here iam trying to print Course Name. After Reach 5 course in a line it should be break and print next line...

thanks
User avatar
genconv
Forum Commoner
Posts: 34
Joined: Sun Jul 05, 2009 9:27 am

Re: how can i thumbnail data in php

Post by genconv »

The solution for you:

Code: Select all

 
<?php
$query = 'SELECT CourseId, CourseAbbr FROM coursetb';
 
$result = mysql_query($query);
$n = 1;
while ($row = mysql_fetch_assoc($result)) {
    echo '<input type="checkbox" name="courseid[]" value="'.$row['CourseId'].'" > '. $row['CourseAbbr'] .' ';
    if($n%5 == 0){
        echo '<br />';
    }   
    $n++;
}
 
manojsemwal1
Forum Contributor
Posts: 217
Joined: Mon Jun 29, 2009 4:13 am
Location: India

Re: how can i thumbnail data in php

Post by manojsemwal1 »

Thanks Budy.....
Thank u Very Much ........
regards,
Post Reply