Page 1 of 1

some advice

Posted: Fri May 31, 2002 4:59 pm
by Almore
I'm new to php and so far the only reference to using php that i've seen is the echo tag. No matter how complicated coding gets it all points to a simple echo to print some result of some information. My question is how do i use php to display a file in a table. for example i make a form in html. The form has a table in which u can browse for a photo, then using the submit button, sending that photo to a table in the index.php for instance. what do i use then to get the info from the submit to the php page. I read a little bit about the file codes in php and am unsure if i should use a temp file command of some sort, but how would i keep the integrity of the php page that way, wouldn't the info just change everytime the temp dir was cleared, etc... I'm totally unsure how to go about coding this any pointers would be welcome.

reply

Posted: Sat Jun 01, 2002 4:35 am
by rats
A quick tutorial is in order.

http://www.devshed.com/php/

look for a article called php 101

it should take about an hour.
Books are better to learn from though.

also you can look at http://www.php.net put fopen in the search/functionlist for some examples of file handling
.

Posted: Sat Jun 01, 2002 1:28 pm
by gotDNS
If I understand you at all I would suggest:

You have your form with some selection box or something that uses JS to change images and the like:

Code: Select all

<form action="index.php" method="post">
<select name="image">
<option value="img1.jpg">Image 1</option>
<option value="img2.jpg">Image 2</option>
</select>
</form>
Then index.php you have:

Code: Select all

<?php
echo "<table>
<tr>
<td><img src="$image">
</td>
</tr>
</table>";
?>
Is that what you meant at all?

Not quite

Posted: Sun Jun 02, 2002 3:58 am
by Almore
No what i'm trying to do is make a template that my dad can browse a file on his computer preferably images, then on the submit button it would go to index.php and show up in a table. its a basic template for him to make a photo web page, i just can't figure out the coding for the php i have the form working fine.

Posted: Sun Jun 02, 2002 4:37 am
by Tiimmy
gotDNS wrote: <?php
echo "<table>
<tr>
<td><img src="$image">
</td>
</tr>
</table>";
?>
That won't work. :lol:

Code: Select all

&lt;?php

echo "
&lt;TABLE&gt;
  &lt;TR&gt;
    &lt;TD&gt;
      &lt;IMG SRC="$image"&gt;
    &lt;/TD&gt;
  &lt;/TR&gt;
&lt;/TABLE&gt;
";

?&gt;
Parse errors can be a pain... :twisted:

PHP 4.2.x and Request Variables

Posted: Sun Jun 02, 2002 6:02 am
by James Pelow
Tut tut tut.... what about PHP 4.2.x? None of them will work! :roll:

Code: Select all

&lt;?php

echo "
&lt;TABLE&gt;
  &lt;TR&gt;
    &lt;TD&gt;
      &lt;IMG SRC="" . $_POST&#1111;"image"] . ""&gt;
    &lt;/TD&gt;
  &lt;/TR&gt;
&lt;/TABLE&gt;
";

?&gt;
-James

Posted: Sun Jun 02, 2002 1:05 pm
by gotDNS
i have images :D ... http://brin.ath.cx/images/

What i have

Posted: Sun Jun 02, 2002 6:21 pm
by Almore
this is the form:
<center><table cellpadding=0 cellspacing=30 border=1>
<tr><td align=center valign=bottom>
<form method=get enctype="multipart/form-data" name="photo1" action="http://spork/scripts/index.php">
<input type="hidden" name="directory1" value="">
<input type="hidden" NAME="dispopts1" VALUE="html, gif, jpg, other;;*">
<input type="file" name="userfile1" size=15><br>
<input type="submit" NAME="op-upload1" value="Get File">&nbsp;&nbsp;<br>
</form></td>

now is there a way to capture the file path into the php document from this form? if i specify $userfile1 in the php i know theres a way to get that path. and post the image.