Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Image Probs!

Status
Not open for further replies.

7724

Programmer
Feb 25, 2005
28
GB
Hi Guys,

I’m trying to display an image on a live php page, wihich is already uploaded to a directory:

So in my admin section I have this code:

<select name="image">
<option value="" selected>select an image...</option>
<?php
$query = mysql_query("SELECT * FROM `images`");
while($reza = mysql_fetch_assoc($query)){
?>
<option value="<?php echo $reza['url']; ?>"><?php echo $reza['name']; ?></option>
<?php
}
?>
</select>

Now this is a dropdown list which looks in my SQL images table for each image in the directory. This tale holds the name of the image, which is displayed on the dropdown.

What I want to do is make a form (post) the above so that when submit, the selection I have made is held in memory and I can go in and change that image as needed – then the selected image is displayed on my live site using;

<img src="images/<?php echo"$image"; ?>">

Not sure how I’d modify the dropdown though to do this, so it can be modified and the selection is held.

Any ideas?

Thanks
 
not certain that i fully understand your question.
but .. it seems like what you want to do is not display the image directly but to do some manips first.

not a problem.

from the form you have the name of the image.
use php to execute the image manipulations on the image and save it as a new image (or whatever) and then populate the src attribute of the img tag with the new file name (or whatever).
 
Hi,

Bit further on using this code:

Yep that's the idea! But with this:



php:
--------------------------------------------------------------------------------

<?php
if (isset($_POST['image'])){
$selected = $_POST['image'];
$selected_display = $_POST['image'];
} else (
$selected = "";
$selected_display = "select an image...";
}
echo "
<select name='image'>
<option selected value='$selected'> $selected_display </option>
";
$query = mysql_query("SELECT * FROM `images`");
while($reza = mysql_fetch_assoc($query)){
$name = $reza['name'];
$location = $reza['url'];
echo " <option value='$location'>$name</option>";
}
echo "</select>";
?>


--------------------------------------------------------------------------------



Throws up an error:

Parse error: parse error, unexpected ';' in /home/sleaz/public_html/cms/add_profiles.php on:

= ""; $selected_display = "select an image..."; } echo

Any ideas?

Ta
 
you have a round bracket after the else statement rather than a curly brace.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top