On Wed, 22 Sep 2004 23:53:06 -0700, Ben wrote:
Hi everybody!
I have a multi-file upload form... Please looks at my code below. It's
in an initial stage. I'm trying to display the values of each text box
when I press "upload" but it doesn't seem to work... i don't know
what's the problem.. I'm using PHP5.
I haven't studied this in detail enough to know exactly where your problem
is, but I can see one problem right away. You have one misplaced quotation
mark, namely the one after image on this line:
<input type="file" name="image"<?php echo ifcond($i); ?> /><br /><br
I believe you want the return from function ifcond to be attached to the
word image, not come after it in the input tag.
But more importantly, you should try to rewrite your code so that it is
more readable. I very rarely mix clear html text with php tags for the
very reason that your piece of code here is very hard to debug. There are
many ways to write this piece of code, some more efficient than others,
but forgetting efficiency for the moment (php is fast anyway), this might
read better instead of the equivalent lines that you wrote:
<?php
for ($i=1; $i < 11; $i++)
{
$str = ifcond($i);
echo "Image$str:<input type=\"file\"
name = \"image$str\" /><br /><br />";
}
?>
Granted, it is clumsy having to use \" within to write a quote within the
echo command, but it reads better than having to parse a handful of php
tags by eyeball. Note here also, you have only one call to your function
instead of two. Also, if you are using a php-syntax aware editor,
something like Image$str looks very readable since the $str will be taken
as a PHP variable and made in a different color than Image.
Regards,
Steve, Denmark