Class Homework using $_Get

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Locked
redrocket1855
Forum Newbie
Posts: 8
Joined: Tue Sep 15, 2009 12:30 am

Class Homework using $_Get

Post by redrocket1855 »

here is the assignment:
# Build a multidimensional array storing class information as listed below. (Each class should be stored in an array containing at least three elements: class number, title, and room.) (10 points)

* CTEC 2350 Intro to Communication Technology FAB 412
* CTEC 3350 Website Communication FAB 411
* BCMN 3319 Broadcast Management FAB 327
* BCMN 3340 Electronic News FAB 112
* ADVT 3305 Advertising Media FAB 409

# Produce a function, showClass, which will take in an argument, $prefix, and produce a class list that matches the class prefix supplied by $prefix. For example, when you call the function showClass('CTEC'), only CTEC classes will be listed. Classes should be listed in a table format.

#To demonstrate the functionality of your script, call the showClass function with the argument set to $_GET['prefix'] at the end of your script block like this:
showClass($_GET['prefix']);

I am having problems with the function part of the assignment and call the showClass function with the argument set to $_GET['prefix'] at the end of your script block like this:
showClass($_GET['prefix']);
here is the code so far..........

Code: Select all

<body>
<table border="1">
<tr>
 <th>Class Number</th>
 <th>Title</th>
 <th>Room</th>
</tr>
<?php
$classes = array (
    array('CTEC 2350','Intro to Communication Technology','FAB 412'),
    array('CTEC 3350','Website Communication','FAB 411'),
    array('BCMN 3319','Broadcast Management','FAB 327'),
    array('BCMN 3340','Electronic News','FAB 112'),
    array('ADVT 3305','Advertising Media','FAB 409')
);
 
foreach($classes as $class)
{
 echo '<tr>';
 foreach($class as $item)
 {
  echo "<td>$item</td>";
 }
 echo '</tr>';
}
 
function showClass ($prefix){[color=#FF0040]//there should be something here i think  [/color]
                        
}
?>
</table>
</body>
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Class Homework using $_Get

Post by John Cartwright »

Duplicate account + Duplicate thread = Locked.

Please send me a private message with which one of your accounts you would like to keep, otherwise, the latest one will be removed within 24h.
Locked