..hi, my name is greenhorn...

Discussion in 'PHP' started by dharma, May 1, 2006.

  1. #1
    ye... i just try to find out what php is...
    actually i have a little problem...
    i cant find out how to reach that my php script will write things he have to in invert order... it means latest on begining...
    like disscussions...

    this is the part of code which make the writtening...

    <?
    if (($akce=="add") && ($Email!="") && ($Jmeno!="") && ($Zprava!="")) {
    $fp=FOpen("kniha.body","a");
    FPutS($fp,"
    <table class='style7' border='0' cellpadding='0' cellspacing='0' width='100%'>
    <tr>
    <td width='100%'><small>".Date("j.n.Y H:i:s")."</small></td>
    </tr>
    <tr>
    <td width='100%'><b>$Jmeno</b> (<a
    href='mailto:$Email'>$Email</a>) </td>
    </tr>");
    FPutS($fp, "
    <tr>
    <td width='100%'>web: <a href='$Web'>$Web</a>
    </td>
    </tr>");
    FPutS($fp, "
    <tr>
    <td width='100%'>&nbsp;&nbsp;</td>
    </tr>
    <tr>
    <td width='100%'><em>".NL2BR(HTMLSpecialChars($Zprava))."</em></td>
    </tr>
    </table><br><br><br><br>");

    is here anyone who can give advice how to force that he write the latest on begining? please
    thank You
     
    dharma, May 1, 2006 IP
  2. Danny

    Danny Active Member

    Messages:
    732
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    78
    #2
    that reads like a VCR manual with coffee stains on it.

    Essentially I think you are saying

    "I want to get my php script to write things in reverse order?"
    is this correct?


    your code is a bit odd too.

    Why do you open a file and do an fput within an fput?



    or are you trying to say
    "I want to get my php script to insert text"?
     
    Danny, May 1, 2006 IP
  3. dharma

    dharma Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    dear Danny
    in first, thank You for reply. Its nice that anyone accept greenhorns...
    Im just adviceless...
    Well, i dont know what is VCR manual with coffee stains on it.
    Yes, I want to get my php script to write things in reverse order.
    I dont know what is ODD...
    I dont know too, what is open a file and do an fput within an fput.

    In fact I want to have a guest book and i want that the new messages will be on top of the page and diresction down the olders and olders... but now it works, that on the top of the page is the first and the newest one is on bottom...
    see http:my web site (www. dharma. sk - guestbook
    im really just a greenhorn and more, my english is very simply...
    but anyway, nice that you try to help.
    Thank You
     
    dharma, May 1, 2006 IP
  4. Danny

    Danny Active Member

    Messages:
    732
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    78
    #4
    sorry mate I had a bit of sarcasm in my last post. I am glad I deciphered it right.

    It is probably better if you use a database, do you have access to a database?

    If you do it makes this job a lot easier because you can simply have your SQL statement do the work by using an "order by ID desc" on the end of it.

    So essentially do you have to do this with files, or can you do this with a database?

    Cheers
    Dan
     
    Danny, May 2, 2006 IP
  5. dharma

    dharma Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    that is the problem... i have a hosting without mysql support...
    in fact there is this support, but i have to pay more... and allready this is expensive enough... :)
    so i try to do it this way....

    i found some manual... and i tryed to change the parameter a behind fopen to r+

    but than it made mass in there...
    so im again where i was on begining :)

    so You are a joker :)

    doesnt matter :)
    i like black humor too :)

    HEY! and something more... i dont know all functions of this forum neither... just few minutes ago i did push a red triangle above your message... than i realised when i read the comment for it... so i just cancelled the action...
    so if there is anything what looks strange from me, just dont be surprised...
    i have to learn about this too...
    Just now im gona to check box "Quote message in reply?" even if i dont know what will happen... :)
    so... thx
    see ya :)
     
    dharma, May 2, 2006 IP
  6. Danny

    Danny Active Member

    Messages:
    732
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    78
    #6
    I will see if I can get some code together for you soon. but it may have to wait until early next week. I am trying to finish off my ecommerce app for release which is about 6 months over due.

    The other way you could do it is to create a new file for each comment and then name it with an incremented ID.
    You could then grab them in reverse order

    Alternatively you could feed them into an array and step through them in reverse

    Daniel
     
    Danny, May 2, 2006 IP
  7. sadcox66

    sadcox66 Spirit Walker

    Messages:
    496
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #7
    sadcox66, May 2, 2006 IP
  8. TwistMyArm

    TwistMyArm Peon

    Messages:
    931
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #8
    In reality, I would recommend you *don't* dump all of the HTML formatting to the file... if you decide you want to change the layout later on, you will need to re-edit the entire file. Instead, add the HTML when you read the file in to display it.

    Anyway, if I were you, I'd do the following:
    1) Create a new file
    2) Dump the new data in to that file
    3) Open the original file and stream the data from that in to the new file
    4) Delete the original file and rename the new file

    That way, you're basically prepending the string to the file. That is to say, you're automatically making the file itself sorted newest to oldest.
     
    TwistMyArm, May 2, 2006 IP
  9. dharma

    dharma Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    I thing you are right... the strrev is not the thing which can work here...
    well, trhank yiou for advice...
    now i gona search in tutorials how to create, rename and delete new files and dump data from one to an other... and then i go to try inplement it in my code :)
    I have a feeling this is the solution.... this new file... cuz i was trying to make fopen,r+
    but it makes mass :)
    well, thank you all very much
     
    dharma, May 2, 2006 IP
  10. dharma

    dharma Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    yes, i think this is a way to do it.... i will try to find out how to make array and than, how to tell to my code to make files and put in array... and than read them...
    this i can find in tutorial, i quess, this must work...
    Thank you very much :)
    have much succes
     
    dharma, May 2, 2006 IP