Need help on school project

Hello- I am a student who is new to PHP. For our current project, I am very lost. We are supposed to create a searchable picture directory. If all the parameters are entered in correctly (people, avatars, bios), the whole directory will show. I am stuck on three things:

  1. How or where do you include a CSS file? I’ve done it for HTML, but not PHP.
  2. We need to use one for each function for the three arrays. How do you do this?
  3. I have no idea if I am even coding the error section correctly. Am I even heading in the right direction?

Help!

[php]

Fake Directory

Picture Directory

<?php include("inc_vars.php"); echo $_GET[people]; ?>
    <p>First Name: <input type="text" name="FirstName"></p>
    <p>Last Name: <input type="text" name="surName"></p>

    <p>
      <input type="reset" value="Clear Form">
      <input type="submit" value="Send Form" name="Submit">
   </p>

Error!

Joe Lagana/President and CEO/Lagana Tech

Gayle Ujifusa/VP of Sales/Elguji Software

Scott Fisher/VP of Accounting/Drugco Inc.

Jeff Hendryx/Programmer/Mobil Solutions, Inc.

Paul Yee/Systems Analyst/Sharp Systems

James Farrier/Systems Analyst/Sharp Systems

Marshall Pinder/VP of Marketing/Sharp Systems

Kelly Callahan/Lead Designer/Wry Toast Designs

Allison Pierce/Teacher/Distric 42

Erin Varner/Student/EWU

[/php]

PHP include file

[php]

inc_vars php file <?php $people = array("Joe Lagana","Gayle Ujifusa","Scott Fisher","Jeff Hendryx","Paul Yee","James Farrier","Marshall Pinder","Kelly Callahan","Allison Pierce","Erin Varner"); $avatars = array("malehead.png","femalehead.png","malehead.png","malehead.png","malehead.png","malehead.png","malehead.png","femalehead.png","femalehead.png","femalehead.png"); $bios = array("President & CEO "
\n"; Laganatech","VP of Sales "
\n"; Elguji Software","VP of Accounting "
\n"; Drugco Inc.","Programmer "
\n"; Mobile Solutions, Inc.","Systems Analyst "
\n"; Sharp Systems","Systems Analyst "
\n"; Sharp Systems","VP of Marketing "
\n"; Sharp Systems","Lead Designer "
\n"; Wry Toast Designs","Teacher "
\n"; District 42","Student "
\n"; EWU"); foreach ($people as $key => $value){ echo "{$people[$key]}{$avatars[$key]}{$bios[$key]}\n"; } /*if (isset ($_GET ["people"]) echo "Yes, it is set."; else { echo "No, it is not set."; }*/ mkdir("picture directory"); $errorflag= FALSE; $errortext= FALSE; //people parameter isset ($_GET ['$people']){ if $_GET ['$people'] > 0 && $_GET ['$people'] <= 10); $total_people = $_GET ['$people']; } else { $errorflag= TRUE; $errortext= "People arguement requiring numbers between 1 and 10"; } else { $errorflag= TRUE; $errortext= "No person arguement found."; } //bio parameter isset ($_GET ['$bios']){ if $_GET ['$bios'] > 0 && $_GET ['$bios'] <= 10); $total_bios = $_GET ['$bios'];} else { $errorflag= TRUE; $errortext= "People arguement requiring correct name."; } else { $errorflag= TRUE; $errortext= "No person arguement found."; } // avatar parameter isset ($_GET ['$avatars']){ if $_GET ['$avatars'] > 0 && $_GET ['$avatars'] <= 10); $total_avatars = $_GET ['$avatars'];} else { $errorflag= TRUE; $errortext= "People arguement requiring correct picture."; } else { $errorflag= TRUE; $errortext= "No person arguement found."; } ?> [/php]

CSS file

[code][color=blue]body {font-family:Verdana,Arial;
margin:0;
padding:0;
background-color:#fafafa;}

#wrapper {
background-color: #cccccc;
width:900px;
}

#errors {background-color:red;
width:860px;
padding:20px;

}

.row {
background-color:#cacaca;
border-bottom:1px solid #fff;
padding:40px;
}

.avatars {margin-bottom: 5px;}[/color[/code]

I see what you’re doing with the bios, but you should really make the companies into a seperate array or a multidemensional array.

But you’re not searching a physical folder though, all you’re doing is looping through multiple arrays. What i’d do is create a multi-demensional array since that’s how you want to do it.

$people = array(“person1” => array(“avatar1”, “position1”, “company1”), “person2” => array(“avatar2”, “position2”, “company2”); (you get the jist of it)

Then use array_search to search the people array, if it equals 1 (it’ll return a 1 or 0 depending on if it finds something), then display the person’s data
[php]
$people = array(“person1” => array(“avatar1”, “position1”, “company1”), “person2” => array(“avatar2”, “position2”, “company2”);

$term = $_POST[‘FirstName’]." “.$_POST[‘surName’];
if(array_search($term, $people)) {
for ($row = 0; $row < count($people); $row++) {
foreach($people[$row] as $key => $value) {
echo $value.”
";
}
}
}
[/php]

This is untested, so if it doesn’t work, please post back with any error messages. You’ll have to mess with the echos to get it to display the information how you want it.

Hi Richei- (I signed up for a membership after this post). Thank you for your help! I’m going to test it out and work on the echo statements.

Sponsor our Newsletter | Privacy Policy | Terms of Service