Someone gave me a script that works - but it doesn't work for me. I've been trying to debug it, but I'm striking out.
First, let's start with a simple query:
$sql= "SELECT COUNT(URL) AS num FROM people WHERE URL = :MyURL";
It works, where a URL is MySite/Carl_Sagan and $MyURL = 'Carl_Sagan'
I have several similar queries for various websites and sections. I want to try to merge everything into a new website that will function kind of like a mini encyclopedia. So I use UNION ALL to link several queries together, like this...
$sql = "SELECT SUM(num) FROM (
SELECT COUNT(URL) AS num FROM pox_topics WHERE URL = :MyURL
UNION ALL
SELECT COUNT(URL) AS num FROM people WHERE URL = :MyURL
UNION ALL
SELECT COUNT(Taxon) AS num FROM gz_life WHERE Taxon = :MyURL
) AS X";
$stmt = $pdo->prepare($sql);
$stmt->bindParam(':MyUrl',$MyURL,PDO::PARAM_STR);
$stmt->execute();
$Total = $stmt->fetch();
switch($Total['num'])
{
case 1:
// ETC.