|
-
Oct 8th, 2003, 05:41 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Simple question
How can i compare values?
i need to check the brandname, and replace it with another string (a image path). Is this code below correct? becouse it aint working here 
and i am very new to php 
VB Code:
if ($brand == "renault") {
$DealPic = "images/renault.gif";
}
Last edited by phrozeman; Oct 12th, 2003 at 02:38 PM.
There's a certain mystique when I speak, that you notice that it's sorta unique, cause you know it's me
-
Oct 8th, 2003, 08:26 AM
#2
What seems to be the problem? Do you get an error? Or are you simply not getting the results you expect?
-
Oct 8th, 2003, 02:29 PM
#3
Member
Perhaps you've got a capitalization in $brand and you didn't carry the same capitalization through into the test string. Convert them both to lowercase and see if it works
PHP Code:
if(strtolower($band) == "renault") {
$DealPic = "images/renault.gif";
}
-
Oct 11th, 2003, 05:44 PM
#4
Stuck in the 80s
Re: Simple question
Originally posted by phrozeman
How can i compare values?
i need to check the brandname, and replace it with another string (a image path). Is this code below correct? becouse it aint working here 
and i am very new to php 
VB Code:
if ($brand == "renault") {
$DealPic = "images/renault.gif";
}
If you truly want to REPLACE IT with another string, then your code would be:
Code:
if ($brand == "renault") {
$brand = "images/renault.gif";
}
That would be replacing it (the $brand) with something else. In your example, you're just creating another variable based on what $brand is.
-
Oct 12th, 2003, 08:05 AM
#5
Besides, if your code and images keep following that logic, it would be MUCH faster to write
$DealPic = "images/$brand.gif";
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Oct 12th, 2003, 02:37 PM
#6
Thread Starter
Hyperactive Member
Thanks guys, i already got it working, i made a spelling error and thats why it didn't work
There's a certain mystique when I speak, that you notice that it's sorta unique, cause you know it's me
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|