Jump to content

Include or file gets contents?


HarryMW

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.