Search the Community
Showing results for tags 'php mssql'.
-
Hi all, I am trying to do a query on a database that takes a variable from a html drop down box. I've tried so many different forums and can't find the answers. HTML PAGE: <html> <head> <script> function showUser(str) { if (str=="") { document.getElementById("txtHint").innerHTML=""; return; } if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else { // code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("txtHint").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","getuser.php?q="+str,true); xmlhttp.send(); } </script> </head> <body> <form> <select name="users" onchange="showUser(this.value)"> <option value="">Select ID:</option> <option value="1">Boston</option> <option value="2">NYC</option> <option value="3">UK</option> <option value="4">Paris</option> </select> </form> <br> <div id="txtHint"><b>Info will be listed here</b></div> </body> </html> PHP CODE: <?php $q = intval($_GET['q']); //connection details // db details $query ="SELECT * FROM tblExample WHERE id = '".$q."'"; $result = sqlsrv_query( $conn, $query); echo "<table> <tr> <th> Name</th> <th> Address</th> <th> Department</th> <th> Salary</th> <th> Bonus</th> </tr>"; while( $row = sqlsrv_fetch_array( $result, SQLSRV_FETCH_ARRAY) ) { echo "<tr><td>".$row[Name]."</td><td>".$row[Address]."</td><td>".$row[Department]."</td><td>".$row[salary]."</td><td>".$row[bonus]."</td></tr>"; } echo "</table>" sqlsrv_close( $conn); This doesn't seem to work, is there any way some can help with sorting this. I want to basically select a load of data that matches the query. There doesn't seem to be loads of help for this.
-
The information on the php.net documentation seems to be out of date. http://php.net/manual/en/faq.databases.php#faq.databases.mssql as the link to the necessary libraries for Linux is broken. Can you tell me, or point me to what is needed to connect to MSSQL with PHP 5.3.3/Apache on Red Hat Linux If there is more than one option, we would like to know what they are and the installation details. Thanks