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!
<?php
if (isset($_POST['item'])) {
if ($_POST['itemnum'] > "") {
$itemnum = $_POST['itemnum'];
$image_dir = 'images/Soma/Items';
$itemnum = $itemnum;
if(!is_dir($image_dir))
{
echo ('Sorry but that is not a Direcotry.');
exit;
}
if(($dir_open = opendir($image_dir)) == false)
{
echo ('Error-- Could not open Directory');
exit;
}
while(($read_dir = readdir($dir_open)) != false)
{
if(!preg_match('/^\.+$/',$read_dir))
{
if(preg_match('/gif|jpeg|jpg|ico|png$/', $read_dir))
{
$images[] = $read_dir;
}
}
}
echo "<img src=\"images/soma/items/$images[$itemnum]\">";
}
}
?>
Basically i would like an image to change based on the value of an input box... i would also like the value of the input box to remain the same as the person input into it...rather than resetting itself. Also if there was a way for this code to be loaded based on a change in value of the input box that would be good too ^_^
Any help on this matter is greatly appreciated.... spent ages searching to no avail
tags
second of all, what is not working about it? your $_POST['itemnum'] > '' probebly is not going to work, you might wanna try using != instead of > for that.
for the last part they u said you might wanna use javascript.