![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Jul 2004
Posts: 1
Rep Power: 0
![]() |
First question:
I have created a mail form and was wondering how to get the action to be home2.php?page=mail&action=results. I already have the form as home2.php?page=mail. Second question: I have also created a news posting script that saves to a file named home.inc and was wondering how I can get the information to display from newest to oldest, instead of oldest to newest. The information that is written to home.inc looks like this: $output = '<h2 class=/"margin/">'.$date.'</h2>\n<p class=/"margin/">'.$post_content.'</p>'; Any help is greatly appreciated. Thank you in advance. |
|
|
|
|
|
#2 |
|
Expert Programmer
|
The easiest method is just to write new data to the front of the file.. which means everytime you want to write to a file, write to a temporary file, copy the old news file the the end of the temp file, then move the temp file to the original file's place.
In your form try using: <input type="hidden" name="action" value="results"> That is the simplest way to do it, and I am assuming will work for your purposes.. if not come back and be a bit more precise on telling us how you plan on generating that URI ![]()
__________________
Clifford Matthew Roche <geek@cliffordroche.com> Web Hosting: http://www.crd-hosting.com Consulting: http://www.crdev-consulting.com |
|
|
|
|
|
#3 | |
|
Programming Guru
![]() ![]() |
Here's a little diddy, that i whiped up...havn't tested it though.
get you script that inputs the news into the file to seperate the news with a line that contains somthing like ^&. <?PHP
$textfile = "Your/Path/to/file"; //set the path to the file here.
if ($text = @file("textfile")) //Don't display errors on file open
{
$y = 0; //set the height var. for the array.
for ($x=0; $x<count($text); $x++)
{
$tmp = $text[$x];
if ($tmp == "^&")
{
//we have a line break
$textarr[$y][$x] = $text[$x]; //we will need to have the
//line break later when
//outputing.
$y++;
}
else
{
//we have text that is still part of a new item.
$textarr[$y][$x] = $text[$x];
}
}
//Now to output the text
for ($x=count($text); $x<>0; $x--)
{
if ($textarr[$y][$x] == "^&") //we have a line brake.
{
$y--;
}
else
{
echo $textarr[$y][$x];
}
}
}
?>Anyways, That's how i would do it, but kurifu is right Quote:
Good luck and hope my code is right...heh
__________________
Profanity is the one language that all programmers understand. Check out my Blog <---updated Nov 30 2007! |
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|