Posted by Justin Koivisto on 03/20/06 21:56
brad wrote:
> The following is a short ASP script and I would like to change it into
> a PHP script. The script of off of the W3 Schools wep
> site(http://www.w3schools.com/ajax/ajax_database.asp). I am not sure
> what would need to be changed to fit into the PHP syntax. Alright, here
> is the short script I need help with. Have at it if you want to help
> me. Thanks in advanced to any help at all.
>
> sql="SELECT * FROM CUSTOMERS WHERE CUSTOMERID="
> sql=sql & request.querystring("q")
$sql = 'SELECT * FROM customers WHERE customerid='.intval($_GET['q']);
> set conn=Server.CreateObject("ADODB.Connection")
> conn.Provider="Microsoft.Jet.OLEDB.4.0"
> conn.Open(Server.Mappath("/db/northwind.mdb"))
This stuff you'd need to use the correct connection functions in php. If
you're using ODBC for connection, check on this page:
http://www.php.net/odbc (odbc_connect)
Be sure to skim the user-submitted notes as well at the bottom of the page.
> set rs = Server.CreateObject("ADODB.recordset")
> rs.Open sql, conn
This part requires the use of a query function. I believe that odbc_exec
is the one you'll need for that.
> response.write("<table>")
> do until rs.EOF
> for each x in rs.Fields
> response.write("<tr><td><b>" & x.name & "</b></td>")
> response.write("<td> & x.value & "</td></tr>")
> next
> rs.MoveNext
> loop
>
> response.write("</table>")
You may be able to use odbc_result_all to do this...
I've never used ODBC stuff myself, and I've never connected PHP with an
Access database (nor will I ever want to).
HTH
--
Justin Koivisto, ZCE - justin@koivi.com
http://koivi.com
[Back to original message]
|