Look closely right here
$link_prefix = mysql_fetch_ARRAY($result);
here too
$linkname = mysql_fetch_ARRAY($result1);
and lastly
$linkurl = mysql_fetch_ARRAY($result2);
NOTE I capped the ARRAY for emphasis in the code.
In all those code you set a variable to the result set of an sql query so
$link_prefix[$i] would give the values of the array and so on, try that out.
You have some unnecessary code also why con't you combine the
$query = "SELECT `name` FROM `links` WHERE `position` = 1 LIMIT ${i},${j} ";
$result1 = mysql_query($query) or die('Query failed: ' . mysql_error());
$linkname = mysql_fetch_array($result1);
$query = "SELECT `URL` FROM `links` WHERE `position` = 1 LIMIT ${i},${j} ";
so you have this instead since they are in the same table.
$query="SELECT 'URL', 'name' FROM links";
$result= mysql_query($query)
and this should return your stuff in a table if you want the link to work add <a href=......>and </a> it to the code where needed.
echo "<table cellspacing= '2' border='2'";
while ($row=mysql_fetch_array($result)){
echo"<tr><td>";
echo"{$row['URL']}{$row['name']}";
echo"</td></tr>";
}
echo "</table>";