Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jul 3rd, 2004, 10:26 AM   #1
mrbig06
Newbie
 
Join Date: Jul 2004
Posts: 1
Rep Power: 0 mrbig06 is on a distinguished road
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.
mrbig06 is offline   Reply With Quote
Old Jul 22nd, 2004, 11:55 PM   #2
kurifu
Expert Programmer
 
kurifu's Avatar
 
Join Date: Jul 2004
Location: Halifax, Nova Scotia (Canada)
Posts: 784
Rep Power: 5 kurifu is on a distinguished road
Send a message via ICQ to kurifu Send a message via MSN to kurifu
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 &lt;geek@cliffordroche.com&gt;
Web Hosting: http://www.crd-hosting.com
Consulting: http://www.crdev-consulting.com
kurifu is offline   Reply With Quote
Old Jul 23rd, 2004, 9:41 AM   #3
Pizentios
Programming Guru
 
Pizentios's Avatar
 
Join Date: May 2004
Location: Brandon, Manitoba, Canada
Posts: 2,023
Rep Power: 7 Pizentios is on a distinguished road
Send a message via ICQ to Pizentios Send a message via MSN to Pizentios
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:
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.
Note i havn't tested this code yet, so it might be right or wrong. Probally got some errors in it. And when your putting the news into your file only make a line brake at the top of your news text that you inputting, otherwise you'll get werid stuff happening when you output the code because of the array.

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!
Pizentios is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:32 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC