OK, one thing at a time:
"Can you explain what this line does?
$selected = ($category==$catValue)?' selected="selected"':'';"
That is called a ternary operator. Basically it is a sort of shorthand format of an if/else statement. In that particular line of code it sets the value of $selected based upon the condition of ($category==$catValue).
Example:
$result = ($a == $b) ? 'true' : 'false' ;
"Since single quotes won't interpret $self, why does adding single quotes around $self work?"
It doesn't. In the code you posted you had something like this:
echo '[a href="' . $url . '"]Link[/a]';
Inthat example, the first single quote starts a literal string. The next single quote ends the literal string (the double quote is treated as part of the string). After that second single quote any variables will be interpreted by their value. There is then another single quote to start a literal string and then a final single quote at the end of the line.
You could get the same exact result with this since variable are interpreted within strings defined with double quotes. but since there are suppiosed to be double quotes as part of the string you have to escape them with a \ otherwise the interpreted would think you were ending the string when the 2nd double quote was parsed.
echo "[a href=\"$url\"]Link[/a]";
"It only works if the image is in the same folder as my php script"
Sounds to me like the path is not correct from the working directory. You either need to specify the full path from the domain OR you can specify the relative path from the working directory. So, if the script you are running is in the path "htdocs/theform" and your images are in the folder "htdocs/images", you would specify the path as "../images/theimage.jpg". The ".." means to go up one level. I think you can also specify to start from the root folder using a single period. That might be easier for you. Just right-click the broken image and check the URL. I am sure it will show that the directory path to the image is not 100% correct.
"Where do you actually use $selected?"
My mistake. It should have been included in this line:
echo " <option value=\"$catValue\"$selected>$catValue</option>\n";
Michael J