Jump to content

asp tp php please help


acwe88

Recommended Posts

hi could somebody please convert this to php as im having real trouble

sql="SELECT * FROM CUSTOMERS WHERE CUSTOMERID="sql=sql & request.querystring("q")set conn=Server.CreateObject("ADODB.Connection")conn.Provider="Microsoft.Jet.OLEDB.4.0"conn.Open(Server.Mappath("/db/northwind.mdb"))set rs = Server.CreateObject("ADODB.recordset")rs.Open sql, connresponse.write("<table>")do until rs.EOFfor each x in rs.Fieldsresponse.write("<tr><td><b>" & x.name & "</b></td>")response.write("<td>" & x.value & "</td></tr>")nextrs.MoveNextloopresponse.write("</table>")

Thanks in advanceAlex

Link to comment
Share on other sites

$conn = odbc_connect("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . str_replace("/", "\\", $_SERVER["DOCUMENT_ROOT"]) . "\db\northwind.mdb", "", "");$sql="SELECT * FROM CUSTOMERS WHERE CUSTOMERID=" . intval($_GET['q']);$result = odbc_exec($conn, $sql);echo "<table>";while ($row = odbc_fetch_array($result)){  foreach ($row as $key => $val)  {	echo "<tr><td><b>{$key}</b></td>";	echo "<td>{$val}</td></tr>";  }}echo "</table>";

Link to comment
Share on other sites

$conn = odbc_connect("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . str_replace("/", "\\", $_SERVER["DOCUMENT_ROOT"]) . "\db\northwind.mdb", "", "");

Hi thanks for your reply i appreciate it very muchCould you explain what these lines of code are doing as it is mesiing my page upAnd im not to sure what to do about itAlso how do i connect to my mysql database?ThanksAl
Link to comment
Share on other sites

That is a connection string to connect to an Access database using ODBC.http://www.php.net/manual/en/function.odbc-connect.phpTo connect with MySQL, you will use the MySQL library.http://www.php.net/manual/en/ref.mysql.phpThere is an example on that page about using it, and links to the references for individual functions. You will replace the odbc_ functions I gave you with mysql_connect, mysql_select_db, mysql_query, and mysql_fetch_assoc.I've never tried using Access or ODBC with PHP, so I probably wouldn't be much help there. I try to stay as far away from Access as possible.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...