| | |
images and drop down list boxes
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jul 2007
Posts: 57
Reputation:
Solved Threads: 2
hi I am new to this forum and new to using php. Everyone says it is really easy and so far so good until I was trying to display pictures based on the selected option from a drop down menu.
so I have 3 options:
dromidary
bactrian
mollie
I have an image from each. so I sent the form in the localhost from the HTML document to my php document using my webrowser but the pictures I cannot get to appear. This is my php code so far
<?php
$Fname = $_POST["txta"];
$add1 = $_POST["txtb"];
$add2 = $_POST["txtc"];
$add3 = $_POST["txtd"];
$postcode = $_POST["txte"];
$EM= $_POST["txtf"];
$mob= $_POST["txtg"];
$sex = $_POST["gender"];
$cam = $_POST["camel"];
$inv = $_POST["invoice"];
$subm = $_POST["sub"];
$TOT =500;
$B = $TOT * 17.5/100;
$A = $B + $TOT;
echo "INVOICE","<br>","<br>","<br>";
echo "name- ", $Fname,"<br>";
echo "adress1- ", $add1,"<br>";
echo "adress2- ",$add2,"<br>";
echo "adress3- ",$add3,"<br>";
echo "postcode- ",$postcode,"<br>";
echo "Email- ",$EM,"<br>";
echo "mobile- ",$mob,"<br>";
echo "sex of camel- ",$sex,"<br>";
echo"camel name-", $cam, "<br>";
echo "information will be sent to you via-",$inv,"<br>","<br>","<br>";
echo "subtotal:","£",$TOT,"<br>";
echo "vat is 17.5% is:",$B,"<br>";
echo "total cost:","£",$A;
if ($cam = camelx)
require ("maledromidary.jpg");
elseif ($cam = camely)
require ("malebactrian2.jpg");
else ($cam= camelz)
require ("mollie.jpg");
?>
Now I couldnt work out how to set it up as an array cus I dont know if it is possible to do super and subvariables. So I tried it as an if statement and i did nothing. This php page is an invoice showing the data That is typed in on the form and I just want to be able to display the pictures at thebottom of the page depending on the choise that is selected.
so I have 3 options:
dromidary
bactrian
mollie
I have an image from each. so I sent the form in the localhost from the HTML document to my php document using my webrowser but the pictures I cannot get to appear. This is my php code so far
<?php
$Fname = $_POST["txta"];
$add1 = $_POST["txtb"];
$add2 = $_POST["txtc"];
$add3 = $_POST["txtd"];
$postcode = $_POST["txte"];
$EM= $_POST["txtf"];
$mob= $_POST["txtg"];
$sex = $_POST["gender"];
$cam = $_POST["camel"];
$inv = $_POST["invoice"];
$subm = $_POST["sub"];
$TOT =500;
$B = $TOT * 17.5/100;
$A = $B + $TOT;
echo "INVOICE","<br>","<br>","<br>";
echo "name- ", $Fname,"<br>";
echo "adress1- ", $add1,"<br>";
echo "adress2- ",$add2,"<br>";
echo "adress3- ",$add3,"<br>";
echo "postcode- ",$postcode,"<br>";
echo "Email- ",$EM,"<br>";
echo "mobile- ",$mob,"<br>";
echo "sex of camel- ",$sex,"<br>";
echo"camel name-", $cam, "<br>";
echo "information will be sent to you via-",$inv,"<br>","<br>","<br>";
echo "subtotal:","£",$TOT,"<br>";
echo "vat is 17.5% is:",$B,"<br>";
echo "total cost:","£",$A;
if ($cam = camelx)
require ("maledromidary.jpg");
elseif ($cam = camely)
require ("malebactrian2.jpg");
else ($cam= camelz)
require ("mollie.jpg");
?>
Now I couldnt work out how to set it up as an array cus I dont know if it is possible to do super and subvariables. So I tried it as an if statement and i did nothing. This php page is an invoice showing the data That is typed in on the form and I just want to be able to display the pictures at thebottom of the page depending on the choise that is selected.
•
•
Join Date: Sep 2006
Posts: 162
Reputation:
Solved Threads: 14
You can just turn of the php tags or echo the img tag
php Syntax (Toggle Plain Text)
if ($cam == camelx) { ?> <img src="maledromidary.jpg" alt="" /> <?php } elseif ($cam == camely) echo "<img src='malebactrian2.jpg' alt='' />"; ?>
•
•
Join Date: Jul 2007
Posts: 57
Reputation:
Solved Threads: 2
thnx for showing me that. I now have this code
if ($cam == camelx)
{
?>
<img src="maledromidary.jpg" alt="" />;
<?php
}
elseif ($cam == camely)
{
?>
"<img src='malebactrian2.jpg' alt='' />";
}
<?php
($cam== camelz)
elseif "<img src='malebactrian2.jpg' alt='' />";
?>
I am getting this error
Parse error: syntax error, unexpected T_ELSEIF in C:\xampp\htdocs\invoice.php on line 45
now line 45 is the line I have put in bold.
I see the logic in what you are saying but I dont understand why it is a parse error usually I only get that if I have missed out the semi-colon but I havnt.
if ($cam == camelx)
{
?>
<img src="maledromidary.jpg" alt="" />;
<?php
}
elseif ($cam == camely)
{
?>
"<img src='malebactrian2.jpg' alt='' />";
}
<?php
($cam== camelz)
elseif "<img src='malebactrian2.jpg' alt='' />";
?>
I am getting this error
Parse error: syntax error, unexpected T_ELSEIF in C:\xampp\htdocs\invoice.php on line 45
now line 45 is the line I have put in bold.
I see the logic in what you are saying but I dont understand why it is a parse error usually I only get that if I have missed out the semi-colon but I havnt.
the elseif needs to be inside in front of the condition, you have it on the line below in front of a string for your img tag (which also won't work right). Also, you've gotten your php code and html tangled up in the last couple of cases. Check your php tags.
Last edited by Ezzaral; Aug 3rd, 2007 at 2:39 pm.
•
•
Join Date: Jul 2007
Posts: 57
Reputation:
Solved Threads: 2
thnx a lot because it really helped. Now I read that if you put html code inside php it echos the HTML code and then the browser reads the html code so I tried to do that with this because I reaised with the other code that all pictures were showing one on top of the other and so using the echo seemed the sensible way but my browser doesnt seem to detect the html.
if ($cam == camelx)
{
echo "<img src='maledromidary.jpg' alt='' />";
}
elseif ($cam == camely)
{
echo "<img src='malebactrian2.jpg' alt='' />";
}
elseif ($cam == camelz)
echo "<img src='mollie.jpg' alt='' />";
?>
if ($cam == camelx)
{
echo "<img src='maledromidary.jpg' alt='' />";
}
elseif ($cam == camely)
{
echo "<img src='malebactrian2.jpg' alt='' />";
}
elseif ($cam == camelz)
echo "<img src='mollie.jpg' alt='' />";
?>
![]() |
Similar Threads
- Error in loading items into a Dropdown list box in an ASP .net Page (ASP.NET)
- How to rank well in msn? (Search Engine Optimization)
- Using Arrays with list boxes (Visual Basic 4 / 5 / 6)
- Beginner CSS Help/ (HTML and CSS)
- Macromedia Releases MX (Graphics and Multimedia)
Other Threads in the PHP Forum
- Previous Thread: AJAX And PHP
- Next Thread: Website that generates graphs and charts
| Thread Tools | Search this Thread |
5.2.10 action apache api array beginner beneath binary broken cakephp checkbox class classes cms code cron curl database date destroy display dynamic echo echo$_get[x]changingitintovariable... email encode error fcc file files folder form forms function functions google header howtowriteathesis href htaccess html image images include insert ip javascript joomla limit link local login mail memberships menu mlm mod_rewrite multiple multipletables mysql mysqlquery neutrality oop open passwords paypal pdf php provider query radio random record remote rss script search server sessions sockets source space sql strip_tags syntax system table template thesishelp tutorial update upload url validator variable video voteup web window.onbeforeunload=closeme; youtube






