View Full Version : Images in Forms

Deacon Frost
02-14-2008, 10:01 AM
It's a php form that I need to also edit, so I'm asking all of the questions here...

What i have:


$result = mysql_query("SELECT filmid,name FROM theater WHERE status=2") or die('mysql_error()' . 'Error: ' . mysql_errno() );
$row = mysql_fetch_assoc($result);

$filmid = $row['filmid'];
$name = $row['name'];


<form action="theater.php" method="get">
<input type="submit" value=<img src="http://images.stage6.com/video_images/<? echo $filmid ?>t.jpg</img> <br /> <center> "<? echo $name ?>" </center> />

What I need it to do...

There's a few fields in the database. The only one I need it to send to theater.php in the get function is the "id" for the video. filmid is the code, but id is the unique video's, well, id.

What it will need to do is show 5 images where the status=2 (approved). These images are like above. <? echo $filmid ?> will finish the image, and $name is just the name of the movie. When this is clicked, I need it to use the method get to grab the id for the $filmid and $name image (form) clicked.

Basically (once I have this i can do everything else) I need an image on a form. Not a button, but a form. How do I put an image on a form?

02-14-2008, 02:42 PM
Why does it have to be a form?

You can do this and still use $_GET in the receiving script:

<a href="receiving_script.php?id=<?=$filmid?>"><img src="<?=$filmid?>t.jpg"></a>

The receiving script has this:

02-14-2008, 04:04 PM
If you have to use a form, use an image button. ASFAIK It doesn't work to put HTML markup in the value attribute of a submit button, and it certainly isn't valid HTML.

Deacon Frost
02-14-2008, 08:33 PM
that won't make it so the id = the id number for that video, but it will equal the filmid for that video. It has to be the unique id for that video...

I got it to work, now I just need help on...

How to use the get function properly. Basically I have ID FilmID and Name. FilmID and Name are what is used to MAKE up the form that I have. However, I need the ID that is for the form matching FilmID and Name to be sent to the theater.php (receiving). That way in the receiving I can set it up to $_GET['id'] and when doing so it'll put it in a query string in the url, and change the id number of which movie was selected.

02-15-2008, 03:37 AM
You can send more than one variable with the URL ...

<a href="theater.php?id=1234&filmid=37362&name=name of the film">

With the form, you can have hidden variables ...

<form action="theater.php" method="post">
<input type="hidden" name="name" value="name of the film">
... other stuff

if you use the URL, the script uses $_GET ...

if you use method="post" in a form, your script uses $_POST

By using POST in a form, you won't see the variables in the URL


Final method, you have each one stored in a database.
You only send the ID and the script called "theater.php" matches
that ID to the database and then it knows everything else about
the film by matching the ID and reading the database.

Deacon Frost
02-15-2008, 09:17 AM
Ok, well, I got that part done... I used forms cause doing the link could cause problems in the future. (Format and ****)