ASP --> PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
quadoc
Forum Contributor
Posts: 137
Joined: Fri Jul 01, 2005 5:33 pm
Location: Atlanta, GA

ASP --> PHP

Post by quadoc »

I've the following code in ASP and I want to convert it to PHP but not quite know how. Could someone good with PHP and ASP show me how? Thanks... :?

Code: Select all

<% 
dim tmpcity
dim tmpcity
						
if Request.Form("hidCity") <> "" then
   tmpcity= Request.Form("hidCity")
else
   tmpcity=0
end if 
%>

<SCRIPT LANGUAGE=javascript>

function selcity(obj)
{
document.getElementById("hidCity").value=obj.options[obj.options.selectedIndex].value

   if(document.getElementById("hidCity").value!=0)
   {					
      document.getElementById ("frmcity").submit()
   } 
}
</SCRIPT>
<form name="frmcity" id="frmcity" method="post" action="findapub.asp">
<input type="hidden" name="hidCity" id="hidCity" value="<%= tmpcity%>">
</form>

<form id="frmnew" name="frmnew" method="post" action="publist.asp">

City:-
<%
dim rscity
set rscity = GetRecordSet("SELECT * FROM Cities order by cityname")
%>
<select name="dropbox3" ID="SelectCity" onchange="javascript:selcity(this)">
<option value="">Select a City</option>
   <%while not rscity.EOF %>
      <option value="<%= rscity("cityid")%>" <%if cint(tmpcity) = cint(rscity("cityid")) then%> selected <%end if%>><%= rscity("cityname")%>
      </option>
   <%rscity.movenext : wend%>
</select>

Area-
<%
dim rsarea
set rsarea = GetRecordSet("SELECT Areas.areaid, Areas.City, Areas.Area FROM Areas WHERE Areas.City=" & tmpcity)
%>

<select NAME="dropbox">
   <option value="Area0">Any</option>
   <%while not rsarea.eof%>
         <option value="<%= rsarea("areaid")%>"><%= rsarea("Area")%></option>
   <%rsarea.movenext : wend%>
</select>
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

You might want to show the part where you have trouble.. because it seems pretty trivial do "translate"..

http://phplens.com/phpeverywhere/node/view/30 gives a nice side-by-side introduction ;)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

here's a start

Code: Select all

<?php

$tmpcity = (empty($_POST['hidCity']) ? '' : $_POST['hidCity']);

?>
<SCRIPT LANGUAGE=javascript>

function selcity(obj)
{
document.getElementById("hidCity").value=obj.options[obj.options.selectedIndex].value

   if(document.getElementById("hidCity").value!=0)
   {                    
      document.getElementById ("frmcity").submit()
   }
}
</SCRIPT>
<form name="frmcity" id="frmcity" method="post" action="findapub.asp">
<input type="hidden" name="hidCity" id="hidCity" value="<%= tmpcity%>">
</form>

<form id="frmnew" name="frmnew" method="post" action="publist.asp">

City:-
<?php

$rscity = mysql_query('SELECT * FROM Cities order by cityname') or die(mysql_error());

?>
<select name="dropbox3" ID="SelectCity" onchange="javascript:selcity(this)">
<option value="">Select a City</option>
<?php
while($row = mysql_fetch_assoc($rscity))
{
  echo '      <option value="'.$row['cityid'].'" '.(intval($tmpcity) == intval($row['cityid']) ? 'selected' : '').'>'.$row['cityname'].'</option>'."\n";
}
?>
</select>
you can figure out from that the rest ;)
User avatar
quadoc
Forum Contributor
Posts: 137
Joined: Fri Jul 01, 2005 5:33 pm
Location: Atlanta, GA

Post by quadoc »

Thanks a lot for the quick tips guys. I'll give it a try... :D
Post Reply