Re: ASP to PHP language problems
| From: | Ligaya Turmelle | Date: | Wed, 10 Mar 2004 22:40:21 +0000 |
| Subject: | Re: ASP to PHP language problems | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-180057@lists.php.net to get a copy of this message | ||
I don't know ASP but I think this is what you want:
$sql = "SELECT * FROM table WHERE Type = \"& type & \" order by
style;";
$resultID = mysql_query($sql, DBlink); // send the query and returns a
pointer to the results
while ($row = mysql_fetch_assoc($resultID)) // while there are results
give them to me as an associative array
//
results could also be returned as an array, object, or row
//
see mysql_fetch_array, mysql_fetch_object, and mysql_fetch_row respectively
{
Here is a loop
}
"Alistair Hayward" <alistair@co-sys.co.nz> wrote in message
news:20040310222514.31406.qmail@pb1.pair.com...
> Hi ,
>
> What is the equavilant in PHP to creating a recordset in ASP using a
query?
> This is what I do in PHP:
> ..................................
>
> dim Type
> Type = CStr(Request.QueryString("action")) (getting parameter from URL)
>
> Dim cnn ' ADO connection
> Dim rst ' ADO recordset
> Dim strDBPath ' path to my Access database (*.mdb) file
>
> strDBPath = Server.MapPath("/_database/database.mdb")
> Set cnn = Server.CreateObject("ADODB.Connection")
> cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath &
> ";"
>
> Set rst = cnn.Execute("SELECT * FROM table WHERE Type ='" & type &
> "'
> order by style")
> ..........................................
> I can then call any field and display it in the html by using :
> <%=rst.fields("whatever").value%>
> ..........................................
> I can also create a loop:
> <%Do While Not rstSimple.EOF%>
> do something
> <%
> rstSimple.MoveNext
> Loop
> %>
> ............................................
>
> Please can someone show me how to do the same thing in PHP?
>
> Alistair