some advice

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Almore
Forum Newbie
Posts: 6
Joined: Fri May 31, 2002 4:59 pm

some advice

Post 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.
rats
Forum Newbie
Posts: 21
Joined: Fri May 31, 2002 5:55 am

reply

Post 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
.
User avatar
gotDNS
Forum Contributor
Posts: 217
Joined: Tue May 07, 2002 5:53 pm
Location: West Chester, PA

Post 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?
User avatar
Almore
Forum Newbie
Posts: 6
Joined: Fri May 31, 2002 4:59 pm

Not quite

Post 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.
Tiimmy
Forum Commoner
Posts: 38
Joined: Sat Apr 27, 2002 1:56 am
Location: Australia
Contact:

Post 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:
User avatar
James Pelow
Site Admin
Posts: 51
Joined: Sat Jun 01, 2002 5:28 am
Location: Killiney, Co. Dublin, Ireland
Contact:

PHP 4.2.x and Request Variables

Post 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
User avatar
gotDNS
Forum Contributor
Posts: 217
Joined: Tue May 07, 2002 5:53 pm
Location: West Chester, PA

Post by gotDNS »

i have images :D ... http://brin.ath.cx/images/
User avatar
Almore
Forum Newbie
Posts: 6
Joined: Fri May 31, 2002 4:59 pm

What i have

Post 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.
Post Reply