in Search
     
Latest post 10-16-2007 9:52 PM by cyrose30. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 10-16-2007 5:53 PM

    • cyrose30
    • Top 200 Contributor
    • Joined on 10-17-2007
    • Posts 4
    • Points 95

    php sorting

    ellow poh.. i need help about my simple program exercise.. plz help me.. tnx!

    this is the output i need..

    output:

    (10 numbers will be sorted)

    (1st number) is lower than (2nd number) 

    (textbox)

    (command button)

    ----------------------------------

    when i'll input 10 numbers in textbox.. the output will be sorted if i'm clicking the command button...

    plz help me.. tnx!

    Filed under:
    • Post Points: 20
  • 10-16-2007 8:03 PM In reply to

    • cruizer
    • Top 10 Contributor
    • Joined on 12-14-2005
    • Singapore
    • Posts 944
    • Points 22,590

    Re: php sorting

    will you separate the numbers in the text box with spaces or commas in between?

    step by step...what you can do use the explode() function to break up the string entered in the text box into an array based on the separator character/string (space or comma). then once you have the array, use the asort() function to sort it, then iterate over that array to display each element in sorted order.

    http://devpinoy.org/blogs/cruizer
    Naglalayong buksan at palayain ang kamalayan ng Pinoy .NET developer
    • Post Points: 20
  • 10-16-2007 8:27 PM In reply to

    • cyrose30
    • Top 200 Contributor
    • Joined on 10-17-2007
    • Posts 4
    • Points 95

    Re: php sorting

    can you plz give me an code for that? plzzz... tnx!

    this is my created php code.. i'll w8 for your reply this day.. tnx!

    <?php

    echo "<u>Output:</u></br></br>";

    echo $_POST["num"]. "</br></br>";

    ?>

    <html>
    <head>

    <title></title>
    </head>
    <body>
    <h5>Input 10 Numbers:</h5>
    <form action = "9.php" method = "POST">
    <p style="background-color:lavender;padding:10px;width=10%">
    <input type = "box" name = "num" value = "<?php echo $num; ?>" />
    <p><input type = "submit" value = "Enter" />
    </form>

    </body>
    </html>

     

    • Post Points: 20
  • 10-16-2007 8:37 PM In reply to

    • cruizer
    • Top 10 Contributor
    • Joined on 12-14-2005
    • Singapore
    • Posts 944
    • Points 22,590

    Re: php sorting

    I think it would be better if you write the code yourself. That is the only way you will learn PHP.

    Anyway, I suggest you break your code down into something like this:

    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
       /* put your code here when responding to the POST back submission */
    } else {
       /* put your code here to display the initial page */
    }

     

    http://devpinoy.org/blogs/cruizer
    Naglalayong buksan at palayain ang kamalayan ng Pinoy .NET developer
    • Post Points: 20
  • 10-16-2007 9:52 PM In reply to

    • cyrose30
    • Top 200 Contributor
    • Joined on 10-17-2007
    • Posts 4
    • Points 95

    Re: php sorting

    ok sir.. i'll try

    • Post Points: 5
Page 1 of 1 (5 items)