Jump to content

Javascript help


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.




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">
<table border="5" cellspacing="8">
        <th><U>Sharpener ID:</U></th>
        <th><U>Further Details:</U></th>
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";}
<?php include "sql.php"; ?>
<script language="javascript" type="text/javascript">
//Browser Support Code
function ajaxFunction(){
var ajaxRequest; 
// Opera >=8.0, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer 
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
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);
// End Ajax
<input type="text" id="radioSearch" name="search" onkeyup="ajaxFunction();" autocomplete="off" />
<input type="submit" value="Submit" />
<div id='ajaxDiv'>
include "radio_search.php";


Link to comment
Share on other sites

This thread is more than a year old. Are you sure you have something important to add to it?

Join the conversation

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

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.