Any php coders out there?
21-11-2009, 14:21
|
#1
|
|
Angry is as angry does..
Join Date: Jan 2006
Location: Belfast
Posts: 2,594
|
Any php coders out there?
Can anyone recommend a ready made "news" script?
One that shows a list of headlines which once clicked opens up the relevant story.
Any tips / pointers much appreciated.
__________________
"Exercising the right to exorcise the right".
|
|
|
21-11-2009, 14:47
|
#2
|
|
Eric Cartman Wannabe
Join Date: Jun 2003
Location: Cockney geeza land
Age: 28
Services: c:\> net start punky
Posts: 13,728
|
Re: Any php coders out there?
I've never used a 3rd party one, so I can't recommend one in particular. I'm sure there are a few about if you Google, just see which works best.
If you want to tweak one or build your own, gimme a shout.
If you did want to build your own, the direction you should be looking at is parsing XML: http://uk.php.net/manual/en/book.xml.php
Headlines generate a RSS feed which is in XML (specially formatted text). You load this and parse the information you want out of it.
__________________
"We're not here for a long time, we're here for a good time" - (Mike Ness / Social Distortion)
Last edited by punky; 21-11-2009 at 14:50.
|
|
|
21-11-2009, 16:20
|
#3
|
|
Angry is as angry does..
Join Date: Jan 2006
Location: Belfast
Posts: 2,594
|
Re: Any php coders out there?
Quote:
Originally Posted by punky
I've never used a 3rd party one, so I can't recommend one in particular. I'm sure there are a few about if you Google, just see which works best.
If you want to tweak one or build your own, gimme a shout.
If you did want to build your own, the direction you should be looking at is parsing XML: http://uk.php.net/manual/en/book.xml.php
Headlines generate a RSS feed which is in XML (specially formatted text). You load this and parse the information you want out of it.
|
Punky, dependable as ever!!
PM* en route.
* This is not meant to infer that I am sending Gordon Brown round to Punky's - it's interweb "shorthand" for "private message".
__________________
"Exercising the right to exorcise the right".
|
|
|
21-11-2009, 16:44
|
#4
|
|
Eric Cartman Wannabe
Join Date: Jun 2003
Location: Cockney geeza land
Age: 28
Services: c:\> net start punky
Posts: 13,728
|
Re: Any php coders out there?
Lemme try and knock up something for ya.
---------- Post added at 15:44 ---------- Previous post was at 15:34 ----------
BTW, what version PHP do you use?
__________________
"We're not here for a long time, we're here for a good time" - (Mike Ness / Social Distortion)
|
|
|
21-11-2009, 17:07
|
#5
|
|
Angry is as angry does..
Join Date: Jan 2006
Location: Belfast
Posts: 2,594
|
Re: Any php coders out there?
Blue?
__________________
"Exercising the right to exorcise the right".
|
|
|
21-11-2009, 17:14
|
#6
|
|
Eric Cartman Wannabe
Join Date: Jun 2003
Location: Cockney geeza land
Age: 28
Services: c:\> net start punky
Posts: 13,728
|
Re: Any php coders out there?
Create a .php file which says this:
PHP Code:
<?php
phpinfo();
?>
open it and read what it says at the top.
__________________
"We're not here for a long time, we're here for a good time" - (Mike Ness / Social Distortion)
|
|
|
21-11-2009, 18:56
|
#7
|
|
Angry is as angry does..
Join Date: Jan 2006
Location: Belfast
Posts: 2,594
|
Re: Any php coders out there?
5.2.10
Like I said, "Blue".
__________________
"Exercising the right to exorcise the right".
|
|
|
21-11-2009, 19:50
|
#8
|
|
Eric Cartman Wannabe
Join Date: Jun 2003
Location: Cockney geeza land
Age: 28
Services: c:\> net start punky
Posts: 13,728
|
Re: Any php coders out there?
PHP 5 makes life a lot easier.
Have you tried this, it looks pretty good.
http://www.scriptol.com/rss/rss-reader.php
__________________
"We're not here for a long time, we're here for a good time" - (Mike Ness / Social Distortion)
|
|
|
21-11-2009, 20:28
|
#9
|
|
Angry is as angry does..
Join Date: Jan 2006
Location: Belfast
Posts: 2,594
|
Re: Any php coders out there?
Certainly looks "dinky" but I'm looking something which lists headlines as links which open news story pages when clicked.
A simple admin interface where the admin types in the date, headline and content. submits it and hey presto! a link appears.
PM (not Gordon Brown) en route.
__________________
"Exercising the right to exorcise the right".
Last edited by Mr Angry; 21-11-2009 at 20:32.
|
|
|
21-11-2009, 21:16
|
#10
|
|
Killed You
Join Date: Jul 2007
Location: Chavy Derbyshire
Age: 15
Services: Dell XPS 420.....
Internet: Be* Pro 24Mbps
Phone: HTC Touch Diamond 2
TV: 32" + Xbox 360 Elite
Posts: 1,468
|
Re: Any php coders out there?
Quote:
Originally Posted by Mr Angry
Certainly looks "dinky" but I'm looking something which lists headlines as links which open news story pages when clicked.
A simple admin interface where the admin types in the date, headline and content. submits it and hey presto! a link appears.
PM (not Gordon Brown) en route.
|
Wordpress? (like my site)
|
|
|
21-11-2009, 23:14
|
#11
|
|
Bored much?
Join Date: Feb 2008
Location: Swindon
Services: 10MB
V XL TV
iPhone 3GS
Posts: 2,913
|
Re: Any php coders out there?
http://cutephp.com/ is pretty decent. Been around for a long time aswell, i've used it in the past and has worked a treat.
|
|
|
22-11-2009, 00:45
|
#12
|
|
Eric Cartman Wannabe
Join Date: Jun 2003
Location: Cockney geeza land
Age: 28
Services: c:\> net start punky
Posts: 13,728
|
Re: Any php coders out there?
Quote:
Originally Posted by Mr Angry
Certainly looks "dinky" but I'm looking something which lists headlines as links which open news story pages when clicked.
A simple admin interface where the admin types in the date, headline and content. submits it and hey presto! a link appears.
PM (not Gordon Brown) en route.
|
Ahh I see what you mean.
I was taking the "news" bit too literally. I thought you wanted to stream headlines from BBC News or something.
Easiest way is to do this:
Create a database table (with phpMySql is easiest) . You need the following fields (as a minimum) with the data type in brackets.
Quote:
id (int) & auto increment
headline (varchar)
content (longtext)
date (datetime)
|
Or import this SQL:
Code:
CREATE TABLE IF NOT EXISTS `headlines` (
`id` int(11) NOT NULL auto_increment,
`headline` varchar(100) NOT NULL default '',
`date` datetime NOT NULL default '0000-00-00 00:00:00',
`content` longtext NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ;
Then you need to create 3 files:
connect.php - This stores the database username/password and makes the connection
PHP Code:
<?php
$username = "your_username"; $password = "your_password"; $database = "your_database";
mysql_connect("localhost",$username,$password) OR die(mysql_error());
mysql_select_db($database); ?>
admin.php - This allows you to add new news articles.
PHP Code:
<html> <h1>Admin page...</h1>
<?php
// Connect to database include("connect.php");
// Check if you are submitting a new headline if (isset($_POST['submit'])) { // Build the INSERT query $sql = "INSERT INTO headlines (`date`, `headline`, `content`) VALUES('" . date("Y-m-d H:i",time()) . "','" . mysql_real_escape_string($_POST['headline']) . "','" . mysql_real_escape_string($_POST['content']) . "')"; $result = mysql_query($sql); if (mysql_affected_rows() > 0) { echo ("<h2>Headline submitted.</h2><br /><br />"); } else { echo ("Headline NOT submitted because: " . mysql_error()); } }
// Otherwise create a new headline
// Create form to submit to back to this page ?> <form action="<?php echo($SERVER['PHP_SELF']); ?>" method="post"> <table> <tr><td>Headline</td><td><input type="text" name="headline" id="headline" size="100" /></td></tr> <tr><td>Content</td><td><textarea name="content" id="content" cols="100" rows="20"></textarea></td></tr> <tr><td colspan="2" style="text-align:center;"><input type="submit" name="submit" id="submit" value="Add headline" /></td></tr> </table> </form> </html>
headlines.php - This shows all the headlines if no parameter is passed or a specified headline if one is.
PHP Code:
<html> <head> <!-- You need this bit to wrap the headline content properly --> <style> pre { font-family:Times New Roman; white-space: pre-wrap; /* css-3 */ white-space: -moz-pre-wrap /* Mozilla, since 1999 */ white-space: -pre-wrap; /* Opera 4-6 */ white-space: -o-pre-wrap; /* Opera 7 */ word-wrap: break-word; /* Internet Explorer 5.5+ */ } </style> </head> <h1>List of headlines</h1> <?php
// Connect to database include("connect.php");
// Check whether to view a single news story or a list of headlines if (isset($_GET['h'])) { // Show headline $sql = "SELECT * FROM headlines WHERE id = " . $_GET['h']; $query = mysql_query($sql); $row = mysql_fetch_array($query); echo ("<div style=\"width:500px;\"><h2>" . $row['headline'] . "</h2></a>Published: " . date("d/m/Y G:i", strtotime($row['date'])) . "<br /><pre>" . $row['content'] . "</pre></div>"); } else { // Show headlines $sql = "SELECT * FROM headlines ORDER BY date DESC;"; $query = mysql_query($sql); while($row = mysql_fetch_array($query)) { echo ("<a href=\"headlines.php?h=" . $row['id'] . "\"><h2>" . $row['headline'] . "</h2></a>Published: " . date("d/m/Y G:i", strtotime($row['date'])) . "<br />"); // Handle preview (first 100 characters) if (strlen($row['content']) > 100) { echo (substr($row['content'],0,100) . "..."); } else { echo ($row['content']); } echo "<hr />"; } }
?>
</html>
Bear in mind this is the bear minimuim you would need with no style formatting. You'll probably want to add in author and paging but this will get you going.
Anything else you need or anything explaining, lemme know.
Edit: As Callumpy said you can use Wordpress or similar. They can be hard work to merge into an existing site so might not gain any time savings.
__________________
"We're not here for a long time, we're here for a good time" - (Mike Ness / Social Distortion)
Last edited by punky; 22-11-2009 at 00:54.
|
|
|
22-11-2009, 01:13
|
#13
|
|
Angry is as angry does..
Join Date: Jan 2006
Location: Belfast
Posts: 2,594
|
Re: Any php coders out there?
Sex on a stick.
I'll have a blast at these later today.
__________________
"Exercising the right to exorcise the right".
|
|
|
24-11-2009, 02:49
|
#14
|
|
- Israel's Son -
Join Date: Feb 2008
Location: Newcastle
Services: Freeview, Freesat, Virgin. 10mb broadband/3gb 3 dongle.
Posts: 780
|
Re: Any php coders out there?
As you guys are talking about php I was wondering if someone would be able to help me as I am a total novice when it comes to php/html.
I was wondering if it would be possible to make a page on my website where people can upload a file using my ftp details (which is pre-entered into the coding) and then once it’s done get transferred to a page (in folder view) of all uploaded files?
I have no idea in the slightest how to do this (or even if it can be dones) so does anyone know how to do it? Or can anyone point me in the direction of a pre-made script that I can use?
Thanks
|
|
|
24-11-2009, 08:54
|
#15
|
|
Programming Monkey
Join Date: Jan 2004
Location: Between Somerset and Essex
Age: 27
Services: 8MB Office MAX on Freeola,
Freeview, Freesat
Posts: 860
|
Re: Any php coders out there?
Yes that can be done using the built in FTP functions PHP has. However you would be much better using the HTTP Post method but this may restricted as to the size of files you can upload. Depending on what level of access to the server you have this may be adjustable.
There are also free Java file uplad applets out there that can display the local and remote folder tree and upload over FTP or HTTP POST. These can be embedded into a HTML page.
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT +1. The time now is 06:57.
|