Jump to content

Use a zipcode from database to fill in link to weather report


KitCarl

Recommended Posts

I created weather links by hand for several zipcodes like this and put them in a column in the database, but that seems to be poor use of the database  ;D

<a href="http://www.weather.com/weather/tenday/07461" target="_blank"> Weather</a>

 

I would like have a self generating link using the zipcode column from the database and here is the code from the already created zip table cell

".$row["clubZipcode"]."

 

Can someone please show me how to combine them? I can't seem to figure out all the " "'s and //'s.

 

 

Link to comment
Share on other sites

I tried a simple cut & paste with Zanus' code but I doesn't work as I used it. It works separately when tested so I know it is the implementation not the code  ;)

 

Here is the complete code which will probably make it easier to figure out.

 

$sql = "SELECT  * 
FROM BeagleClub AS B, ClubOrganization AS C, Association AS A
WHERE B.clubID = C.clubID
AND C.organizationID = A.associationID
AND C.organizationID = '1'
ORDER BY B.clubName";      // Database Query  

$result = mysql_query("$sql")  or die(mysql_error());  // Database Query result

$num_rows = mysql_num_rows($result) or die(mysql_error());


echo "<h3 align='center'>There are $num_rows IBGA clubs\n</h3>";


// Starts the table
echo "<table bgcolor=#0469B3 border=0 cellpadding=10 cellspacing=0 align='center' font-size=10px;>\n
<tr>
<th>Club Name</th>
<th>Website</th>
<th>Street Address</th>
<th>City</th>
<th>State</th>
<th>Zipcode</th>
<th>GPS Lattitude</th>
<th>GPS Longitude</th>
<th>Weather Forcast</th>
</tr>";

// Create the contents of the table.
for( $i = 0; $i < $row = mysql_fetch_array($result); $i++){
    echo "<TR>\n"

  
      
        ."<TD bgcolor=".row_color($i).">".$row["clubName"]."</TD>\n"
."<TD bgcolor=".row_color($i).">".$row["website"]."</TD>\n"
        ."<TD bgcolor=".row_color($i).">".$row["clubAddress"]."</TD>\n"  
        ."<TD bgcolor=".row_color($i).">".$row["clubCity"]."</TD>\n"  
        ."<TD bgcolor=".row_color($i).">".$row["clubState"]."</TD>\n"  
        ."<TD bgcolor=".row_color($i).">".$row["clubZipcode"]."</TD>\n"        
        ."<TD bgcolor=".row_color($i).">".$row["clubLattitude"]."</TD>\n"
        ."<TD bgcolor=".row_color($i).">".$row["clubLongitude"]."</TD>\n"
        ."<TD bgcolor=".row_color($i).">".$row["clubWeather"]."</TD>\n"
."</TR>";
}
echo "</TABLE>";
mysql_close($connection);
?>

 

When I changed the last <TD> line to

."<TD bgcolor=".row_color($i).">'<a href="http://www.weather.com/weather/tenday/' .$row["clubZipcode"]. '" target="_blank"> Weather</a>';</TD>\n"

 

This is the error message:

 

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/beagle5/public_html/ibgany.org/ibga_club_list.php on line 145

 

Hoping to learn best practices not just have passable code so critics on all the code happily accepted.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.