Jump to content


Photo

PHP include being written to div using JS DOM?


  • Please log in to reply
3 replies to this topic

#1 austonb

austonb
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 04 September 2006 - 04:22 PM

I need to know what needs to done in order to make this work
I've got my php code that queries/results from my mysql db here
<?php
$con = mysql_connect("localhost","userr","passw*rd);
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("databasee", $con);

$result = mysql_query("SELECT * FROM fags");

while($row = mysql_fetch_array($result))
  {
  echo "<b>". $row['Question'] . "</b><br/> " . $row['Answer'];
  echo "<br />";
  }

mysql_close($con);
?>

and then I use this php include tag/command/function
<?php include("thefileurl/filename.php"); ?>

and I use it in this javascript function, which is located in an external file on my server(lamp server)
function faqclick() 
{ document.getElementById('sfhead').innerHTML="<br><h2>F.A.Q.</h2><h3>Frequently Asked Questions.</h3>";
  document.getElementById('sfcontent').align="left";  
document.getElementById('sfcontent').innerHTML="<?php include('http://hiphop-tops.com/testsite/header.php'); ?>";
  }

does anyone have any insight as to why it's not working and what I can do to make it work?

#2 radar

radar
  • Members
  • PipPipPip
  • Advanced Member
  • 645 posts
  • LocationSLC

Posted 04 September 2006 - 09:42 PM

well #1 that i could see would be your query.. i highly doubt your table is named fags it's probably faqs

#3 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 04 September 2006 - 09:57 PM

Javascript runs on the client and PHP on the Server. By the time Javascript executes, PHP is nolonger active. To do what you want to do, you need to look at an AJAX solution. You can go to the sister forum to this one AJAXfreaks.com (http://www.ajaxfreaks.com/). You can also look at the YAHOO! User Interface Library Connection Manager module (http://developer.yah...yui/connection/) which takes alot of the pain of AJAX programming away.

Ken

#4 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 04 September 2006 - 10:02 PM

well #1 that i could see would be your query.. i highly doubt your table is named fags it's probably faqs


For some wierd reason, this was the funniest post, I have ever read since I have been here.

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users