PHP - Like Facebook News Feed
I was wondering what approach you would take to code a news feed like Facebook has.
I have a status, users, and photo mysql tables. Would you create a new table called "feed" and have a query run everytime someone updates, inserts, etc anything in those three tables? or something else? What would be the most efficient way to code a news feed? Thanks in advanced! Similar TutorialsHow does facebook do their news feed? Or can you think of an algorithm that will do this effectively? I thought of an algorithm, but it's not that effective. My algorithm goes like this, choose 10 random friends from their friends list, and then put the latest updates of these friends into an array in order, then output the updates onto the feed in order. The problems with this algorithm are that this makes the feed change every time because there are new random friends shown. Then there's the problem of choosing friends that are inactive, therefore showing updates from a long time ago. Any suggestions? What's the best way to create a news feed? How would you guys do it? Would you have to have a time stamp stored for when each action occurred? I am working on a feed but am getting the nesting wrong, the </event> is appearing at the end of the whole feed and not at the end of the particular event. Here is a link to the feed http://www.horseeventsuk.com/events-feed-test.php and my code is Code: [Select] ?> <?php :'( $output_as_html=false; if ($output_as_html) echo '<html><head><title>Events Feed</title></head><body><h1>Events Feed</h1>'; $xml='<events>'; $sql="SELECT * FROM `events` WHERE event_status='live' ORDER BY event_created DESC LIMIT 3;"; $xml.='<event>'; $result=mysql_query($sql); if ($result) { while ($row=mysql_fetch_array($result)) { $event_id=$row['event_id']; $venue_id=$row['ven_id']; $county_id=FindVenueCountyId($venue_id); //print("Found event ".$event_id.'<br />'); $xml.=EchoRowItem($row,'title',$output_as_html); //$xml.=EchoRowItem($row,'description',$output_as_html,'event_details'); $xml.=EchoTag('contact_email','gilly@rackfield.co.uk',$output_as_html); $xml.=EchoTag('county',FindVenueCountyName($venue_id),$output_as_html); $xml.=EchoTag('postcode',FindVenuePostcode($venue_id),$output_as_html); $xml.=EchoTag('website_address',BuildEventURL($event_id,$county_id),$output_as_html); $xml.=EchoRowItem($row,'startdate',$output_as_html); $xml.=EchoTag('category','Animals, Convservation',$output_as_html); $xml.=EchoTag('category','Sport',$output_as_html); $xml.=EchoTag('category','Exhibitions, Shows',$output_as_html); } } $xml.='</event>'; $xml.='</events>'; if ($output_as_html) echo '</body></html>'; else { // serve the xml file header("Content-type: text/xml"); echo '<?xml version="1.0" encoding="UTF-8"?>'; echo $xml; } exit; When a post is approved I only want $details = $_POST['newstitle']; update_user_actions(8, $details); Being posted once with the corresponding news article title. Any way to achieve this? Right now it is looping through all of the titles and is posting them all. Code: [Select] foreach($posts as $post) { $displayName = ucwords("${post['firstname']} ${post['lastname']}"); if (isset($_POST['approve'])) { if(is_array($_POST['approve'])) { $keys = array_keys($_POST['approve']); $id = $keys[0]; $details = $_POST['newstitle']; update_user_actions(8, $details); $sql = "UPDATE `news` SET `newsdate` = NOW(), `approved` = 1 WHERE `id` = '$id'"; header("Location: " . $_SERVER['PHP_SELF'] . "?" . $_SERVER['QUERY_STRING'] ); } } else if (isset($_POST['deny'])) { if(is_array($_POST['deny'])) { $keys = array_keys($_POST['deny']); $id = $keys[0]; $sql = "UPDATE `news` SET `newsdate` = NOW(), `approved` = -1 WHERE `id` = '$id'"; header("Location: " . $_SERVER['PHP_SELF'] . "?" . $_SERVER['QUERY_STRING'] ); } } else if (isset($_POST['delete'])) { if(is_array($_POST['delete'])) { $keys = array_keys($_POST['delete']); $id = $keys[0]; $sql = "DELETE FROM `news` WHERE `id` = '$id'"; header("Location: " . $_SERVER['PHP_SELF'] . "?" . $_SERVER['QUERY_STRING'] ); } } if(isset($sql) && !empty($sql)) { mysql_query($sql) or die(mysql_error()); } ?> Hi guys i have been racking my brains been on about 5 different forums now with no joy either.. so here goes I am looking for a PHP news script thing, so I can have a column on the right hand side of my home page updating students results in passing or failing. I have looked and looked for php news scripts and none work they all are defect i am using a windows server, using wampserver to test my files locally.. any ideas or help.. would be oh so much appreciated Hi all, i have a form for add-/edit- news. my fields are :id postdate title newstxt formember preimg img1 img2 img3 authr. i store (modified by concat date)names of news images in table and upload theme in folder /dir/newsimg. i want my images in jpg/gif format and for preimage (103*103 pixel & <5KB) and for img1,2,3 (width:650 pixel & <50KB ). Here is my (multipart)form: <form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>" enctype="multipart/form-data"> <div><input id="post_title" type="text" size="30" tabindex="1" value="news title" /></div> <textarea cols="80" rows="10"></textarea> <div > <h3>Just For Members:</h3> <ul> <li> <label><input type="checkbox" name="chbox" />yes</label></li> </ul><BR/> <ul> <h4>news pics</h4> <li><p>preimg pic must be 103*103 pixel and maxsize <5kb. </p></li> <li><p> for image1,image2,image3 weightsize must ebe 650pixel and maxsize mustbe <50 kb. </p></li> <li> <INPUT TYPE=file NAME="preimg" size=20 accept="image/jpeg,image/gif"> </li> <li><INPUT TYPE=file NAME="image1" size=20 accept="image/jpeg,image/gif"> </li> <li><INPUT TYPE=file NAME="image2" size=20 accept="image/jpeg,image/gif"> </li> <li><INPUT TYPE=file NAME="image3" size=20 accept="image/jpeg,image/gif"> </li> </ul> <p> <input type="submit" value="preview" /> <input type="submit" value="save" /> </p> </div> </form> in INSERT and for TEST MY IMAGES what should i add? my php code is : include_once '../../config.inc.php'; if (!include '../autorization.php') { echo 'Access denied!'; exit (); } if ($_POST['submit']) { $SQL = 'INSERT INTO news VALUES(?:for images); if (!(mysql_query ($SQL))) { exit ('Can\'t PUBLISH news!'); ; } if ($_FILES['logo']['name']) { if (copy ($_FILES['preimg']['tmp_name'], $documentroot . ('' . ' /dir/newsimg/' . NOW() . '.') . substr ($_FILES['preimg']['type'], 6))) { unlink ($_FILES['logo']['tmp_name']); } } if ($_FILES['image1']['name']) { if (copy ($_FILES['image1']['tmp_name'], $documentroot . ('' . ' /dir/newsimg/' . NOW() . '.') . substr ($_FILES['image1']['type'], 6))) { unlink ($_FILES['image1']['tmp_name']); } } if ($_FILES['image2']['name']) { if (copy ($_FILES['image2']['tmp_name'], $documentroot . ('' . ' /dir/newsimg/' . NOW() . '.') . substr ($_FILES['image2']['type'], 6))) { unlink ($_FILES['image2']['tmp_name']); } } if ($_FILES['image3']['name']) { if (copy ($_FILES['image3']['tmp_name'], $documentroot . ('' . ' /dir/newsimg/' . NOW(). '.') . substr ($_FILES['image3']['type'], 6))) { unlink ($_FILES['image3']['tmp_name']); } } } TNX. I have this code.. <?php if($_SERVER['REQUEST_METHOD'] == 'POST') { mysql_query("INSERT INTO blog (date, name, desc) VALUES ('" . date("Y-m-d") . "', '". realEscape($_POST['name']) ."', '". realEscape($_POST['desc']) ."') ") or die(mysql_error()); echo "News Added."; } ?> <center><h1>Adding News</h1> <form action="news.php" method="POST"> Your News Name:<br> <input id="name" type="text" name="name" autocomplete="off" maxlength="25"><br>Your News Description: <br> <textarea name="desc" id="desc" rows="3" cols="60" maxlength="250"> </textarea><br> <input type="submit" name="submit" value="Add News"> </form> And the error is Code: [Select] You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'desc) VALUES ('2010-09-02', 'vcv', ' xcvxc')' at line 1 Note: vcv and xcvxc are the inputs we(I) used for a test so we(I) could get the error. Before I posted in here about a content management system for posting news. I was wondering how I could make so that when you fill out a form and send all the data to the database, it creates a new page from a template and includes that data within it? I know I asked this before, and some mentioned the _get method, but im using _post to process the form data and have no idea where to integrate the _get method. Here's the form in question: Code: [Select] <form action="http://www.djsmiley.net/cms/news/process.php" method="post" id="news"> <h1>Post New Article</h1> <p>Please fill out all of the following fields:</p> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td height="55" class="cmsNewsformText">Type*:</td> <td><font size="1"> <input name="type" type="text" class="Form1" size="50" /> </font></td> </tr> <tr> <td height="55" class="cmsNewsformText">News Topic/Title*: </td> <td><font size="1"> <input name="title" type="text" class="Form1" size="50" /> </font></td> </tr> <tr> <td height="55" class="cmsNewsformText">Username*:</td> <td><font size="1"> <input name="user" type="text" class="Form1" value="DJ Smiley" size="50" /> </font></td> </tr> <tr> <td height="55" class="cmsNewsformText">Url*:</td> <td><font size="1"> <input name="url" type="text" class="Form1" size="50" /> </font></td> </tr> <tr> <td height="55" class="cmsNewsformText">Message*:</td> <td><font size="1"> <textarea name="message" cols="43" rows="10" class="TextField1"></textarea> </font></td> </tr> <tr> <td height="55" class="cmsNewsformText"> </td> <td><font size="1"> <input name="Submit" type="submit" class="Button1" value="Submit" /> <input name="Submit2" type="reset" class="Button1" value="Reset" /> </font></td> </tr> </table> </form> and here's the code that sends the data from the forms to the database: Code: [Select] <?php $user=$_POST['user']; $title=$_POST['title']; $message=$_POST['message']; $type=$_POST['type']; $url=$_POST['url']; mysql_connect("hostname", "username", "password") or die(mysql_error()); mysql_select_db("database") or die(mysql_error()); $sql = sprintf("INSERT INTO mynews (user, title, message, type, url) VALUES ('%s', '%s', '%s', '%s', '%s')", mysql_real_escape_string($user), mysql_real_escape_string($title), mysql_real_escape_string($message), mysql_real_escape_string($type), mysql_real_escape_string($url)); $result = mysql_query($sql); Print "The article has successfully been posted"; ?> can someone help or at least point me in the right direction? Hello everyone, I'm making a site with PHP script and PHPmyadmin database, i need some help with how to add news and then edit them or delete them on the site, not in the Database(if that is even possible to do it there), so far i can only delete the news, but when i try to add new stuff i just get the error message of my code, which is not very nice of it but hey, i'm a noob at this PHP so i must be doing something wrong. this is the code i have for the current situation. Code: [Select] <?php include_once( 'database_functions.php' ); $connectID = connectToDatabase( 'login' ); mysql_set_charset( 'utf8', $connectID ); $categories = mysql_query('SELECT * FROM ref_categories', $connectID); if( @$_POST && @$_POST['submitted'] && ( !@$_GET[ 'id' ] ) ) { $title = ( $_POST[ 'topic_name' ] ); $topic = ( $_POST[ 'topic_desc' ] ); //write to database mysql_query ( "INSERT into news (title, topic) VALUES ('$title', '$topic')", $connectID ) or die ("Unable to insert record into database"); print "Record successfully added"; } elseif( !$_POST && $_GET && $_GET['id'] ) { $id = $_GET['id']; $thisRecord = mysql_query("SELECT * FROM ref_categories WHERE id = $id", $connectID ) or die( "Can't Read this record." ); $recordData = mysql_fetch_array( $thisRecord, MYSQL_ASSOC ); } elseif( $_POST && $_POST['submitted'] && ( $_GET['id'] ) ) { $title = ( $_POST[ 'title' ] ); $topic = ( $_POST[ 'topic_desc' ] ); $id = $_GET['id']; $success = mysql_query( "SELECT * FROM news", $connectID ) or die( "Can't Update this record" ); if( $success ) { header( 'Location: links_admin.php?updated=1' ); } } else { } ?> Got this script he http://www.codewalkers.com/c/a/Database-Articles/PHPMySQL-News-with-Comments/6/ Everything works, and I mean EVERYTHING. The problem is, when the form gets submitted, the database isn't being queried/updated/whatever. It worked at first, but after I started customizing/modifying it, it quit working. Here's my modified script: Code: [Select] <?php //**********************************// //**********************************// /*******user config variables********/ /* max number of news items to show */ //**********************************// //**********************************// $max_items = 5; //***********************// //***********************// //***********************// //make database connection// //***********************// //***********************// //***********************// $db = mysql_connect ('my hostname','my username','my password'); mysql_select_db ('my database name',$db); //If not all of the news articles are being displayed... function displayNews($all = 0) { /* bring in two variables * $db is our database connection * $max_items is the maximum number * of news items we want to display */ global $db, $max_items; /* query for news items */ if ($all == 0) { /* this query is for up to $max_items; only five news articles will be displayed */ $query = "SELECT id,title,body," . "DATE_FORMAT(date, '%m-%d-%Y') as date " . "FROM news ORDER BY id DESC LIMIT $max_items"; } else { /* this query will get all news; $max_items will be false */ $query = "SELECT id,title,body," . "DATE_FORMAT(date, '%Y-%m-%d') as date " . "FROM news ORDER BY id DESC"; } $result = mysql_query ($query); while ($row = mysql_fetch_assoc ($result)) { /* place table row data in * easier to use variables. * Here we also make sure no * HTML tags, other than the * ones we want are displayed */ $date = $row['date']; $title = htmlentities ($row['title']); $news = nl2br (strip_tags ($row['body'], '<a><b><i><u>')); $url = $row['id']; /* display the data (news) */ echo "<table border=\"0\" width=\"100%\"><tr><td><strong><h2><a href=\"{$_SERVER['PHP_SELF']}" . "?action=show&id={$row['id']}\">$title</a></h2></strong> <em>posted on $date</em> | by <strong>DJ Smiley</strong></td></tr>\n"; echo "<tr><td>"; echo stripslashes(substr($news, 0, 500)); echo "...<a href=\"{$_SERVER['PHP_SELF']}" . "?action=show&id={$row['id']}\">read more</a></td></tr>\n"; /* get number of comments from database */ $comment_query = "SELECT count(*) FROM comments " . "WHERE news_id={$row['id']}"; $comment_result = mysql_query ($comment_query); $comment_row = mysql_fetch_row($comment_result); /* display number of comments with link; add twitter, facebook, digg, and share widgets; and add email sharing widget */ echo "</table>\n<table width=\"100%\" border=\"0\"> <tr> <td width=\"6%\"><a href=\"{$_SERVER['PHP_SELF']}" . "?action=show&id={$row['id']}\"><img src=\"images/Icons/Comment/2.png\" width=\"20\" height=\"20\" class=\"fltlft2\"/></a>$comment_row[0]</td> <td width=\"13%\"><!-- FreeTellaFriend BEGIN --> <a href=\"http://www.freetellafriend.com/tell/\" onclick=\"window.open('http://www.freetellafriend.com/tell/?option=email&heading=Tell+A+Friend&bg=14&url=http%3A%2F%2Fhttp://www.djsmiley.net/index.php?action=show&id={$row['id']}', 'freetellafriend', 'scrollbars=1,menubar=0,width=435,height=500,resizable=1,toolbar=0,location=0,status=0,left='+(screen.width-435)/2+',top='+(screen.height-500)/3);return false;\"><img alt=\"Tell a Friend\" src=\"http://serv1.freetellafriend.com/s14.png\" border=\"0\" /></a> <!-- FreeTellaFriend END --></td> <td width=\"81%\"><span class=\"st_twitter_hcount\" st_url=\"http://www.djsmiley.net/index.php?action=show&id={$row['id']}\" displayText=\"Tweet\" st_title=\"{$row['title']}\"></span><span class=\"st_facebook_hcount\" st_url=\"http://www.djsmiley.net/index.php?action=show&id={$row['id']}\" displayText=\"Share\" st_title=\"{$row['title']}\"></span><span class=\"st_email_hcount\" st_url=\"http://www.djsmiley.net/index.php?action=show&id={$row['id']}\" displayText=\"Email\"></span><span class=\"st_sharethis_hcount\" st_url=\"http://www.djsmiley.net/index.php?action=show&id={$row['id']}\" displayText=\"Share\"></span></td> </tr> </table><br>"; } /* if we aren't displaying all news, * then give a link to do so */ if ($all == 0) { echo "<br><div style=\"border-radius: 10px; border: solid 2px #E5E5E5; padding: 10px; margin: 5px; background: #F6F6F6;\"></p><a href=\"{$_SERVER['PHP_SELF']}" . "?action=all\">View All Articles</a></p></div>"; } } //function for displaying only one item function displayOneItem($id) { global $db; /* query for item */ $query = "SELECT * FROM news WHERE id=$id"; $result = mysql_query ($query); $row = mysql_fetch_assoc($result); /* easier to read variables and * striping out tags */ $title = htmlentities ($row['title']); $news = nl2br (strip_tags ($row['body'], '<a><b><i><u>')); /* if we get no results back, error out */ if (mysql_num_rows ($result) == 0) { echo "This news article does not exist!\n"; return; } echo "<TABLE border=\"0\" width=\"100%\">\n"; /* displays individual article user visits */ echo "<tr><td><strong><h2><a href=\"{$_SERVER['PHP_SELF']}" . "?action=show&id={$row['id']}\">$title</a></h2></strong> <em>posted on $date</em> | by <strong>DJ Smiley</strong></td></tr>\n"; echo "<tr><td>"; echo stripslashes($news); echo "</td></tr>\n"; echo "</table>\n"; echo "<br>\n"; echo ("</table>\n<table width=\"100%\" border=\"0\"> <tr> <td width=\"6%\"><a href=\"{$_SERVER['PHP_SELF']}" . "?action=show&id={$row['id']}\"><img src=\"images/Icons/Comment/2.png\" width=\"20\" height=\"20\" class=\"fltlft2\"/></a>$comment_row[0]</td> <td width=\"13%\"><!-- FreeTellaFriend BEGIN --> <a href=\"http://www.freetellafriend.com/tell/\" onclick=\"window.open('http://www.freetellafriend.com/tell/?option=email&heading=Tell+A+Friend&bg=14&url=http%3A%2F%2Fhttp://www.djsmiley.net/index.php?action=show&id={$row['id']}', 'freetellafriend', 'scrollbars=1,menubar=0,width=435,height=500,resizable=1,toolbar=0,location=0,status=0,left='+(screen.width-435)/2+',top='+(screen.height-500)/3);return false;\"><img alt=\"Tell a Friend\" src=\"http://serv1.freetellafriend.com/s14.png\" border=\"0\" /></a> <!-- FreeTellaFriend END --></td> <td width=\"81%\"><span class=\"st_twitter_hcount\" st_url=\"http://www.djsmiley.net/index.php?action=show&id={$row['id']}\" displayText=\"Tweet\"></span><span class=\"st_facebook_hcount\" st_url=\"http://www.djsmiley.net/index.php?action=show&id={$row['id']}\" displayText=\"Share\"></span><span class=\"st_email_hcount\" st_url=\"http://www.djsmiley.net/index.php?action=show&id={$row['id']}\" displayText=\"Email\"></span><span class=\"st_sharethis_hcount\" st_url=\"http://www.djsmiley.net/index.php?action=show&id={$row['id']}\" displayText=\"Share\"></span></td> </tr> </table>"); /* now show the comments */ displayComments($id); } function displayComments($id) { /* bring db connection variable into scope */ global $db; /* query for comments */ $query = "SELECT * FROM comments WHERE news_id=$id"; $result = mysql_query ($query); echo "<h2>Comments</h2>"; /* display the all the comments */ while ($row = mysql_fetch_assoc ($result)) { //sets variables $comment = strip_tags ($row['comment'], '<a><b&><i><u>'); $comment = nl2br ($comment); $name = htmlentities ($row['name']); $time = ($row['time']); echo "<div style=\"border-radius: 10px; border: solid 2px #E5E5E5; padding: 10px; margin: 5px; background: #F6F6F6;\"><p><table border=\"0\" width=\"100%\"><tr><td><strong>$name</strong> says:</td></tr></table> <table><tr><td><img src=\"images/Icons/People/Anonymous 2.png\" alt=\"\" width=\"50\" height=\"50\"/></td><td>$comment</td></tr></table><table><tr><td>added on $time</td></tr></table></p></div>"; } /* add a form where users can enter new comments */ echo "<form action=\"{$_SERVER['PHP_SELF']}" . "?action=addcomment&id=$id\" method=post> <h2>Comment</h2><table width=\"37%\" border=\"0\"> <tr> <td width=\12%\">Name:</td> <td width=\"88%\"><label> <input type=\"text\" name=\"name\" id=\"name\" class=\"commentBoxforms\"> </label></td> </tr> <tr> <td>Comment:</td> <td><label> <textarea name=\"comment\" id=\"comment\" cols=\"45\" rows=\"5\" class=\"commentField1\"></textarea> </label></td> </tr> <tr> <td> </td> <td><label> <input type=\"submit\" name=\"submit\" id=\"submit\" value=\"Comment\" class=\"Button1\"> </label></td> </tr> </table> </form>\n"; } function addComment($id) { global $db; /* insert the comment */ $query = "INSERT INTO comments " . "VALUES('',$id,'{$_POST['name']}'," . "'{$_POST['comment']}')"; mysql_query($query); echo "Your comment has been posted!<br>\n"; echo "<a href=\"{$_SERVER['PHP_SELF']}" . "?action=show&id=$id\">Return To Previous Page</a>\n"; } /* this is where the script decides what do do */ switch($_GET['action']) { case 'show': displayOneItem($_GET['id']); break; case 'all': displayNews(1); break; case 'addcomment': addComment($_GET['id']); break; default: displayNews(); } ?> Can anyone tell me where this script is going wrong? I've literally tried EVERYTHING. I even went back to the original script and compared every single character to mine, but NO luck. PLEASE HELP! I need to set when new news is posted from 7 days to now, to put echo that it is new.. Code: [Select] while ($var = mysql_fetch_array($result)) { $name = $var['name']; $date = $var['date']; echo " - {$s_name} [new]<br />"; }Now i need to put "[new]" when news is written in past 7 days(1 week), can someone help me? I have a news code that posts news on the home page like a CMS would. How would i make it so when I post news using the code, I can use HTML within the post to change around what it looks like? Instead of just having it display the HTML like "<font color="blue">Example</font>" Regards, NW I'm lost on this one. This code works fine in Firefox, but not my IE8. I think it has something to do with the <?php echo '<?xml version="1.0" encoding="utf-8"?>'; ?> line, but i'm not sure. IE says "Internet Explorer cannot display this feed" and "A name contained an invalid character. Line: 7 Character: 701." Any ideas? <?php header('Content-Type: text/xml'); ?> <?php echo '<?xml version="1.0" encoding="utf-8"?>'; ?> <?php include('../vars.php'); ?> <rss version="2.0"> <channel> <title>Newsfeed</title> <description>News and Updates</description> <link>http://www.example.com</link> <language>en-us</language> <?php require_once("../conn.php"); $query = "SELECT * FROM news"; $data = mysqli_query($db, $query); while ($row = mysqli_fetch_array($data)) { echo '<item>'; echo ' <title>' . $row['title'] . ' - ' . substr($row['content'], 0, 32) . '...</title>'; echo ' <link>http://www.example.com/new.php?newsid=' . $row['newsid'] . '</link>'; //echo ' <pubDate>' . $row['date'] . '</pubDate>'; echo ' <description>' . $row['content'] . '</description>'; echo '</item>'; } ?> </channel> </rss> Hi I get an error when trying to add a link to my rss feed Code: [Select] <link>http://www.jobjar.co.uk/jobdetails.php?keywords=lon0014&page=1</link>Something to do with the last part of the link because when I remove the page=1 it then works. How can I resolve this? Also, will I have to manually update my xml file for rss feeds or can it be updated automatically? If so how? Thanks Hi All, I'm trying to incorporate a BBC Sport RSS Feed into my website. The following code will show me the news feeds as text and I can include the url's as text also but want to turn this into a clickable url. How do I do this, I cant work it? please help. $feed_url = "http://newsrss.bbc.co.uk/rss/sportonline_uk_edition/football/teams/s/shrewsbury/rss.xml"; // Get data from feed file $response = file_get_contents($feed_url); // Insert XML into structure $xml = simplexml_load_string($response); // Browse structure foreach($xml->channel->item as $one_item) echo $one_item->title."<BR>"; Hello, can you help me on my news article? I would like to be able to add photo on the article. Below is my codes Quote ======= html ======= <?php include_once ('post_news.php'); ?> <form Action="add_news.php" Method="post"> <input name="postdate" type="text" id="postdate"> <input name="title" type="text" id="title"> <textarea name="newstext" cols="60" rows="15" id="newstext"></textarea> <input type="submit" name="submit" value="Submit"> <input type="reset" name="reset" value="Reset"> </form> ============== php - post_news.php ============== <?php ini_set ('display_errors', 1); error_reporting (E_ALL & ~E_NOTICE); if (isset ($_POST['submit'])) { require_once ('inc/dbConfig.php'); // Define the query. $query = "INSERT INTO news (id, postdate, title, newstext) VALUES (0,'{$_POST['postdate']}', '{$_POST['title']}','{$_POST['newstext']}')"; // Execute the query. if (@mysql_query ($query)) { print "<p>Data has been added.</p>"; } else { print "<p>Could add the entry because: <b>" . mysql_error() . "</b>. The query was $query.</p>"; } mysql_close(); } ?> ===== db structure ====== id int(10) unsigned NOT NULL auto_increment, postdate timestamp(14), title varchar(50) NOT NULL, newstext text NOT NULL, PRIMARY KEY (id), KEY postdate (postdate) Hope you guys can help me. Thanks! I have manage to create my own script that add news article, however, I would like to add a comment form below the news article. How can I relate the news and the comments? also, when I delete the articles, it should also delete the comments in mysql. Your help is highly appreciated! hi i want to make a script like http://www.greatdane.ru/eng/site/news/ and i dont have problem too add dogs but i want a auto news update after specific change like the link example : after add new dog or update dog or add image to a dog the link tell exactly what i want but also it has a feature that group added dogs and send a news any one have idea for make it? it is also so similar to facebook profile that after user do something page will auto update like : user change his cover Hi, I'm currently coding a script, where I would like to post news & versions changes etc into my client's portal. So my client install the script, they login to the admin area, and they see messages from me, optionally if there's a new version available. I was thinking about doing this with cUrl, and just have a page that display my news, and then call it from the client portal, not sure about it though. What would you guys suggest? |