HarryMW Posted April 2, 2011 Share Posted April 2, 2011 Hello, I have a simply query that will if a simple two different things: $cssyn = mysql_query("SELECT `12` FROM `12345` WHERE `abc` = '$_SESSION[number]'"); $cssy = mysql_fetch_row($cssyn); if($cssy[0] == "YES") { echo "Yes"; } else { echo "No"; } The YES or NO result is stipulated earlier on so thats not the problem. But basically before I added the if statement simply would have echoed a table with all the rows etc from another query. However I would like to give the user a choice between echoeing the results into one table or a neater two. I have separated the code for the table and the queries into two separate files but say if I use: file_get_contents then it just prints the HTML and doesnt actually populate it will the queried parts. Nor if I use something like include() then it wont echo anything, which it wouldnt unless called so what I am asking is: Is there a way to get EVERYTHING from the file if the answer is YES or the other file if NO. Quote Link to comment https://forums.phpfreaks.com/topic/232526-include-or-file-gets-contents/ Share on other sites More sharing options...
HarryMW Posted April 3, 2011 Author Share Posted April 3, 2011 I have tried wrapping the table, query and while loop in a big if statement however that doesn't seem to work. Quote Link to comment https://forums.phpfreaks.com/topic/232526-include-or-file-gets-contents/#findComment-1196175 Share on other sites More sharing options...
kenrbnsn Posted April 3, 2011 Share Posted April 3, 2011 Please show us your code between tags. Ken Quote Link to comment https://forums.phpfreaks.com/topic/232526-include-or-file-gets-contents/#findComment-1196216 Share on other sites More sharing options...
j9sjam3 Posted April 3, 2011 Share Posted April 3, 2011 I will attempt to explain the differences between file_get_content and include. File get content does what it says on the tin. It liturally GETS the content and does nothing with it. It makes it act like an HTML file. So if the files content was this: <?php echo "something cool here; ?> And your page was: <?php echo file_get_content("pathToFile.php"); The page would display: <?php echo "something cool here; ?> On the other hand, if you were to have an include statement: <?php include("pathToFile.php"); The page would display: something cool here Hope this helps a little. Quote Link to comment https://forums.phpfreaks.com/topic/232526-include-or-file-gets-contents/#findComment-1196221 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.