Jump to content

chwebdesigns

Members
  • Posts

    73
  • Joined

  • Last visited

Everything posted by chwebdesigns

  1. What I have is a news page. I add the news to this page using a form, and it saves it into a .txt file. On each line there is the next piece of news, and each line contains the following information ($pieces): Name of Person Who Posted It, Date of Post, Title of Post, News Article, Category. This is how I work out the $pieces <?php $lines = file("newsadd.txt"); $lines = array_reverse($lines); $pieces = explode("|", $lines);?> In this code $pieces[5] = Category. For example one category is "other", what I want is the PHP code to look and find all of the pieces of news in the "other" category and echo them. Cheers
  2. has anybody got any ideaS?
  3. how would you only echo the ones that the if statement has passed for example: <?php if($pieces[5] == "other"){ echo **********} Because there are other categories too for example important, events, results ect.... and on this code I only want the OTHER news items to appear. I hope this makes sense TAR From Callum
  4. Hi, I think I need an if statement for this, but i have no idea on how to write it. I have a news file that adds into a *.txt file. (with some other PHP) and I have broken the code down like this: $lines = file("newsadd.txt"); $lines = array_reverse($lines); $pieces = explode("|", $lines); I then want it to look if $pieces[5] is equal to "other" then to show all of the ones which have pieces 5 as "other" (this is the category) I hope you can understand this, From Cal PS. I am a PHP NOVICE
  5. I'm still very confused, I don't know much information at all on PHP. So if anyone could write part of the code/ give me alot of ideas on how to write it, it would be appreciated
  6. Hi all, I have a event calendar on a website I run. I was wondering if there is a PHP code which will change the background colour of the cell to grey once the date has passed. Is this possible? Any answers would be appreciated Thanks alot from cal
  7. Why don't you just use FTP? Anyway, there is abit of a code here which a wrote a while ago, so I am not too sure whether it works, ect. As I can't remember. This lets you upload any type of file to a certain folder, with a browse button too. You could, create a drop down list, or radio buttons to make it upload to a different folder. The only thing is though, I think you have to set the folder permissions to 777, before you can use this script, otherwise it just dosen't allow it. Let me know how it goes, <?php //set where you want to store files //in this example we keep file in folder upload //$HTTP_POST_FILES['ufile']['name']; = upload file name //for example upload file name cartoon.gif . $path will be upload/cartoon.gif $path= "upload/".$HTTP_POST_FILES['ufile']['name']; // change "upload/" to the location on the server if($ufile !=none) { if(copy($HTTP_POST_FILES['ufile']['tmp_name'], $path)) { echo "<h1>Successful</h1><BR/>"; //$HTTP_POST_FILES['ufile']['name'] = file name //$HTTP_POST_FILES['ufile']['size'] = file size //$HTTP_POST_FILES['ufile']['type'] = type of file echo "<strong>File Name :</strong>".$HTTP_POST_FILES['ufile']['name']."<BR/>"; echo "<strong>File Size :</strong>".$HTTP_POST_FILES['ufile']['size']."<BR/>"; echo "<strong>File Type :</strong>".$HTTP_POST_FILES['ufile']['type']."<BR/>"; } else { echo "Error"; } } ?> From Cal
  8. I don't understand what that code does. I am not too sure whether I explained this right or not, I have many rows, each with two columns, in one column there is a date (in format of Sun 10th June) and in the second column there is information about the event. After the date has passed (and abviously the event has finished too, I want the background in the two cells to turn grey ( #666666 ) (the code for the table is above) Cheers, from Cal
  9. Hi, What I have is a table (code below) and it is for an events page. What I want is after the date has gone, it changes the whole row to grey. ( #666666 ). Thanks for your help, From Cal P.S. I'm a novice at PHP & have no access to mySQL Events Table Code: <table width="567" border="1" align="center" cellpadding="0" cellspacing="0" id="events"> <tr bgcolor="#FF9933"> <td colspan="2"><div align="center"> <p><strong>JUNE</strong></p> </div></td> </tr> <tr> <td width="120"><div align="center"> <p>Sun 3rd June </p> </div></td> <td width="441"><div align="center"> <p>Int. Comp</p> </div></td> </tr> <tr> <td width="120"><div align="center"> <p>Sat 9th June </p> </div></td> <td><div align="center"> <p>Class 3 Judges Course</p> </div></td> </tr> <tr> <td width="120"><div align="center"> <p>Sun 10th June </p> </div></td> <td><div align="center"> <p>Comp</p> </div></td> </tr> <tr> <td width="120"><div align="center"> <p>Sun 24th June </p> </div></td> <td><div align="center"> <p>First Aid Course</p> </div></td> </tr> <tr bgcolor="#FF9933"> <td colspan="2"><div align="center"> <p><strong>JULY</strong></p> </div></td> </tr> <tr> <td width="120"><div align="center"> <p>Sun 1st July 07 </p> </div></td> <td><div align="center"> <p>Comp </p> </div></td> </tr> <tr> <td width="120"><div align="center"> <p>Sat 7th & <br> Sun 8th July </p> </div></td> <td><div align="center"> <p>Seminar 321</p> </div></td> </tr> <tr> <td width="120"><div align="center"> <p>Sun 15th July </p> </div></td> <td><div align="center"> <p>Grading 8 </p> </div></td> </tr> <tr> <td width="120"><div align="center"> <p>Sun 22nd July </p> </div></td> <td><div align="center"> <p>Competition 198</p> </div></td> </tr> </table>
  10. Thanks for that, just what I needed, From Cal
  11. No unfortunately it doesnt, it comes out as Sun/Jun/2007 , do I need to use an if statement? Thanks from cal
  12. Is there a way of changing the "Sunday 3rd June" to >> 03/06/07 and the same for all of the other dates. ??? cheers from cal
  13. Oh yes :S Thank you very much for that, it's just what I needed. Cheers from Cal
  14. Yes thank you, the date and competition info work fine now. Is there a way of getting it to update automatically to the date? For e.g. : The top event on the calendar at the moment is Sun 3rd June, which was yesterday, could it automatically show the next event? Thanks very much from cal
  15. That works for the Event but it doesn't work for the date. Here is the code for my table: <table width="567" border="1" align="center" cellpadding="0" cellspacing="0" id="events"> <tr bgcolor="#FF9933"> <td colspan="2"><div align="center"> <p><strong>JUNE</strong></p> </div></td> </tr> <tr> <td width="120"><div align="center"> <p>Sun 3rd June </p> </div></td> <td width="441"><div align="center"> <p>Int. Comp</p> </div></td> </tr> <tr> <td width="120"><div align="center"> <p>Sat 9th June </p> </div></td> <td><div align="center"> <p>Class 3 Judges Course</p> </div></td> </tr> <tr> <td width="120"><div align="center"> <p>Sun 10th June </p> </div></td> <td><div align="center"> <p>Comp</p> </div></td> </tr> <tr> <td width="120"><div align="center"> <p>Sun 24th June </p> </div></td> <td><div align="center"> <p>First Aid Course</p> </div></td> </tr> <tr bgcolor="#FF9933"> <td colspan="2"><div align="center"> <p><strong>JULY</strong></p> </div></td> </tr> <tr> <td width="120"><div align="center"> <p>Sun 1st July 07 </p> </div></td> <td><div align="center"> <p>Comp </p> </div></td> </tr> <tr> <td width="120"><div align="center"> <p>Sat 7th & <br> Sun 8th July </p> </div></td> <td><div align="center"> <p>Seminar 321</p> </div></td> </tr> <tr> <td width="120"><div align="center"> <p>Sun 15th July </p> </div></td> <td><div align="center"> <p>Grading 8 </p> </div></td> </tr> <tr> <td width="120"><div align="center"> <p>Sun 22nd July </p> </div></td> <td><div align="center"> <p>Competition 198</p> </div></td> </tr> </table> Thanks for your help from cal
  16. Hi, Is there a way to get the PHP code to read a line from the table and write it in a box? What I have is an events table with two columns, Date of Event & Name of Event. This is saved on a page called events.html (can be changed to .php) What I wan is on index.php I want a next event box. So what I want for it is to read from the events page, and find when the next event is, using information on dates. I have no idea on how to start this at all. If you require any other information then just ask From Cal PS ~ I'm a novice at PHP
  17. I have found this code on my computer. It was written some time ago now, by me and my uncle, so I'm not too sure if it works / what you are looking for. You have to set the permissions to the folder to "777" on your ftp. <?php //set where you want to store files //in this example we keep file in folder upload //$HTTP_POST_FILES['ufile']['name']; = upload file name //for example upload file name cartoon.gif . $path will be upload/cartoon.gif $path= "upload/".$HTTP_POST_FILES['ufile']['name']; // change "upload/" to the location on the server if($ufile !=none) { if(copy($HTTP_POST_FILES['ufile']['tmp_name'], $path)) { echo "<h1>Successful</h1><BR/>"; //$HTTP_POST_FILES['ufile']['name'] = file name //$HTTP_POST_FILES['ufile']['size'] = file size //$HTTP_POST_FILES['ufile']['type'] = type of file echo "<strong>File Name :</strong>".$HTTP_POST_FILES['ufile']['name']."<BR/>"; echo "<strong>File Size :</strong>".$HTTP_POST_FILES['ufile']['size']."<BR/>"; echo "<strong>File Type :</strong>".$HTTP_POST_FILES['ufile']['type']."<BR/>"; } else { echo "Error"; } } ?> Let me know how it goes From Cal
  18. Thanks for that "sprinkles", I was writing in parts <a href="website"> as I am more confident in writing HTML, and never realised it changes. Thanks! From Cal
  19. Thanks for that site, I'll take a look Unfortunately, the trim function doesn't seem to work. Any other suggestions?
  20. Thanks for that, I'll have to check to see if that works. If the PHP code works fine on my computers will it work the same on any viewers? I am extremley new to PHP and put together the code from different websites ect. As the code works fine, and it is just what I need. Also I don't have access to mySQL unfortunately, as the server won't allow connections to free sources and it costs way too much to have a mySQL account with them. Thanks from Cal
  21. I am having a problem again with my PHP code. It is all working fine (thanks to some help off this forum) but when I try typing in a hyperlink or an image address I always get %22 on the end of it? Is there a way of stopping this from happening. It is a news page I have the problems with. Here is the code from the Add News Page: <?php $pass = md5($HTTP_POST_VARS['password'] ) ; if($HTTP_POST_VARS['submit']) { if($pass == 'password is here') { if(strstr($HTTP_POST_VARS['name'],"Select your name")) { echo "<h1 align=\"center\">You must select your name <a href=\"javascript:history.back(-1)\"> Go back</a></h1>"; exit; } if(!$HTTP_POST_VARS['title']) { echo "<h1 align=\"center\">You must enter a title <a href=\"javascript:history.back(-1)\"> Go back</a></h1>" ; exit; } if(!$HTTP_POST_VARS['news']) { echo "<h1 align=\"center\">You must enter some news <a href=\"javascript:history.back(-1)\"> Go back</a></h1>"; exit; } if(strstr($HTTP_POST_VARS['name'],"|")) { echo "<h1 align=\"center\">Name cannot contain the pipe symbol - |<a href=\"javascript:history.back(-1)\"> Go back </a></h1>"; exit; } if(strstr($HTTP_POST_VARS['title'],"|")) { echo "<h1 align=\"center\">Title cannot contain the pipe symbol - |<a href=\"javascript:history.back(-1)\"> Go back </a></h1>"; exit; } if(strstr($HTTP_POST_VARS['news'],"|")) { echo "<h1 align=\"center\">News cannot contain the pipe symbol - |<a href=\"javascript:history.back(-1)\"> Go back</a></h1>"; exit; } $fp = fopen('../newsadd.txt','a'); if(!$fp) { echo "<h1 align=\"center\">Error opening file! Please try again. If the error continues please contact the webmaster <a href=\"javascript:history.back(-1)\" Go back</a><br><a href=\"mailto:[email protected]?subject=php error UTKD code 101\"> E-mail the webmaster</a></h1>"; exit; } $line = "|" . date("d/m/y") . "|" . $HTTP_POST_VARS['name']; $line .= "|" . $HTTP_POST_VARS['title']; $line .= "|" . $HTTP_POST_VARS['news'] ; $line = str_replace("\r\n","<BR>",$line); $line .= "\r\n"; fwrite($fp, $line); if(!fclose($fp)) { echo "Error closing file! Please try again. If the error continues please contact the webmaster <a href=\"javascript:history.back(-1)\" Go back</a><br><a href=\"mailto:[email protected]?subject=php error UTKD code 102\"> E-mail the webmaster</a>"; exit; } echo "<h1>News item added</h1>" ; } else { echo "<h1>Bad Password</h1>"; } } ?> <FORM ACTION="<?=$PHP_SELF?>" METHOD="POST" NAME="newsentry"> <p align="center"><strong>Your name:</strong><BR> <select name="name" id="name"> <option selected title="select">Select your name</option> <option>Cheif Instrucor</option> <option>Instructor 1</option> <option>Instructor 3</option> <option>Webmaster</option> </select> </p> <p align="center"><strong>Title:</strong></p> <p align="center"><strong> <input name="title" type="text" id="title" value="" size="75" maxlength="100"> </strong><BR> <strong>The News:</strong><BR> <TEXTAREA NAME="news" COLS="75" ROWS="5"></TEXTAREA> <BR> <BR> <strong>News Password:</strong><BR> <INPUT TYPE="password" SIZE="30" NAME="password"> <BR> <INPUT TYPE="submit" NAME="submit" VALUE="Post it!"> <BR> </p> </FORM> And here is the code from the news page (which displays all the news) <?php $data = file('newsadd.txt'); $data = array_reverse($data); foreach($data as $element) { $element = trim($element); $pieces = explode("|", $element); echo "<h3 align=\"center\">" . $pieces[3] . "</h3>" . "" . "<i><h5 align=\"center\">Posted by " . $pieces[2] . " on " . $pieces[1] . "</b></i></h5><p align=\"center\">" . $pieces[4] . "<br><hr><br>" ; } ?> Thanks for your help From Cal
  22. Thanks loads, this has worked perfectly! Just what I wanted, thanks lots from cal
  23. Hello, I am designing a new website for a taekwondo club in my area. Currently we have a news page, but with no facility for instructors to post. I have written a short php code which works fine, and saves the news item into a *.txt file. As I do not have any access to mySQL. I also have written the code for showing the news on a page. But I want the latest news title to appear in a box on the index. I can get just the title but I am struggling just to get the latest. Here is the php code for submitting the news article <?php $pass = md5($HTTP_POST_VARS['password'] ) ; if($HTTP_POST_VARS['submit']) { if($pass == PASSWORD) { if(strstr($HTTP_POST_VARS['name'],"Select your name")) { echo "<h1 align=\"center\">You must select your name <a href=\"javascript:history.back(-1)\"> Go back</a></h1>"; exit; } if(!$HTTP_POST_VARS['title']) { echo "<h1 align=\"center\">You must enter a title <a href=\"javascript:history.back(-1)\"> Go back</a></h1>" ; exit; } if(!$HTTP_POST_VARS['news']) { echo "<h1 align=\"center\">You must enter some news <a href=\"javascript:history.back(-1)\"> Go back</a></h1>"; exit; } if(strstr($HTTP_POST_VARS['name'],"|")) { echo "<h1 align=\"center\">Name cannot contain the pipe symbol - |<a href=\"javascript:history.back(-1)\"> Go back </a></h1>"; exit; } if(strstr($HTTP_POST_VARS['title'],"|")) { echo "<h1 align=\"center\">Title cannot contain the pipe symbol - |<a href=\"javascript:history.back(-1)\"> Go back </a></h1>"; exit; } if(strstr($HTTP_POST_VARS['news'],"|")) { echo "<h1 align=\"center\">News cannot contain the pipe symbol - |<a href=\"javascript:history.back(-1)\"> Go back</a></h1>"; exit; } $fp = fopen('newsadd.txt','a'); if(!$fp) { echo "<h1 align=\"center\">Error opening file! Please try again. If the error continues please contact the webmaster <a href=\"javascript:history.back(-1)\" Go back</a><br><a href=\"mailto:[email protected]?subject=php error UTKD code 101\"> E-mail the webmaster</a></h1>"; exit; } $line = date("d/m/y") . "|" . $HTTP_POST_VARS['name']; $line .= "|" . $HTTP_POST_VARS['title']; $line .= "|" . $HTTP_POST_VARS['news']; $line = str_replace("\r\n","<BR>",$line); $line .= "\r\n"; fwrite($fp, $line); if(!fclose($fp)) { echo "Error closing file! Please try again. If the error continues please contact the webmaster <a href=\"javascript:history.back(-1)\" Go back</a><br><a href=\"mailto:[email protected]?subject=php error UTKD code 102\"> E-mail the webmaster</a>"; exit; } echo "<h1>News item added</h1>" ; } else { echo "<h1>Bad Password</h1>"; } } ?> Here is the php code for showing it on the news page: <?php $data = file('newsadd.txt'); $data = array_reverse($data); foreach($data as $element) { $element = trim($element); $pieces = explode("|", $element); echo "<h3 align=\"center\">" . $pieces[2] . "</h3>" . "" . "<i><h5 align=\"center\">Posted by " . $pieces[1] . " on " . $pieces[0] . "</b></i></h5><p align=\"center\">" . $pieces[3] . "HTML CODE" ; } ?> Some details: $pieces[0] = Date $pieces[1] = Name of poster $pieces[2] = Title of the news $pieces[3] = Main news article So basically .... all i want to do is show the latest $pieces[2] on a different php file. If you require any extra information I would try my best to write back. Also I do not have much experience in coding with PHP. Any replys / ideas will be extremley gratefull Thanks From CH Webdesigns
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.