Author |
Topic |
chinedu
Starting Member
8 Posts |
Posted - 2004-02-25 : 12:27:56
|
I need your assistance, please.This code is supposed to go through a list of addresses and display them all with links.Instead, what is happening is that it displays all the addresses but only the first one has a link.The rest have no links with the message "no coordinates".I looked at an existing application and all of the addresses listed have links.It's got do with my loop.Can you please take a look.I have only included relevant code.cnt = 0%><table width="100%"><%Do Until cur.EOF cnt = cnt + 1 sit = cur(5).Value & " " & cur(0).Value & " " & cur(6).Value ileft = cur(1).Value - 500 ibottom = cur(2).Value - 500 iright = cur(3).Value + 500 itop = cur(4).Value + 500 pin = cur(5).Value if ileft <> -250 Then if cnt = 1 Then psn = ileft & " " & ibottom & " " & iright & " " & itop%> <tr> <td> <Font size=3 color=#330099><B> Click below on address to display the map </b></font> </tr> <tr> <td> <a href="#" onClick="zoomToExtent('<%=psn%>','<%=pin%>');return false;"> <font size="-1"><%=sit%></font> </a> </td> </tr><% Else%> <tr> <td><font size="-1"><%=sit%> (no coordinates)</font></td> </tr><% End If End If cur.MoveNextLoop%></table><%if cnt = 0 Then%> <Center><B>No results</center><%End IfThanks in advance |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2004-02-25 : 12:35:30
|
Where's the SQL Server code?Tara |
|
|
ditch
Master Smack Fu Yak Hacker
1466 Posts |
Posted - 2004-02-25 : 12:39:10
|
It could be that the value of ileft is always -250ie the value of your second column returned from the sql statement is always 250.Duane. |
|
|
chinedu
Starting Member
8 Posts |
Posted - 2004-02-25 : 12:42:40
|
the sql is in postGres.Here it is anyway: situs = Request.form("situs")SQL = "select name, xmin(the_geom), ymin(the_geom), xmax(the_geom), ymax(the_geom), " _ & " str_number, ' ('||community||', '||zip_code||')' " _ & " from racks" _ & " where address_srch ## '" & Replace(Trim(situs)," ","%") & "' " _ & " order by name, str_number" |
|
|
ehorn
Master Smack Fu Yak Hacker
1632 Posts |
Posted - 2004-02-25 : 12:46:22
|
You have intiialized a variable called cnt. Your do loop is incrmementing cnt but your condition is evaluating whether cnt=1 so you are only writing the link for the first record.<%cnt = 0Do Until cur.EOF cnt = cnt + 1 if cnt = 1 Then <a href="#" onClick="zoomToExtent('<%=psn%>','<%=pin%>');return false;"> Else End If cur.MoveNextLoop%> |
|
|
chinedu
Starting Member
8 Posts |
Posted - 2004-02-25 : 12:57:20
|
Can I ask for your help in re-arranging this, please? |
|
|
ehorn
Master Smack Fu Yak Hacker
1632 Posts |
Posted - 2004-02-25 : 13:16:00
|
[code]<%If not cur.EOF Then%><table width="100%"><% Do Until cur.EOF sit = cur(5).Value & " " & cur(0).Value & " " & cur(6).Value ileft = cur(1).Value - 500 ibottom = cur(2).Value - 500 iright = cur(3).Value + 500 itop = cur(4).Value + 500 pin = cur(5).Value If ileft <> -250 Then psn = ileft & " " & ibottom & " " & iright & " " & itop%> <tr><td><Font size=3 color=#330099><B>Click below on address to display the map</b></font></td></tr> <tr><td><a href="#" onClick="zoomToExtent('<%=psn%>','<%=pin%>');return false;"><font size="-1"><%=sit%></font></a></td></tr><% Else%> <tr><td><font size="-1"><%=sit%> (no coordinates)</font></td></tr><% End If cur.MoveNext Loop cur.Close Set cur = Nothing%></table><%Else%> <Center><B>No results</center><%End If%>[/code] |
|
|
chinedu
Starting Member
8 Posts |
Posted - 2004-02-25 : 13:18:01
|
You are an angel.May God Bless your heart.Thank you!! |
|
|
ehorn
Master Smack Fu Yak Hacker
1632 Posts |
Posted - 2004-02-25 : 13:23:57
|
You're quite welcome. Glad that worked for you |
|
|
|