Jump to content

php script help!


wazza91

Recommended Posts

 

how would i go about the task?

 

Create a php script to

 

- receive the chosen option  from the select box & textbox in the html file & check it is within range and is a number (using  the is_numeric( ) function)

- Assign 7 employee records (Employee Number, Employee Name, Age, Department Name) into a 2 dimensional sequential array (using employee numbers 1 to 7) and your own made up values for the other record details – remember that text values are enclosed within inverted commas whereas numeric values are not:

- See PHP worksheet 3 for how a 2D array is created in a program

- If the chosen select option is to print the whole table

o – then print all 7 records in an html table with a header row

• You will need a for loop to print a record

• You will need to manipulate array values

(You should use a variable for the row number to

  generalise row printing a row using the for loop)

- If the chosen option is to print a selected record, use the record number from the textbox to

o Print that particular record including the header details row

• E.g. for employee number 1 by transposing it to the array row index number

• This row number should be generalised using a variable for the row index number

• Sample record

 

Link to comment
Share on other sites

any one have any ideas on what functions, i need to use and how i would write the code!!!!

 

Bro, it says guidelines all over "You will need a for loop", It gives you a small example on the last 3 lines. It tells you what worksheet to use for how 2d arrays are created.

 

Give it a try, and come back with some code, and then we can help.

Link to comment
Share on other sites

this is what i got at the minute am i on the right lines?

<?php
$output = "";
$total = 0;

for($i = 1; $i <= 7; $i++) {


$employee = array(array(21, "1employee"), array(25, "2employee"), array(23, "3employee"), 
                 array(29, "4employee"),  array(19, "5employee"), array(30 , "6employee") 
                 array(32 ,"7employee")  );


print "Whole Table<br>";

);
?>

Link to comment
Share on other sites

okay this is what i got someone plz help

<?php

$output = "";

$total = 0;

 

for($i = 1; $i <= 7; $i++) {

 

 

$people = array(array(21, "John"), array(25, "Bill"), array(23, "Anna"),

                array(29, "Aine"),  array(19, "Pat"), array(30 , "Leanne") );

 

 

 

print "<table border=1>";

print "<tr><th>Age</th><th>Name</th></tr>";

 

for($x=0;$x<6;$x=$x+1) {   

 

print "<tr><td>" . $people[$x][0]  . "</td>";

print "<td>" . $people[$x][1]  . "</td></tr>";

 

}

 

?>

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.