Jump to content

Seperate the content and the PHP


yakabod

Recommended Posts

I installed this script.  The script is called wFAQ 1.0.  The file that is being called is a .php that contains the content of the script.  How can I seperate the content and the PHP? I want to have the content on an .htm and have the php seperate.  Since the content is "in" the php file, this is my results:

 

http://caraudioclips.com/support.php

 

<?

include "faq_config.php";

// SHOW ADMIN HEADER
echo $admin_info[header];

// IF USER HAS CLICKED ON A QUESTION
if(isset($_GET['q_id'])) { $q_id = $_GET['q_id']; }

if($q_id != "") {
$question_query = mysql_query("SELECT * FROM faq_questions WHERE q_id='$q_id'");
$question = mysql_fetch_assoc($question_query);
if(mysql_num_rows($question_query) == 0) {
echo "<h2>An error has occurred:</h2>
You are attempting to view an FAQ question that does not exist.
";
}

echo "
<h2>$question[question]</h2>
$question[answer]
<form action='faq.php' method='POST'>
<input type='submit' value='Back to FAQ'>
</form>
";

} else {

// IF USER IS LOOKING AT THE MAIN PAGE
$totalcount = 0;
$faq_questions = mysql_query("SELECT * FROM faq_questions");

$faqcat = mysql_query("SELECT * FROM faq_categories ORDER BY c_order");
$num_of_kitties = mysql_num_rows($faqcat);
while($faqcat_info = mysql_fetch_assoc($faqcat)) {
$questions = mysql_query("SELECT q_id, c_id, question FROM faq_questions WHERE c_id='$faqcat_info[c_id]' ORDER BY q_order");


// SHOW CATEGORY NAME, IF IT CONTAINS QUESTIONS AND CATEGORY NAMES ARE TURNED ON
if(mysql_num_rows($questions) > 0) {
if($admin_info[showcats] == 1) {
echo "
<h2>$faqcat_info[category]</h2>
";
}
}


// SHOW QUESTIONS
$count = 0;
while($question = mysql_fetch_assoc($questions)) {
$totalcount++;
$count++;

// SHOW NUMBERS IF ENABLED
if($admin_info[shownumbers] == 1) {
if($admin_info[showcats] == 1) { echo "$count. "; } else { echo "$totalcount. "; }
}

echo "<a href='faq.php?q_id=$question[q_id]'>$question[question]</a><br>";
}


// ADD SPACE AFTER THIS CATEGORY
if(mysql_num_rows($questions) != 0 AND $admin_info[showcats] == 1) {
echo "<br>";
}

}
}





// SHOW HTML FOOTER
echo $admin_info[footer];



?>

 

Thank you.

Link to comment
Share on other sites

I personally don't seperate the php from html code. That is i dont separate it entirely. I first create a html page with a layout then i deside what parts of that page should be dynamic and that's where i place the php to reduce. The php code even more on my layout page I use php classes. and the use of classes might be the way you want to go. seperating php code completely with file_get_contents and str_replace from html isn't really nessescarry unless your building a CMS which really requires it

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.