Jump to content

Javascript help


jabirshah1

Recommended Posts

HI can anyone help i have a error with my code it allows me to run the while loop to echo my variables from a SQL table but wont run the javacript replying there is a error 

here are my 2 forms of coding.

 

radio_search.php

 

<?php
include "sql.php";
if ($_GET[search] == '') {
$where = "";
} else {
$where = " WHERE manufacfurer LIKE '%".$_GET[search]."%' OR model LIKE '%".$_GET[search]."%' OR further_details LIKE '%".$_GET[search]."%' id LIKE '%".$_GET[search]."%'  angle LIKE '%".$_GET[search]."%'  type LIKE '%".$_GET[search]."%' OR country LIKE '%".$_GET[search]."%'" ;
}
$dblink = mysqli_connect($mysql_host, $mysql_user, $mysql_pw, $mysql_db);
$sql_query = "SELECT * FROM sharpeners".$where." ORDER BY id,manufacturer, model";
$query_result = mysqli_query($dblink, $sql_query) OR die ("Cannot read from Product List ".mysql_error($dblink));
$num_of_rows = mysqli_num_rows ($query_result) or die ("No entries yet.");
echo "<div align=center><b>There are $num_of_rows Sharpeners in the DB</b></div>\n";
?>
<div align ="center">
<p><p><p><p><p><p></p></p></p></p></p></p>
<table border="5" cellspacing="8">
<thead>
    <tr>
    
        <th><U>Sharpener ID:</U></th>
        <th><U>Angle:</U></th>
        <th><U>Manufacturer:</U></th>
        <th><U>Model:</U></th>
        <th><U>Type:</U></th>
        <th><U>Country:</U></th>    
        <th><U>Further Details:</U></th>
    </tr>
</thead>
</div>
<?php
while ($row = mysqli_fetch_array ($query_result)) {
echo "<tr><td>".$row["id"]."</td><td>" .$row["angle"]."</td><td>".$row["manufacturer"]."</td><td>" .$row ["model"]. "</td><td>" .$row ["type"]. "</td><td>".$row ["country"]. "</td><td>".$row["further_details"]."</td></tr>\n";}
?>
</table>
 
search_radios.php
 
<?php include "sql.php"; ?>
<script language="javascript" type="text/javascript">
<!--
//Browser Support Code
function ajaxFunction(){
var ajaxRequest; 
try{
// Opera >=8.0, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer 
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// still doesn't work
alert("Your Browser is not supported.");
return false;
}
}
}
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
var ajaxDisplay = document.getElementById('ajaxDiv');
ajaxDisplay.innerHTML = ajaxRequest.responseText;
}
}
var radio = document.getElementById('radioSearch').value;
ajaxRequest.open("GET", "radio_search.php?search=" + radio, true);
ajaxRequest.send(null); 
}
//-->
</script>
<?php
// End Ajax
?>
<p>
<form>
<input type="text" id="radioSearch" name="search" onkeyup="ajaxFunction();" autocomplete="off" />
<input type="submit" value="Submit" />
</form>
</p>
<div id='ajaxDiv'>
<?php
include "radio_search.php";
?>
</div>
</body>
</html>
 
Thankyou

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.