Question

Write a web program to allow the user to sort a list of things. Use HTML...

Write a web program to allow the user to sort a list of things. Use HTML and PHP. Your input (HTML) should include a text area the user can type in their list. The output (PHP) should be in the form of a table. Use the explode command to break the input up into an array. $list=explode(PHP_EOL, $stuff);

Once you have the text into an array, use the sort function to sort it, and then loop through it and print the results into a table.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

<?php
$det=array();//create an empty array
if(isset($_POST["sort"]))
{
$stuff=$_POST["stuff"];
$det=explode(PHP_EOL,$stuff);//split the input data using explode() based on delimitter and store in array
  
}
?>
<html>
<head>Sort list of data</head>
<body>
<form method="post">
<textarea name="stuff" rows="5" cols="30"></textarea>
<input type="Submit" name="sort" value="sort"/>
</form>
<?php if(count($det)>0) // if count of array elements is greater than 0
{
?>
<table border="1">
<tr><td>Sorted Data</td></tr>
<?php
sort($det);//sort details in ascending order
for($i=0;$i<count($det);++$i)
{?>
<tr>
<td><?php echo $det[$i];?></td></tr><?php }?></table><?php } ?>
</body>

</html>

Input

Enter data in text area and click on sort button

localhost/sort.php - Opera Minbox (588)-x !! Fidaa Full So ewrite A web PHP asort-1 × 2phpsort(Sa × Tryit Editor × 亟PH P: priafter clicking on sort button details will be sorted and printed in table

localhost/sort.php - Opera M inbox (588)-rit.cses × Fidaa Full Songs Juk × ewrite A Web Progra × 囧localhost/sort.php + 〉 C 8:

Add a comment
Know the answer?
Add Answer to:
Write a web program to allow the user to sort a list of things. Use HTML...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 1. Print out information of PHP use phpinfo() function. 2. Write a program that check and...

    1. Print out information of PHP use phpinfo() function. 2. Write a program that check and print odd / even numbers (from number 1 to 100 using for/while loop). Display the results within an HTML table with 2 columns as shown below: NUMBERS RESULTS 1 ODD 2 EVEN 3 ODD HINT: use <table> tags to create a table, <th> tags for ‘Numbers’ and ‘Results’. Wrap code PHP inside HTML code. For example: ​<html> ​​<title>CHECK ODD or EVEN</title> ​​<body> ​​​<table> ​​​​<?php...

  • This code should be written in php. Write a program that allows the user to input...

    This code should be written in php. Write a program that allows the user to input a student's last name, along with that student's grades in English, History, Math, Science, and Geography. When the user submits this information, store it in an associative array, like this: Smith=61 67 75 80 72 where the key is the student's last name, and the grades are combined into a single space-delimited string. Return the user back to the data entry screen, to allow...

  • JAVA Write a program that prompts the user to enter a file name, then opens the...

    JAVA Write a program that prompts the user to enter a file name, then opens the file in text mode and reads it. The input files are assumed to be in CSV format. The input files contain a list of integers on each line separated by commas. The program should read each line, sort the numbers and print the comma separated list of integers on the console. Each sorted list of integers from the same line should be printed together...

  • Write a PYTHON program that allows the user to navigate the lines of text in a...

    Write a PYTHON program that allows the user to navigate the lines of text in a file. The program should prompt the user for a filename and input the lines of text into a list. The program then enters a loop in which it prints the number of lines in the file and prompts the user for a line number. Actual line numbers range from 1 to the number of lines in the file. If the input is 0, the...

  • Design a program using Python and using from flask Import flask that generates a lottery number...

    Design a program using Python and using from flask Import flask that generates a lottery number but in a website.. The program should have an Integer array with 9 elements. Write a loop that steps through the array, randomly generating a number in the range of 0 through 42 for each element. (Use the random function) Then write another loop that displays the contents of the array. Each number should be displayed as a list, the numbers should be generated...

  • Write a program that check odd / even numbers (from number 1 to 100). Display the...

    Write a program that check odd / even numbers (from number 1 to 100). Display the results within an HTML table with 2 columns: one for odd number and one for even numbers. NUMBERS RESULTS ODD EVEN ODD 2 HINT: use <table> tags to create a table, <th> tags for 'Numbers' and 'Results'. Wrap code PHP inside HTML code. For example: <html> <title>CHECK ODD or EVEN</title> <body> <table> ?php echo "<tr><td>l</td><td>Odd</td</tr>"; </table> </body </html 2. Do the following steps in...

  • (C++ Program) 1. Write a program to allow user enter an array of structures, with each...

    (C++ Program) 1. Write a program to allow user enter an array of structures, with each structure containing the firstname, lastname and the written test score of a driver. - Your program should use a DYNAMIC array to make sure user has enough storage to enter the data. - Once all the data being entered, you need to design a function to sort the data in descending order based on the test score. - Another function should be designed to...

  • Write a Python program that keeps reading in names from the user, until the user enters...

    Write a Python program that keeps reading in names from the user, until the user enters 0. Once the user enters 0, you should print out all the information that was entered by the user. Use this case to test your program: Input: John Marcel Daisy Samantha Nelson Deborah 0 ================ Output: John Marcel Daisy 25 Samantha Nelson Deborah Hints: Create an array Names to hold the input names. Use the Names.append(x) function to add a new name to the...

  • Write a program that allows the user to enter a series of exam scores. The number...

    Write a program that allows the user to enter a series of exam scores. The number of scores the user can enter is not fixed; they can enter any number of scores they want. The exam scores can be either integers or floats. Then, once the user has entered all the scores they want, your program will calculate and print the average of those scores. After printing the average, the program should terminate. You need to use a while loop...

  • In C only Please! This lab is to write a program that will sort an array...

    In C only Please! This lab is to write a program that will sort an array of structs. Use the functions.h header file with your program. Create a source file named functions.c with the following: A sorting function named sortArray. It takes an array of MyStruct's and the length of that array. It returns nothing. You can use any of the sorting algorithms, you would like though it is recommended that you use bubble sort, insertion sort, or selection sort...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT