I am hoping I am using the correct language for this. I am decent at coding, but I am struggling to figure this one out.
Basically, I have a database of categories and templates. I want to make it so my small code, produces on its own, based on the categories which then pulls from the templates. I am stuck at the string making portion. When pulling the categories from the database for the tabs, I need it to also make the MySQL query string, based on some information from the categories table. The rest I can figure out, I just need to get this working. The columns in the categories table are id number shortname tabname catname. Please see the current full code below, with the exception of the actual tabs content:
<?php
$connect = mysqli_connect("localhost", "brandina_templat", "PWREMOVED", "brandina_templates");
$output = '';
$catresult = "SELECT * FROM categories";
$catquery = mysqli_query($connect,$catresult);
echo "
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
<title>Templates Sheet | Brandin Arsenault's</title>
<script src='js/bootstrap.js'></script>
<script src='js/tabcontent.js'></script>
<link href='css/bootstrap.css' rel='stylesheet' />
</head>
<body>
<div class='container'>
<br />
<h1 align='center'>Templates Sheet</h1>
<center><ul class='tabs'>";
if(!$catquery)
{
die('Invalid query: ' . mysql_error());
}
while($row = mysqli_fetch_array($catquery))
{
$id=$row['id'];
$tabname=$row['tabname'];
$catname=$row['catname'];
echo "<li class='tab-link current' data-tab='$tabname'>$catname</li>";
}
echo "</ul></center>";
INSERT QUERY HERE FOR CATEGORY, e.g. $($id)query = SELECT blah blah
echo "
</body>
</html>";
?>
Thanks in advance.
Updated Code 9/6/16 at 4PM AST:
if(!$catquery)
{
die('Invalid query: ' . mysql_error());
}
while($row = mysqli_fetch_array($catquery))
{
$id=$row['id'];
$number=$row['number'];
$tabname=$row['tabname'];
$catname=$row['catname'];
echo "<li class='tab-link current' data-tab='$tabname'>$catname</li>";
$result[$id] = "SELECT * FROM templates WHERE category=$number";
$query[$id] = mysqli_query($connect,$result[$id]);
echo "$query[$id]";
}