Both dnast and luke9_20 have given you solid advice on solving this, but with the last piece of code that you posted, you are either ignoring their answers or unable to see the benefit of what they are suggesting. I will give you the benefit of a doubt and try to make sense of it for you.
You didn't post what the table definition is for your table, but let's assume that the column that holds your URL is called url so we can use dnast's suggestion.
Now, let's use luke9_20's suggestion of using a while loop instead of your for loop:
$query = "SELECT * FROM $table";
if ($result = mysql_query($query)) {
while ($row = mysql_fetch_array($result)) {
// print the info in field1
echo $row['field1'];
}
Personally, luke9_20 has written a better way of solving your problem, but if you want to use what you have, here is how you could combine it:
<?php
/* Start of PHP3 Script */
/* Data of SQL-server */
$server= "blah.blah.net";
/* Database username */
$user= "thisIsMyUserName";
/* Database Password */
$password= "thisIsMyPassword";
/* name of database */
$database= "thisIsMyDatabase";
/* Name of table, you can select that */
$table= "books";
/* Accessing SQL-Server and querying table */
MYSQL_CONNECT($server, $user, $password) or die ( "<H3>Server unreachable</H3>");
MYSQL_SELECT_DB($database) or die ( "<H3>Database non existent</H3>");
// $result=MYSQL_QUERY( "SELECT * FROM $table");
?>
<?php
//fetch each record in result set
$query = "SELECT * FROM $table";
if ($result = mysql_query($query)) {
while ($row = mysql_fetch_array($result)) {
/* use your echo/print statements here */
echo $row['url'];
}
}
/* Close SQL-connection */
MYSQL_CLOSE();
?>
Some comments: if you are writing code for PHP v3.x, STOP!! Do everything you need to do to upgrade to at least 4.3x. We are now in the age of PHP v5 and any code you write in PHP 3 (especially if you are new to PHP and are following old online tutorials or outdated books) will probably assume register_globals = ON as well as use deprecated naming standards for superglobals. If you are just getting your feet wet, save yourself some grief down the road and get up to date with your tools.