Forum Moderators: coopster

Message Too Old, No Replies

Pulling Data from MySQL and creating web links

         

StevieMac

4:12 am on Sep 8, 2004 (gmt 0)

10+ Year Member



Since you all helped me out before, I got another question for you....

I want to pull data from the database and create a link at the end of a table.

Thanks,

StevieMac

printf("<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td>><td>%s</td></tr>\n", $myrow["Latitude"], $myrow["Longitude"], $myrow["SSID"], $myrow["BSSID"], $myrow["Link"]"<a href=\"http://terraserver.microsoft.com/image.aspx?Lon=$myrow["Longitude"]&Lat=$myrow["Latitude"]&w=1&ref=G¦$myrow["Longitude"],$myrow["Latitude"]">Link</a>);

Zipper

8:51 am on Sep 8, 2004 (gmt 0)

10+ Year Member



So what are you looking for? how to get the values for $myrow["Latitude"], $myrow["Longitude"] etc.?

StevieMac

1:34 pm on Sep 8, 2004 (gmt 0)

10+ Year Member



yes. Into a http link.

MrSpeed

2:10 pm on Sep 8, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Are you looking for something like this? You should be able to modify the select statement, while loop and variables names to match your needs.

/* Connecting, selecting database */ 
$link = mysql_connect("localhost","joe_user", "mypassword")
or die("Could not connect : " . mysql_error());

mysql_select_db("myhost_dbname") or die("Could not select database");

$query = "SELECT * FROM tablename";
$result = mysql_query($query);
echo "<TABLE BORDER=\"0\">\n";
while($row = mysql_fetch_array($result)) {
echo "<TR><TD nowrap><a href=\"/".$row['URL']."/\">".$row['LinkText']."</a></TD></TR>\n";
}
echo "</TABLE>\n";

/* Closing connection */

mysql_close($link);

Zipper

2:26 pm on Sep 8, 2004 (gmt 0)

10+ Year Member



Assuming your table is in the following structure
table{Latitude, Longitude, SSID, BSSID}
try this,

@mysql_connect("localhost","username","password");
@mysql_select_db("database");
$sql = 'SELECT * FROM table';
$result = mysql_query($sql) or die(mysql_error());
if(mysql_num_rows($result)!= 0){
echo "<table>";
while($row = mysql_fetch_array($result)){
echo "<tr><td>$row[0]</td><td>$row[1]</td><td>$row[2]</td><td>$row[3]</td><td><a href=\"http://terraserver.microsoft.com/image.aspx?Lon=$row[1]&Lat=$row[0]&w=1&ref=GĻ$row[1],$row[0]\">Link</a></td></tr>\n";
}
echo "</table>";
}

else, try modifying the sql query.

$sql = 'SELECT latitude, longitude, ssid, bssid FROM table';

StevieMac

4:54 pm on Sep 8, 2004 (gmt 0)

10+ Year Member



MrSpeed & Zipper....

Thanks for the help! It works great.

StevieMac