first, you can put those if statements into a case
[php]
switch ($m) {
case 'a':
$link = 'web1';
break;
case 'b':
$link = 'web2';
break;
case 'c':
$link = 'web3';
break;
default:
$link = 'default';
break;
}
$link = 'http://www.' . $link . '.html';
[/php]
That will improve readability, and you can add or subtract fields w/o going crazy in if statements.
Then, you need to test your sql query to see if you have gotten any results back.
[php]
$result = mysql_query("SELECT name FROM clicks WHERE name='".$m."'");
if (mysql_num_rows($result)) {
$row = mysql_fetch_array($result);
} else {
die('there were no fields returned by this query');
}
[/php]
This will only drop into the mysql_fetch_array if there are not zero rows returned. Also note that you were wrapping your $m inside of single quotes which are treated as literal, so every time you were searching fr $m and not the variable you had in mind. Look at how I cahnged your query in my example.