View Single Post
Old 02-05-2022, 11:37 AM  
Publisher Bucks
Confirmed User
 
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,124
Quote:
Originally Posted by k0nr4d View Post
Again I have no idea what you are doing and why you are even using loops if you are doing LIMIT 1, but maybe this will steer you in the right direction.

PHP Code:
<?php
$servername 
"localhost";
$username "user";
$password "pass";
$dbname "db";
$conn = new mysqli($servername$username$password$dbname);
if (
$conn->connect_error) {
    die(
"Connection failed: " $conn->connect_error);
}

$result $conn->query("SELECT * FROM Table WHERE Body != '' LIMIT 1");
if (
$result->num_rows 0) {
    while(
$row $result->fetch_assoc()) {
        
$sresult $conn->query("SELECT * FROM Table WHERE Keyword != '' LIMIT 1");
        while(
$srow $sresult->fetch_assoc()) {
            echo 
"<a href=\"urldotcom\">".$srow['Keyword']."</a>";
        }
    }
} else {
    echo 
"0 results";
}
?>
The code above was just copy & pasted to show what I was asking about, not the code I'm actually using, was just open in notepad lol


Basically, its for a makeshift CMS type admin area to manage a couple of sites via a crud system and on the external side of things, wanted to generate the pages using SQL outputs to save time (and be able to use predefined templates) but I also wanted to include a query in those templates to pull some niche specific data instead of having to hand code it into each template individually, I figured having that data stored in a seperate table and pulling it into the html code (stored in another table) would be the quickest way of doing that?
__________________
SOMETHING EXTREME IS COMING SOON!
Publisher Bucks is online now   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote