Jump to content

Need help with a Lost and Found list.


alphamic

Recommended Posts

Hello all.  This is my first time posting here and I'm in need of some assistance.  I'm doing a class reunion site for my dad and his classmates, and the site I'm working with is based off of an exiting site.  The developer is allowing us to use his files so I can modify them; I'm simply updating a few minor things like pictures and text, but one area has me stumped.  Please take a look at the page from the website I'm using the files from.  As people who are lost register it's suppose to add them to the found part and then have a link to their bio.  I'm fairly new to using Dreamweaver and thought this would be an easy task since I already had a site to update from, but it's proving otherwise.  The files I have keep showing all of the people from the previous class reunion, and I need to clear those so the people from my dad's class reunion can go there.  Thank you in advance!

 

- Brian

 

Link to site http://www.seaholm87.com/lost_found.php

Link to comment
https://forums.phpfreaks.com/topic/110662-need-help-with-a-lost-and-found-list/
Share on other sites

Here is the code that is suppose to be for the people who have registered on the site: 

 

 

<?php

 

//$i = 0;

$name_array = array('test');

$insideitem = false;

$tag = "";

$first_name = "";

$last_name = "";

$maiden_name = "";

$address = "";

$city = "";

$state = "";

$zip = "";

$email = "";

$phone = "";

$occupation = "";

$spouse_name = "";

$child_name_1 = "";

$child_age_1 = "";

$child_name_2 = "";

$child_age_2 = "";

$child_name_3 = "";

$child_age_3 = "";

$child_name_4 = "";

$child_age_4 = "";

$child_name_5 = "";

$child_age_5 = "";

$comments = "";

 

 

function startElement($parser, $name, $attrs) {

global $insideitem, $tag, $first_name, $last_name, $maiden_name, $address, $city, $state, $zip, $email, $phone, $occupation, $spouse_name, $child_name_1, $child_age_1, $child_name_2, $child_age_2, $child_name_3, $child_age_3, $child_name_4, $child_age_4, $child_name_5, $child_age_5, $comments;

 

if ($insideitem) {

$tag = $name;

} elseif ($name == "STUDENT") {

$insideitem = true;

}

 

}

 

function endElement($parser, $name) {

global $name_array, $insideitem, $tag, $first_name, $last_name, $maiden_name, $address, $city, $state, $zip, $email, $phone, $occupation, $spouse_name, $child_name_1, $child_age_1, $child_name_2, $child_age_2, $child_name_3, $child_age_3, $child_name_4, $child_age_4, $child_name_5, $child_age_5, $comments;

  static $i = 0;

if ($name == "STUDENT") {

    //if (trim($first_name) == $_GET["first_name"] && trim($last_name) == $_GET["last_name"]) {

  if (trim($maiden_name) != "") {

      $name_array[$i] = trim($maiden_name).", (".$last_name."), ".$first_name;

  } else {

  $name_array[$i] = $last_name.", ".$first_name;

  }

      $i++;

        /*printf("<dt><a href=\"popup_xml_2.php?first_name=".trim($first_name)."&last_name=".trim($last_name)."\" onclick=\"window.open(this.href, 'popupwindow', 'width=300,height=300,scrollbars,resizable'); return false;\">%s</a></dt>",

    trim($last_name.", ".$first_name));

    printf("Maiden name: <dd>%s</dd>",htmlspecialchars(trim($maiden_name)));

    printf("Address: <dd>%s</dd>",htmlspecialchars(trim($address)));

    printf("City: <dd>%s</dd>",htmlspecialchars(trim($city)));

    printf("State: <dd>%s</dd>",htmlspecialchars(trim($state)));

    printf("Zip: <dd>%s</dd>",htmlspecialchars(trim($zip)));

    printf("Email: <dd>%s</dd>",htmlspecialchars(trim($email)));

    printf("Phone: <dd>%s</dd>",htmlspecialchars(trim($phone)));

    printf("Occupation: <dd>%s</dd>",htmlspecialchars(trim($occupation)));

    printf("Child name: <dd>%s, age %s</dd>",htmlspecialchars(trim($child_name_1)),htmlspecialchars(trim($child_age_1)));

    printf("Child name: <dd>%s, age %s</dd>",htmlspecialchars(trim($child_name_2)),htmlspecialchars(trim($child_age_2)));

    printf("Child name: <dd>%s, age %s</dd>",htmlspecialchars(trim($child_name_3)),htmlspecialchars(trim($child_age_3)));

    printf("Child name: <dd>%s, age %s</dd>",htmlspecialchars(trim($child_name_4)),htmlspecialchars(trim($child_age_4)));

    printf("Child name: <dd>%s, age %s</dd>",htmlspecialchars(trim($child_name_5)),htmlspecialchars(trim($child_age_5)));

    printf("Comments: <dd>%s</dd>",htmlspecialchars(trim($comments)));*/

//}

 

    $first_name = "";

        $last_name = "";

        $maiden_name = "";

        $address = "";

        $city = "";

        $state = "";

        $zip = "";

        $email = "";

        $phone = "";

        $occupation = "";

$spouse_name = "";

        $child_name_1 = "";

        $child_age_1 = "";

        $child_name_2 = "";

        $child_age_2 = "";

        $child_name_3 = "";

        $child_age_3 = "";

        $child_name_4 = "";

        $child_age_4 = "";

        $child_name_5 = "";

        $child_age_5 = "";

        $comments = "";

$insideitem = false;

}

  if ($name == "STUDENTS") { // We've reached the end of our file, now alphabetize the array and print out in order

    $i = 0;

    sort($name_array);

       

    while($i<count($name_array)) { // We need to separate out each array element (which is in the form "Last name, first name") and add these to the appropriate querystring parameters

 

      $data = explode(',', $name_array[$i]);

  $data = str_replace("(", "", $data);

  $data = str_replace(")", "", $data);

  $name_array_clean[$i] = str_replace(",", " ", $name_array[$i]);

  $name_array_clean2[$i] = str_replace("()", "", trim($name_array_clean[$i]));

  //echo "name_array_clean2 = ".$name_array_clean2[1];

 

  if ($data[2] != "") {

  echo "<a href=\"student_popup.php?first_name=".trim($data[2])."&last_name=".trim($data[1])."\" onclick=\"window.open(this.href, 'popupwindow', 'width=300,height=450,menubar=no,toolbar=no,scrollbars,resizable'); return false;\">$name_array_clean2[$i]</a><br />";

  } else {

  echo "<a href=\"student_popup.php?first_name=".trim($data[1])."&last_name=".trim($data[0])."\" onclick=\"window.open(this.href, 'popupwindow', 'width=300,height=350,menubar=no,toolbar=no,scrollbars,resizable'); return false;\">$name_array_clean2[$i]</a><br />";

  }

      $i++;

    }

  }

 

}

 

 

function characterData($parser, $data) {

global $insideitem, $tag, $first_name, $last_name, $maiden_name, $address, $city, $state, $zip, $email, $phone, $occupation, $spouse_name, $child_name_1, $child_age_1, $child_name_2, $child_age_2, $child_name_3, $child_age_3, $child_name_4, $child_age_4, $child_name_5, $child_age_5, $comments;

if ($insideitem) {

switch ($tag) {

case "FIRST_NAME":

$first_name .= $data;

break;

case "LAST_NAME":

$last_name .= $data;

break;

case "MAIDEN_NAME":

$maiden_name .= $data;

break;

case "ADDRESS":

$address .= $data;

break;

case "CITY":

$city .= $data;

break;

case "STATE":

$state .= $data;

break;

case "ZIP":

$zip .= $data;

break;

case "EMAIL":

$email .= $data;

break;

case "PHONE":

$phone .= $data;

break;

case "OCCUPATION":

$occupation .= $data;

break;

case "SPOUSE_NAME":

$spouse_name .= $data;

break;

case "CHILD_NAME_1":

$child_name_1 .= $data;

break;

case "CHILD_AGE_1":

$child_age_1 .= $data;

break;

case "CHILD_NAME_2":

$child_name_2 .= $data;

break;

case "CHILD_AGE_2":

$child_age_2 .= $data;

break;

case "CHILD_NAME_3":

$child_name_3 .= $data;

break;

case "CHILD_AGE_3":

$child_age_3 .= $data;

break;

case "CHILD_NAME_4":

$child_name_4 .= $data;

break;

case "CHILD_AGE_4":

$child_age_4 .= $data;

break;

case "CHILD_NAME_5":

$child_name_5 .= $data;

break;

case "CHILD_AGE_5":

$child_age_5 .= $data;

break;

case "COMMENTS":

$comments .= $data;

break;

 

}

}

}

 

$xml_parser = xml_parser_create();

xml_set_element_handler($xml_parser, "startElement", "endElement");

xml_set_character_data_handler($xml_parser, "characterData");

$fp = fopen("registration.xml","r")

or die("Error reading XML data.");

while ($data = fread($fp, 4096))

xml_parse($xml_parser, $data, feof($fp))

or die(sprintf("XML error: %s at line %d",

xml_error_string(xml_get_error_code($xml_parser)),

xml_get_current_line_number($xml_parser)));

     

fclose($fp);

xml_parser_free($xml_parser);

 

   

    ?>

 

 

And here is the code for the people who are still on the LOST list:

 

 

<?php

 

$name_array = array('test'); 

$i = 0;

 

//$wholefile = file("not_found.txt");

//foreach($wholefile as $line) echo $line.'<br>';

 

$myFile = "not_found.txt";

$handle = fopen($myFile, 'r');

 

//$handle = str_replace("\n","",$handle) ; // new code: delete newlines

//$handle = str_replace("\r","",$handle) ; // new code: delete carriage

 

while(!feof($handle))

  {

  $name_array[$i] = fgets($handle);

  $i++;

  }

 

  sort($name_array);

  $i = 0;

 

  while($i<count($name_array)) {

  if (($name_array[$i] != "\n") && ($name_array[$i] != "\r\n")) {

if (($name_array[$i] != "") || (!empty($name_array[$i])))

  echo "$name_array[$i]<br />";

}

    $i++;

    }

fclose($handle);

   

    ?>

Sorry guys, I'm incredibly new to all of this.

 

Here is the code that is suppose to be for the people who have registered on the site: 

 

<?php
  
//$i = 0;
$name_array = array('test');
$insideitem = false;
$tag = "";
$first_name = "";
$last_name = "";
$maiden_name = "";
$address = "";
$city = "";
$state = "";
$zip = "";
$email = "";
$phone = "";
$occupation = "";
$spouse_name = "";
$child_name_1 = "";
$child_age_1 = "";
$child_name_2 = "";
$child_age_2 = "";
$child_name_3 = "";
$child_age_3 = "";
$child_name_4 = "";
$child_age_4 = "";
$child_name_5 = "";
$child_age_5 = "";
$comments = "";


function startElement($parser, $name, $attrs) {
global $insideitem, $tag, $first_name, $last_name, $maiden_name, $address, $city, $state, $zip, $email, $phone, $occupation, $spouse_name, $child_name_1, $child_age_1, $child_name_2, $child_age_2, $child_name_3, $child_age_3, $child_name_4, $child_age_4, $child_name_5, $child_age_5, $comments;

if ($insideitem) {
	$tag = $name;
} elseif ($name == "STUDENT") {
	$insideitem = true;
}

}

function endElement($parser, $name) {
global $name_array, $insideitem, $tag, $first_name, $last_name, $maiden_name, $address, $city, $state, $zip, $email, $phone, $occupation, $spouse_name, $child_name_1, $child_age_1, $child_name_2, $child_age_2, $child_name_3, $child_age_3, $child_name_4, $child_age_4, $child_name_5, $child_age_5, $comments;
  static $i = 0;
if ($name == "STUDENT") {
    //if (trim($first_name) == $_GET["first_name"] && trim($last_name) == $_GET["last_name"]) {
  if (trim($maiden_name) != "") {
      	$name_array[$i] = trim($maiden_name).", (".$last_name."), ".$first_name;
  } else {
  	$name_array[$i] = $last_name.", ".$first_name;
  }
      $i++;
        /*printf("<dt><a href=\"popup_xml_2.php?first_name=".trim($first_name)."&last_name=".trim($last_name)."\" onclick=\"window.open(this.href, 'popupwindow', 'width=300,height=300,scrollbars,resizable'); return false;\">%s</a></dt>",
		    trim($last_name.", ".$first_name));
	    printf("Maiden name: <dd>%s</dd>",htmlspecialchars(trim($maiden_name)));
	    printf("Address: <dd>%s</dd>",htmlspecialchars(trim($address)));
	    printf("City: <dd>%s</dd>",htmlspecialchars(trim($city)));
	    printf("State: <dd>%s</dd>",htmlspecialchars(trim($state)));
	    printf("Zip: <dd>%s</dd>",htmlspecialchars(trim($zip)));
	    printf("Email: <dd>%s</dd>",htmlspecialchars(trim($email)));
	    printf("Phone: <dd>%s</dd>",htmlspecialchars(trim($phone)));
	    printf("Occupation: <dd>%s</dd>",htmlspecialchars(trim($occupation)));
	    printf("Child name: <dd>%s, age %s</dd>",htmlspecialchars(trim($child_name_1)),htmlspecialchars(trim($child_age_1)));
	    printf("Child name: <dd>%s, age %s</dd>",htmlspecialchars(trim($child_name_2)),htmlspecialchars(trim($child_age_2)));
	    printf("Child name: <dd>%s, age %s</dd>",htmlspecialchars(trim($child_name_3)),htmlspecialchars(trim($child_age_3)));
	    printf("Child name: <dd>%s, age %s</dd>",htmlspecialchars(trim($child_name_4)),htmlspecialchars(trim($child_age_4)));
	    printf("Child name: <dd>%s, age %s</dd>",htmlspecialchars(trim($child_name_5)),htmlspecialchars(trim($child_age_5)));
	    printf("Comments: <dd>%s</dd>",htmlspecialchars(trim($comments)));*/
	//}

	    $first_name = "";
        $last_name = "";
        $maiden_name = "";
        $address = "";
        $city = "";
        $state = "";
        $zip = "";
        $email = "";
        $phone = "";
        $occupation = "";
	$spouse_name = "";
        $child_name_1 = "";
        $child_age_1 = "";
        $child_name_2 = "";
        $child_age_2 = "";
        $child_name_3 = "";
        $child_age_3 = "";
        $child_name_4 = "";
        $child_age_4 = "";
        $child_name_5 = "";
        $child_age_5 = "";
        $comments = "";
	$insideitem = false;
}
  if ($name == "STUDENTS") { // We've reached the end of our file, now alphabetize the array and print out in order
    $i = 0;
    sort($name_array);
        
    while($i<count($name_array)) { // We need to separate out each array element (which is in the form "Last name, first name") and add these to the appropriate querystring parameters
  
      $data = explode(',', $name_array[$i]);
  $data = str_replace("(", "", $data);
  $data = str_replace(")", "", $data);
  $name_array_clean[$i] = str_replace(",", " ", $name_array[$i]);
  $name_array_clean2[$i] = str_replace("()", "", trim($name_array_clean[$i]));
  //echo "name_array_clean2 = ".$name_array_clean2[1];
  
  if ($data[2] != "") {
  	echo "<a href=\"student_popup.php?first_name=".trim($data[2])."&last_name=".trim($data[1])."\" onclick=\"window.open(this.href, 'popupwindow', 'width=300,height=450,menubar=no,toolbar=no,scrollbars,resizable'); return false;\">$name_array_clean2[$i]</a><br />";
  } else {
	  echo "<a href=\"student_popup.php?first_name=".trim($data[1])."&last_name=".trim($data[0])."\" onclick=\"window.open(this.href, 'popupwindow', 'width=300,height=350,menubar=no,toolbar=no,scrollbars,resizable'); return false;\">$name_array_clean2[$i]</a><br />";
  }
      $i++;
    }
  }

}


function characterData($parser, $data) {
global $insideitem, $tag, $first_name, $last_name, $maiden_name, $address, $city, $state, $zip, $email, $phone, $occupation, $spouse_name, $child_name_1, $child_age_1, $child_name_2, $child_age_2, $child_name_3, $child_age_3, $child_name_4, $child_age_4, $child_name_5, $child_age_5, $comments;
if ($insideitem) {
switch ($tag) {
	case "FIRST_NAME":
	$first_name .= $data;
	break;
	case "LAST_NAME":
	$last_name .= $data;
	break;
	case "MAIDEN_NAME":
	$maiden_name .= $data;
	break;
	case "ADDRESS":
	$address .= $data;
	break;
	case "CITY":
	$city .= $data;
	break;
	case "STATE":
	$state .= $data;
	break;
	case "ZIP":
	$zip .= $data;
	break;
	case "EMAIL":
	$email .= $data;
	break;
	case "PHONE":
	$phone .= $data;
	break;
	case "OCCUPATION":
	$occupation .= $data;
	break;
	case "SPOUSE_NAME":
	$spouse_name .= $data;
	break;
	case "CHILD_NAME_1":
	$child_name_1 .= $data;
	break;
	case "CHILD_AGE_1":
	$child_age_1 .= $data;
	break;
	case "CHILD_NAME_2":
	$child_name_2 .= $data;
	break;
	case "CHILD_AGE_2":
	$child_age_2 .= $data;
	break;
	case "CHILD_NAME_3":
	$child_name_3 .= $data;
	break;
	case "CHILD_AGE_3":
	$child_age_3 .= $data;
	break;
	case "CHILD_NAME_4":
	$child_name_4 .= $data;
	break;
	case "CHILD_AGE_4":
	$child_age_4 .= $data;
	break;
	case "CHILD_NAME_5":
	$child_name_5 .= $data;
	break;
	case "CHILD_AGE_5":
	$child_age_5 .= $data;
	break;
	case "COMMENTS":
	$comments .= $data;
	break;

}
}
}

$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
$fp = fopen("registration.xml","r")
or die("Error reading XML data.");
while ($data = fread($fp, 4096))
xml_parse($xml_parser, $data, feof($fp))
	or die(sprintf("XML error: %s at line %d", 
		xml_error_string(xml_get_error_code($xml_parser)), 
		xml_get_current_line_number($xml_parser)));
      
fclose($fp);
xml_parser_free($xml_parser);

    
    ?>

 

 

And here is the code for the people who are still on the LOST list:

 

<?php

$name_array = array('test');  
$i = 0;
  
//$wholefile = file("not_found.txt");
//foreach($wholefile as $line) echo $line.'<br>';

$myFile = "not_found.txt"; 
$handle = fopen($myFile, 'r');

//$handle = str_replace("\n","",$handle) ; // new code: delete newlines 
//$handle = str_replace("\r","",$handle) ; // new code: delete carriage

while(!feof($handle))
  {
  $name_array[$i] = fgets($handle);
  $i++;
  }
  
  sort($name_array);
  $i = 0;
  
  while($i<count($name_array)) {
  	if (($name_array[$i] != "\n") && ($name_array[$i] != "\r\n")) {
		if (($name_array[$i] != "") || (!empty($name_array[$i])))
		  echo "$name_array[$i]<br />";
}
    $i++;
    }
fclose($handle);
    
    ?>

LoL. I told you, I'm extremely new to this and I'm just trying to finish this site.  I really have no idea what I'm doing when in comes to PHP, and I just started using Dreamweaver like 4 months ago.  I was given the original dev files and have been altering whats there.  Changing pictures and text was easy, but trying to add new names to this list and then once they've registered having the name appear in the found list has me very confused.

 

So, can you give me an example of a database I can use? :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.