PHP - How to 'parse data' from database using one method <p>I have tried a few different ways to make this work to no avail.</p> <p>Basically, I have these 4 lines that are in many functions:</p> <pre><code>function getID($URL){ //These 3 plus this comment line $parentQ = "select * from cdi_content where URL=\"$URL\""; $parentResult = mysql_query($parentQ); // Run the Query $link = mysql_fetch_assoc($parentResult); // Query Result ...continues... </code></pre> <p>That basically tells the database to check $URL and if it matches the URL string in the database, it grabs all of the data associated with that URL, and I grab what I need with </p> <pre><code>$link['ID']; </code></pre> <p>Which would give me the ID associated with the $URL URL. </p> <p>The function checks a list of conditionals that either print the 'override' variable ($ID), the default variable ($defaultID) or pulls from the server ($link['ID']), like below. The 'override' is a variable outside of the function that is currently called in by global $ID.</p> <pre><code>$ID = ''; //Overrides if set function parseData($URL){ //Initialize Query for Table Data $parentQ = "select * from cdi_content where URL=\"$URL\""; $parentResult = mysql_query($parentQ); // Run the Query return mysql_fetch_assoc($parentResult); // Query Result }; function getID($URL){ global $ID; $serverID = parseData($URL); if(empty($ID)){ if(empty($serverID)){ echo $defaultID; } else { echo $serverID['ID']; } }//end of ifs else { echo $ID; } }; </code></pre>