0

I am really new to php and am attempting to create a news reader on my site.

I have gotten it running just fine in a page of its own, BUT, I need it to be inside a php include. How do I link different scripts and stylesheets in the "body" as opposed to the head?

I feel like this is really simple, but I am just not sure of the syntax.

How do I take this code from the head and make it work in the body?

<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<link href="ncahd-main.css" rel="stylesheet" type="text/css" /> 
 
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script> 
<script src="../js/jquery.zrssfeed.min.js" type="text/javascript"></script> 
 
<title>TEST</title> 
</head> 
<body> 
 
<h1>RSS</h1> 
 
<script type="text/javascript"> 
$(document).ready(function () {
	$('#test').rssfeed('..news.xml', {
		limit: 3
	});
});
</script> 
 
<div id="test"></div> 
 
</body> 
</html>
4
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by Tekkno
0

There is no standard way to include anything inside a PHP file. However, if the site is hosted by the Apache webserver and mod_include is loaded then in your PHP script you can use:

<!--#include virtual="/folder/file.ext"-->

Edited by colweb: n/a

0

Sorry, don't understand. HEAD scripts and css files are placed in the head because they are supposed to be in the head - not the body.

However, you can certainly include anything in an include file and include it anywhere in a html file.

What you can't do is run or include a php file from javascript, unless you're implementing Ajax.

For a general example to include a php file:

<?php
   include('includes/javascriptStuff.php');
?>

You could have raw javascript in this file and you can get it to run when the page reaches the client (browser) - that is after all the php has done its work. What you can't do is the opposite (run php code from js).

Hope that answers the question. Come back if not. If you're creating a generic RSS reader that reads loads of different xml files based on a list link for example - you just need javascript (jquery is great for this) - no need for php.

0

:$:$:$
Was a bit to quick with my reply. Like ardav says, there is an include in php. Server side includes is what my reply is all about and is used for including files in html.

Edited by colweb: n/a

0

Put this into a PHP file:

<?php
echo '<script type="text/javascript"> 
         $(document).ready(function () {
	 $("#test").rssfeed("..news.xml", {
		limit: 3
	});
});
</script>'
;?>

Then in your <body> use:

<?php include("news.php"); ?>

Don't quote me on the concatenation, you may have to play around with the syntax (change some of the ' and ").

Edited by Tekkno: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.