Page 1 of 1

basic help needed

Posted: Sun Mar 16, 2003 9:56 pm
by sirrob01
Im trying to write a script which retrives an image from a friends server and then puts them into a table, not all people have pictures though so the script has to be able to put in place a default image if theres dosent work, it also puts there name under the image.. heres what I have so far, I am aware there's probably easier ways of doing it..but im learning...the script partially works, the table wont format correctly and it seems to time out on the 8th try?? help anyone? thanks in advance.


<?php
print "<table border=1>\n";
for ( $y=1; $y<=6; $y++ )
{
print "<tr>\n";
for ( $x=1; $x<=6; $x++ )
{
$name = array(1 => 'john','ralph','help','test','fruit','loop','bacon','bacon', );
for ($i=1; $i<=8; $i++ ){
print "\t<td>";
{$url="http://specified url{$name[$i]}.gif";
$size = getimagesize ("{$url}");
$imagewd=$size[0];
$fp=fopen("{$url}" ,"rb");
if ($imagewd == 100)
{print "<img src={$url}>"; }
elseif ($imagewd < 100)
{print "<img src=http://default graphic/blank.gif>"; }//20
{print ("<br>");}
{print ("<a href=http://specified url{$name[$i]}>{$name[$i]}</a>"); } }


}


print "</td>\n";
}
print "</tr>\n";
}
print "</table>";
?>

Posted: Mon Mar 17, 2003 10:41 am
by lc
Ehm I dunno but maybe try this:

Code: Select all

<?php 
print "<table border=1><tr>"; 

$name = array('john','ralph','help','test','fruit','loop','bacon','bacon', ); 
foreach($name as $key){ 
$url="http://specified url/$key.gif"; 
$size = getimagesize ("$url"); 
$imagewd=$size[0]; 
print "<td>";
if ($imagewd == 100) {
print "<img src=$url>"; 
} 
elseif ($imagewd < 100) {
print "<img src=http://default graphic/blank.gif>"; 
} 
print "<br>"; 
print "<a href=http://specified url/$key>$key</a>"; 
print "</td>";
}

print "</tr></table>"; 
?>
basicly I just removed a lot of stuff I didn't see the sense off... I haven't tried to do anything like this, but saw a lot of things like the {} that just didn't seem to need to be there.
I may of course be completely wrong ;)

Posted: Mon Mar 17, 2003 4:13 pm
by sirrob01
seems to work a treat, thanks heasps Ic :)...now to go and understand why it works lol

Posted: Mon Mar 17, 2003 6:38 pm
by sirrob01
yes i am an idiot,

ok so how would i add a loop to the above script so that instead of formatting the table as one long line of picys would put 4 in each row and then start a new row?

sorry to be a pain......I am trying to make this work before posting...just dosent seem to want to or i dont udnerstand enough to make it work

thanks again for any help...back to reading......