wazza91 Posted February 21, 2011 Share Posted February 21, 2011 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 https://forums.phpfreaks.com/topic/228380-php-script-help/ Share on other sites More sharing options...
wazza91 Posted February 22, 2011 Author Share Posted February 22, 2011 any one have any ideas on what functions, i need to use and how i would write the code!!!! Link to comment https://forums.phpfreaks.com/topic/228380-php-script-help/#findComment-1178321 Share on other sites More sharing options...
Zurev Posted February 22, 2011 Share Posted February 22, 2011 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 https://forums.phpfreaks.com/topic/228380-php-script-help/#findComment-1178323 Share on other sites More sharing options...
wazza91 Posted February 22, 2011 Author Share Posted February 22, 2011 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 https://forums.phpfreaks.com/topic/228380-php-script-help/#findComment-1178336 Share on other sites More sharing options...
wazza91 Posted February 22, 2011 Author Share Posted February 22, 2011 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 https://forums.phpfreaks.com/topic/228380-php-script-help/#findComment-1178364 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.