index.php - pulls header.php as an SQL query.
header.php - is a blank page that contains an SQL query to pull the html code from a database.
Can I include another SQL query in the header.php HTML even though the code is stored in the SQL database, not in the actual header.php file.
I know that I can include an SQL query in a regular server side php include, that contains HTML code, not an SQL query to pull the HTML code.
Can I do the same thing pulling the code out of my SQL database?
Quote:
<head>
<base href="https://gfy.com/" /><!--[if IE]></base><![endif]-->
<base href="https://gfy.com/" /><!--[if IE]></base><![endif]-->
<base href="https://gfy.com/" /><!--[if IE]></base><![endif]-->
<title>Untitled 1</title>
</head>
<body>
<?php
$servername = "localhost";
$username = "user";
$password = "pass";
$dbname = "db";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT * FROM Table WHERE Body != '' LIMIT 1";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
echo "";
// output data of each row
while($row = $result->fetch_assoc()) {
echo "".$row["Body"]."";
}
echo "";
} else {
echo "0 results";
}$conn->close();
?>
</body>
</html>
|
In the SQL table 'body' contains this:
Quote:
<a href="urldotcom">keyword</a>
|
Can I have it (the body data in the table) include the following:
Quote:
<a href="urldotcom"><?php
$servername = "localhost";
$username = "user";
$password = "pass";
$dbname = "db";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT * FROM Table WHERE Keyword != '' LIMIT 1";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
echo "";
// output data of each row
while($row = $result->fetch_assoc()) {
echo "".$row["Keyword"]."";
}
echo "";
} else {
echo "0 results";
}$conn->close();
?></a>
|
An SQL query inside an SQL query in effect?
It doesnt work when I do it like that, but its entirely possible I'm not using the right method of calling the 2nd query, if it is even possible.