-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetSearchResultsBy.php
More file actions
93 lines (71 loc) · 3.37 KB
/
Copy pathgetSearchResultsBy.php
File metadata and controls
93 lines (71 loc) · 3.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
include("utilities.php");
function displayData($noteID, $titleNode, $senderTitleNode, $senderForenameNode ,$senderSurnameNode, $recipientsTitleNode, $recipientsForenameNode, $recipientsSurnameNode, $dateNode,$messageNode, $urlNode, $statusNode)
{
echo ("<tr id='$noteID'> <td>".$noteID."</td>");
echo ("<td>".$titleNode->nodeValue."</td>");
echo ("<td>".$senderTitleNode->nodeValue." ".$senderForenameNode->nodeValue." ".$senderSurnameNode->nodeValue."</td>");
echo ("<td>".$recipientsTitleNode->nodeValue." ".$recipientsForenameNode->nodeValue." ".$recipientsSurnameNode->nodeValue."</td>");
echo ("<td>".$dateNode->nodeValue."</td>");
echo ("<td id='status_$noteID'>".$statusNode->nodeValue."</td>");
echo ("<td><select id='editStatus' onchange='editStatus($noteID,this.value)'>");
echo ("<option value=''>Change Status</option>");
echo ("<option value='new'>New</option>");
echo ("<option value='current'>Current</option>");
echo ("<option value='historic'>Historic</option>");
echo ("</select><td>");
echo ("<td> <input type='button' value='View' onclick='viewNote($noteID)'> </td>");
echo ("<td> <input type='button' value='Delete' onclick='deleteNote($noteID)'> </td> </tr>");
}
if(isset($_GET['result']))
{
$result = $_GET["result"];
$xml=getXML("note.xml");
// get document element
$root = $xml->documentElement;
$notes = $root->childNodes->item(3);
$notesFound = 0;
echo ("<table id='displayNoteResults'>");
echo ("<tr> <th>Note ID</th> <th>Title</th> <th>Sender</th> <th>Recipent</th> <th>Date</th> <th>Status</th> </tr>");
foreach($notes->childNodes as $note)
{
$notesFound++;
$noteID = $note->getAttribute('id');
//title
$titleNode = $note->childNodes->item(0);
//sender
$noteSenderNode = $note->childNodes->item(1);
$senderID = $noteSenderNode->getAttribute('id');
$senderTitleNode = $noteSenderNode->childNodes->item(0);
$senderForenameNode = $noteSenderNode->childNodes->item(1);
$senderSurnameNode = $noteSenderNode->childNodes->item(2);
//date
$dateNode = $note->childNodes->item(3);
//url
$urlNode = $note->childNodes->item(4);
//message
$messageNode = $note->childNodes->item(5);
//status
$statusNode = $note->childNodes->item(6);
//recipient
$noteRecipientsNode = $note->childNodes->item(2);
foreach($noteRecipientsNode->childNodes as $recipients)
{
$recipientID = $recipients->getAttribute('id');
$recipientsTitleNode = $recipients->childNodes->item(0);
$recipientsForenameNode = $recipients->childNodes->item(1);
$recipientsSurnameNode = $recipients->childNodes->item(2);
if($recipientID==$result)
{
displayData($noteID, $titleNode, $senderTitleNode, $senderForenameNode ,$senderSurnameNode, $recipientsTitleNode, $recipientsForenameNode, $recipientsSurnameNode, $dateNode,$messageNode, $urlNode, $statusNode);
}
}
if ($noteID==$result || $senderID==$result || $statusNode->nodeValue==$result)
{
displayData($noteID, $titleNode, $senderTitleNode, $senderForenameNode ,$senderSurnameNode, $recipientsTitleNode, $recipientsForenameNode, $recipientsSurnameNode, $dateNode,$messageNode, $urlNode, $statusNode);
}
}
if($notesFound==0) echo("</br> No notes found");
echo("</table>");
}
?>