Page 1 of 1
how can i thumbnail data in php
Posted: Tue Jul 07, 2009 1:23 am
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
Re: how can i thumbnail data in php
Posted: Tue Jul 07, 2009 1:29 am
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.
Re: how can i thumbnail data in php
Posted: Tue Jul 07, 2009 2:28 am
by manojsemwal1
Thanks for quick reply...
pl can u send me the css file for that...
regards,
manoj
Re: how can i thumbnail data in php
Posted: Tue Jul 07, 2009 2:55 am
by onion2k
Why can't you write it yourself?
Re: how can i thumbnail data in php
Posted: Tue Jul 07, 2009 3:01 am
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 />';
}
}
Re: how can i thumbnail data in php
Posted: Tue Jul 07, 2009 5:40 am
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 > $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
Re: how can i thumbnail data in php
Posted: Tue Jul 07, 2009 8:16 am
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++;
}
Re: how can i thumbnail data in php
Posted: Tue Jul 07, 2009 8:28 am
by manojsemwal1
Thanks Budy.....
Thank u Very Much ........
regards,