Hello there i need help.
im new with php and i would like to tranlate this code from ASp to PHP
<%
x=1
while (not lBE.Eof)
response.Write "&local"&x&"=" & (lBE.Fields.Item("local").Value) & "&disponible"&x&"=" &(lBE.Fields.Item("disponible").Value) &"&dimension"&x&"=" &(lBE.Fields.Item("dimension").Value)&"&ubicacion"&x&"=" &(lBE.Fields.Item("ubicacion").Value)&"&colinda"&x&"=" &(lBE.Fields.Item("colinda").Value)& "&imagen"&x&"=" &(lBE.Fields.Item("imagen").Value)&"<br>"
lBE.MoveNext
x=x+10
wend
%>
THANKS
New in php, help how to translate from ASP to PHP
Moderator: General Moderators
Re: New in php, help how to translate from ASP to PHP
It would be somewhat like this:vohyndra wrote:Hello there i need help.
im new with php and i would like to tranlate this code from ASp to PHP
<%
x=1
while (not lBE.Eof)
response.Write "&local"&x&"=" & (lBE.Fields.Item("local").Value) & "&disponible"&x&"=" &(lBE.Fields.Item("disponible").Value) &"&dimension"&x&"=" &(lBE.Fields.Item("dimension").Value)&"&ubicacion"&x&"=" &(lBE.Fields.Item("ubicacion").Value)&"&colinda"&x&"=" &(lBE.Fields.Item("colinda").Value)& "&imagen"&x&"=" &(lBE.Fields.Item("imagen").Value)&"<br>"
lBE.MoveNext
x=x+10
wend
%>
THANKS
Code: Select all
<?php
mysql_connect([host],[user],[password]) or die(mysql_error());
mysql_select_db([database name]) or die(mysql_error());
$sql="SELECT * FROM .....";
$result=mysql_query($sql) or die(mysql_error());
while($row=mysql_fetch_assoc($result)) {
extract($row);
echo "local=$local disponible=$disponible ";
echo "ubicacion=$ubicacion colinda=$colinda imagen=$imagen<br>";
}
?>Aside from connecting to the database, some of the key syntactical differences include:
- every PHP variable begins with a $
- every PHP statement ends with a ;
- echo is equivalent to response.write
- mysql_fetch_assoc() gets the next row and advances the pointer
- extract() assigns field values to variables named like the fields
- $variables are parsed when enclosed in double quotes