Jump to content

[SOLVED] Using If statement to assign a variable with data


Recommended Posts

Hey all I am trying to use an if statement thing to assign data to a variable. Using the if statement I want to grab data from another variable which is getting its data from a html select form. Basically I want to pull two different things from the select form that are related to the one thing if you get that lol. So my code is like this (simplified):

 

<select name="website">
<option value="100-01">Url1</option>
<option value="100-02">Url2</option>

<?php

$url = $_POST['website'];
$result = ""
if ($url==100-01) $result = headache;
else if ($url==100-02) $result = biggerheadache;

?>

 

I am getting an error: Parse error: syntax error, unexpected T_IF

 

I am not to sure if I am writing the if statement correctly or if this is actually the easiest way to go about doing what I want to do, any help much appreciated :D

I'm too tired to look into it too much but I can tell you that the if statement is not constructed correctly.

 

It should be:

 

if (argument) {

 

//do something

 

} else {

 

//do something else

 

}

 

Hope that gives you something to do while you wait for a better response.

you have already started a topic on this....and you marked it solved

don't double post...mark the other unsolved and continue.

http://www.phpfreaks.com/forums/index.php/topic,220650.msg1012401.html#msg1012401

 

topic closed

 

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.