I seem to be stuck on a concept in database query and website development.I have a website that will reflect what data is stored in a database and the website needs to change depending on that data: therefore, my menu system will not be hardcoded in. It builds my menu system based off a query of all the models …
via PHP Website Development » Search Results » ajax:
SQL Database to php website with javascript
I seem to be stuck on a concept in database query and website development.
I have a website that will reflect what data is stored in a database and the website needs to change depending on that data: therefore, my menu system will not be hardcoded in. It builds my menu system based off a query of all the models in my database. The action of clicking on the menu will show tables without changing the page (a simple javascript “showtables” function). like so:
function showTables(TABLE_NAME)
if(TABLE_NAME != “PRINTER_TABLE”)
document.getElementById(“PRINTER_TABLE”).style.display =”none”;
if(TABLE_NAME != “show_ALL_PRINTERS”)
document.getElementById(“show_ALL_PRINTERS”).style.display =”none”;
document.getElementById(TABLE_NAME).style.display =”block”;
}I did not include all of my other if statements because there are about 15 of them. These statements will hide everything and the only show the formatted table of “TABLE_NAME” at the end of that script.
My problem is that, if all of the data will not be hardcoded in either HTML or PHP, I need to pass into my function “showTables” a model type or ID that will come from my query.
My Menu system code snipet:
- include ‘connection.php’;
- ” .$row[‘printer_model’].”
$query = “SELECT * FROM all_printers”;
$result = mysql_query($query);
while($row = mysql_fetch_array($result))
#echo “
” . $row[‘printer_model’] . “
“;
echo “
n”;
?>This puts the model into the menu system and the “PRINTER_TABLE” will access my showTables function, which then will show that table. But there are many different printer models and I need to tell my table query what specific model to get info on.
I hope this makes sense as there is a lot of logic behind it. Maybe there is an easier way..?
In my tables I have: