Element clicked id= select*from 'id'

Hi Guy’s, back again to beg mercy of the script gods. Please let me know if this even works. I’m trying to get a ul onclick function that will use the uls li element clicked id to write SELECT * FROM “.id.”
External.js


function getproduct(i){
if(i=' '){
document.getElementById('f1').innerHTML=' ';
}
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("f1").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","getproduct.php?q="+i,true);
xmlhttp.send();
}
 
var jewelry= document.getElementById('jewelry').childNodes;   
for (i = 0; i < jewelry.length; i++) {   
if (jewelry[i].className == 'item') {  // excludes class="item disabled" 
jewelry[i].onclick = function() {   
alert(this.id+': Is sending your request.');  // this actually gets the right id
var i=this.id;
alert(i); //alerts correct id
getproduct(i);
}   
}   
} 

window.onload=getproduct();

getproduct.php


<?php
$q=$_GET["q"]; // error "undefined index":q at line 1 syntax error check your etc.

$link=mysql_connect("localhost","root","root")or die(mysql_error( ));

mysql_select_db("bwi",$link) or die(mysql_error( ));

$query=mysql_query("SELECT * FROM '.q.'")or die(mysql_error( ));

:injured:

if(i=’ '){

Are you really assigning a space to i after going to all that trouble to set it to the id or have you simply left out the other =

Try coding it as

if(’ '===i){

Hey Mr. Chapman glad to hear from you, will check it out as soon as I get back from walkin the dogs. Something like ’ '===i checks to see if the string contains i ? Brilliant. Wierd but brilliant. As long as 'SELECT*FROM ‘.q.’ is a standard practice for get or post, I’ll be happier than I can say.

Hi Steve Just tried your if statement and drew this error again. I’m not sure but I think it might be the SELECT*FROM ‘“.q.”’" syntax? even though the error reffers to line one.

Notice: Use of undefined constant q - assumed ‘q’ in D:\use_ide_1\UniServer\www\getproduct.php on line 8
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘‘q’’ at line 1

External.js


function getjewelry(i){
if(' '===i){
document.getElementById('f1').innerHTML=' ';
}
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("f1").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","getproduct.php?q="+i,true); //might be problem?
xmlhttp.send();
}
 
var jewelry= document.getElementById('jewelry').childNodes;   
for (i = 0; i < jewelry.length; i++) {   
if (jewelry[i].className == 'item') {  // excludes class="item disabled" 
jewelry[i].onclick = function() {   
alert(this.id+': Is sending your request.');  // this actually gets the right id
var i=this.id;
alert(i); //alerts correct id
getjewelry(i);
document.getElementById('f1').className='silver'; //actually loads logo class silver bcground img in f1?
//when I use className='i' f1 div just shows error
alert(f1.innerTML); //returns 'undefined' ?
}   
}   
}

getproduct.php


<?php
$q=$_GET["q"]; //syntax to use near ''q'' at line 1
$link=mysql_connect("localhost","root","root")or die(mysql_error( ));

mysql_select_db("bwi",$link) or die(mysql_error( ));
//Use of undefined constant q - assumed 'q' line 8
$query=mysql_query("SELECT * FROM [B]'".q."'[/B]")or die(mysql_error( ));

Defining the constant ‘i’ as ‘q’ might be the problem:sick:

(“GET”,“getproduct.php?q=”+i,true);