abitlikehomer
Members-
Posts
50 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
abitlikehomer's Achievements
Newbie (1/5)
0
Reputation
-
Sorry - that is part of the code when the second form is called. However I have corrected the mistake now and everything works! Thorpe I cannot thank you enough for all the help and support you've given me the last couple of days - you're a life saver. If your in the UK and ever up north I owe you many a pint!! Thanks I can finally mark this as closed! YAY!!!!!!!!!
-
I agree with you - that does appear to be the case but I am sure I am editting the correct pages. I shall post the code below: editStory3.php <?php session_start(); ?> <!-- Design by 2A Smooth Ltd http://www.2asmooth.com --> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta name="generator" content="HTML Tidy for Linux (vers 1 September 2005), see www.w3.org" /> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>The Kingfisher Trust</title> <meta name="keywords" content="Homeless, People, Bridlington, Kingfisher, Trust" /> <meta name="description" content="The Kingfisher Trust - Helping the Homeless" /> <link href="default.css" rel="stylesheet" type="text/css"/> <script src="calendar.js" type="text/javascript" language="javascript"></script> <style type="text/css" media="screen,projection"> @import url(calendar.css); </style> <script type="text/javascript" src="selectNewsTest.js"></script> </head> <body> <!--Header Start--> <div id="header"> <div id="menu"> <ul> <li class="active"><a href="index.php" title="">Homepage</a></li> <li><a href="news.php" title="">News</a></li> <li><a href="about_us.php" title="">About Us</a></li> <li><a href="login.php" title="">Login</a></li> <li><a href="contact us.php" title="">Contact Us</a></li> </ul> </div> </div> <!--Header End--> <!--Content Start--> <div id="content"> <div id="sidebarleft"> <div id="linksleft" class="boxed"> <div class="title"> <h2>Latest News</h2> </div> <?php $i = 0; $rssdoc = simplexml_load_file('news/updatedNewsFeed.xml'); foreach ($rssdoc->channel->item as $item) { $i++; print "<b>". $item->title."</b><br>"; print $item->description."<br>"; print "<a href =".$item->link.">News Story</a><br>"; print "<br />" ; if ($i >= 5) break; } ?> </div> </div> <div id="main"> <div class="post"> <h2 class="title"><span>Edit News Story</span></h2> <div class="intro"><img src="images/logo.jpg" alt="" width="120" height="120" class="left" /> <p>Please select which news story you wish to edit using the drop-down box below: <?php include "connection.php" ?> <?php //database connection $query = mysql_query("SELECT * FROM News ORDER BY NewsID DESC"); ?> <form action="getNewsTest.php" method="POST"> <select name="News" onchange="showNews(this.value)"><option value="" "selected">Select News article to edit</option> <?php // loop through the records while ($row = mysql_fetch_array($query)) { echo "<option value=\"{$row['NewsID']}\">{$row['Title']}</option>"; } ?> </select> </form> </p> <div id="txtHint"><b>News story will appear here</b></div> <br /> <br /> <!-- OF COURSE YOU NEED TO ADAPT NEXT LINE TO YOUR tiny_mce.js PATH --> <script type="text/javascript" src="tinymce_3_2_7/tinymce/jscripts/tiny_mce/tiny_mce.js"></script> <script type="text/javascript"> tinyMCE.init({ theme : "advanced", //mode : "textareas", mode : "exact", elements : "txtHTMLContent", plugins : "fullpage", // Theme options theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect", theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,forecolor,backcolor", theme_advanced_buttons3 : "hr,removeformat,visualaid,|,sub,sup,|,charmap,", theme_advanced_toolbar_align : "left", }); </script> <!-- OF COURSE YOU NEED TO ADAPT ACTION TO WHAT PAGE YOU WANT TO LOAD WHEN HITTING "SAVE" --> <form action="alterNews.php" method="POST" name="retrieveddetails"> <!--<input type="hidden" name="NewsID" value="<?php //$NewsID =$_POST['NewsID']; ?>"/>--> <input type="hidden" name="NewsID" id="NewsID" /> <p> Title: <input name="txtTitle" type="text" id="txtTitle"> </p> <p> Date: <input name="txtDate" type="text" id="txtDate" value="" class="calendarSelectDate" /> </p> <p> Content: <br /> <textarea name="txtContent" cols="50" rows="15" id="txtContent" ></textarea> HTML Content: <br /> <textarea name="txtHTMLContent" cols="50" rows="15" id="txtHTMLContent" ></textarea> <input type="submit" value="Save" /> </p> </form> </div> </div> </div> <div id="calendarDiv"></div> <div id="sidebarright"> <div id="linksright" class="boxed"> <div class="title"> <h2>Useful Links</h2> </div> <ul> <li><a href="http://www.shelter.org.uk">Shelter</a><br /> The UK's biggest homeless charity</li> <li><a href="http://www.eastriding.gov.uk/az/az_details_new?az_selected=599">Homeless form</a><br /> Complete this form for help and assistance from East Riding Council</li> <li><a href="http://homelessuk.org/">HomelessUK</a></li> </ul> <div id="sponsorlogo"><!--<img src="images/United logo.jpg" alt="united coop logo" />--></div> </div> </div> </div> <!--Content End--> <!--Footer Start--> <div id="footer"> <p id="legal">Copyright © 2009 Kingfisher Trust. All Rights Reserved. Designed by <a href="http://www.2asmooth.com/">2A Smooth Ltd</a>.</p> <p><a href="http://validator.w3.org/check?uri=referer"><img src= "http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0 Strict" height="31" width="88" /></a></p> </div> <!--Footer End--> <div style="font-size: 0.8em; text-align: center; margin-top: 1.0em; margin-bottom: 1.0em;"><a href="http://www.2asmooth.com/">2A Smooth Ltd</a> </div> </body> </html> selectNewsTest.js var xmlhttp; function showNews(str) { xmlhttp=GetXmlHttpObject(); if (xmlhttp==null) { alert ("Browser does not support HTTP Request"); return; } //the next couple of lines will add the information to the URL to be passed through so that the data can be retrieved. var url="getNews.php"; url=url+"?NewsID="+str; url=url+"&sid="+Math.random(); xmlhttp.onreadystatechange=stateChanged; xmlhttp.open("GET",url,true); xmlhttp.send(null); } function stateChanged() { if (xmlhttp.readyState==4) { //this will display the data that has been returned using the div element document.getElementById("txtHint").innerHTML=xmlhttp.responseText; //this will display the data that has been returned into the textbox //document.retrieveddetails.NewsID.value=xmlhttp.responseText; console.log(xmlhttp.responseText); var data = xmlhttp.responseText.split('||'); console.log(data); document.retrieveddetails.NewsID.value = data[0]; document.retrieveddetails.txtTitle.value = data[1]; document.retrieveddetails.txtDate.value = data[2]; document.retrieveddetails.txtContent.value = data[3]; //document.retrieveddetails.txtContent.value= data[3]; } } function GetXmlHttpObject() { if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari return new XMLHttpRequest(); } if (window.ActiveXObject) { // code for IE6, IE5 return new ActiveXObject("Microsoft.XMLHTTP"); } return null; } getNewsTest.php <?php include "connection.php"; if (isset($_GET['NewsID'])) { $NewsID = mysql_real_escape_string($_GET['NewsID']); $query = "SELECT Title, `Date`, Content FROM News WHERE NewsID = $NewsID LIMIT 1"; if ($result = mysql_query($query)) { if (mysql_num_rows($result)) { $row = mysql_fetch_array($result); echo $row['NewsID'] . '||' . htmlentities($row['Title']) . '||' . htmlentities($row['Date']) . '||' . htmlentities($row['Content']); } } } ?> <?php /*include "connection.php"; $NewsID=$_GET['NewsID']; $query = "SELECT * FROM News WHERE NewsID = $NewsID"; $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); while ($row = @ mysql_fetch_array($result)) { $NewsID = $row['NewsID']; $Title = $row['Title']; $Date = $row['Date']; $Content = $row['Content']; $Link = $row['Link']; } echo $NewsID.'||'.htmlentities($Title).'||'.htmlentities($Date).'||'. htmlentities($Content); // close connection mysql_close($connection); */ ?> The only other explanation I can possibly think of is that somewhere, somehow it is cashing the page and not using the correct one?
-
as requested - my current getNewsTest.php <?php include "connection.php"; $NewsID=$_GET['NewsID']; $query = "SELECT * FROM News WHERE NewsID = $NewsID"; $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); while ($row = @ mysql_fetch_array($result)) { $NewsID = $row['NewsID']; $Title = $row['Title']; $Date = $row['Date']; $Content = $row['Content']; $Link = $row['Link']; } echo $NewsID.'||'.htmlentities($Title).'||'.htmlentities($Date).'||'. htmlentities($Content); // close connection mysql_close($connection); ?> Thing I have done what you mean there Is the below code what you meant about the html entities? echo $NewsID.'||'.htmlentities($Title).'||'.htmlentities($Date).'||'. htmlentities($Content);
-
I changed my php like how you suggested, the code currently looks like: echo $NewsID.'||'.$Title.'||'.$Date.'||'. $Content; and then: if (xmlhttp.readyState==4) { //this will display the data that has been returned using the div element document.getElementById("txtHint").innerHTML=xmlhttp.responseText; //this will display the data that has been returned into the textbox //document.retrieveddetails.NewsID.value=xmlhttp.responseText; console.log(xmlhttp.responseText); var data = xmlhttp.responseText.split('||'); console.log(data); document.retrieveddetails.NewsID.value = data[0]; document.retrieveddetails.txtTitle.value = data[1]; document.retrieveddetails.txtDate.value = data[2]; document.retrieveddetails.txtContent.value = data[3]; //document.retrieveddetails.txtContent.value= data[3]; } Yes there is HTML content within the content page.
-
Can you give me an example of how it should be done then if you can't echo comments out like that? I did what the original poster has done - copied it straight from the W3Schools website but it won't work for me. It looks like it is the closing tag like you say but I don't understand how to get around that. Thanks.
-
If I can get it done with one form then that is fine, I'm just not sure how to. I have tried looking through the tutorials on the W3Schools website and some work for me others don't. I can't get things to display using XML - just the Textproperty. I don't know enough on either AJAX or Javascript really but I am trying. Anybody know of any other good tutorials out there? Basically what I am trying to do is to select an option from a drop down menu - populate the other appropriate fields which can then be editted and finally saving off the editted version of the form. It seems near impossible to do. So far I can select the data and populate the form areas, but it populates the entire string rather than parts of it - this is where returning the data as xml would help but for some reason I can't get that to work either. Any help please....