1. , Web-, , , Lab4_PHP.
2. , Web-, , , server.
3. server nusoap. php ( D Student) SOAP.
4. server , , index. php. .
5. <?php
6. nusoap. php:
require_once('nusoap. php');
7. MySQL University
7.1 link
$link = @mysql_connect("localhost", "root") or die(" ");
7.2 University
$db=@mysql_select_db("university") or die(" ");
7.3 (cp-1251) . PHP :
@mysql_query("SET SESSION character_set_results = cp1251;");
@mysql_query("SET SESSION Character_set_client = cp1251;");
@mysql_query("SET SESSION Character_set_results = cp1251;");
@mysql_query("SET SESSION Collation_connection = cp1251_general_ci;");
@mysql_query("SET SESSION Character_set_connection = cp1251;");
8. SOAP-:
$server = new soap_server;
9. faculty ( )
9.1 register server
$server->register(
9.2 faculty: 'faculty',
9.3 :
array('return' => 'xsd:string'),
9.4 :
'uri:facultyquery',
9.5 SOAPAction
'uri:facultyquery/faculty',
9.6 rpc/encoded
'rpc',
'encoded'
);
10. faculty PHP.
10.1 (faculty) :
function faculty() {
10.2 f_query
$f_query="select * from `faculty`";
10.3 :
$f=mysql_query($f_query);
10.4 facOptions XML- . faculties
10.5 while f:
while ($fac = mysql_fetch_array($f))
{
}
10.6 XML- faculty, Faculty. ID name, . :
$facOptions = $facOptions."<faculty ID='".$fac['ID']."' name='".$fac['name']."'/>";
|
|
10.7 , faculty, facOptions, faculties:
return $facOptions.'</faculties>';
}
11. (. . 9) spec, XML- .
12. spec PHP (. . 10).
13. gr, XML- PHP.
14. usp () name ( ). :
$server->register(
'usp',
array('group' => 'xsd:string'),
array('return' => 'xsd:string'),
'uri:uspquery',
'uri:uspquery/usp',
'rpc',
'encoded'
);
15. usp PHP:
function usp($group){
$usp_query="SELECT `fio`, `subject`, `ocenka`, `data`
FROM `uspev`, `student`
WHERE `uspev`.`student`= `student`.`zk` AND `gr`=".$group;
$usp=mysql_query($usp_query);
$usp_count = mysql_num_rows($usp);
$usOptions = '<uspev>';
while ($u = mysql_fetch_array($usp))
{
$usOptions = $usOptions."<usp fio='".$u['fio']."' subject='".$u['subject']."' ocenka='".$u['ocenka']."' data='".$u['data']."'/>";
}
return $usOptions.'</uspev>';
}
16. HTTP-
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA)? $HTTP_RAW_POST_DATA: '';
$server->service($HTTP_RAW_POST_DATA);
17. ?>.
Web-
1. Lab4_PHP nuSOAP ( ) Index. php Browse. php .
2. Index. php.
3. <?php
4. nusoap. php:
require_once('nusoap. php');
5. SOAP-.
5.1 client
5.2 soapclient URL SOAP- ( ):
$client = new soapclient('http://localhost/denwer/Lab4_PHP/server/index. php');
6. SOAP- faculty:
$faculty = $client->call('faculty');
7. SOAP- spec gr:
$spec = $client->call('spec');
$gr = $client->call('gr');
8. DOM-
8.1 DOM- fac_dom:
$fac_dom = new DOMDocument();
8.2 DOM-:
$fac_dom -> encoding = "windows-1251";
8.3 DOM- XML- , SOAP- faculty:
$fac_dom->loadXml(iconv("windows-1251", "utf-8", $faculty));
8.4 DOM- spec_dom ( XML- ) gr_dom ( XML- ).
9. ?>
10. (HTML- select name = "faculty") XML- .
<option value="0"> </option>
10.1 :
|
|
<?php
10.2 DOM- fac_dom:
foreach ($fac_dom->documentElement->childNodes as $item) {
10.3 value XML- ID:
$value = iconv("utf-8", "windows-1251", $item->getAttribute('ID'));
10.4 text XML- name:
$text = iconv("utf-8", "windows-1251", $item->getAttribute('name'));
10.5 HTML- option value text.
echo "<option value='".$value."'>".$text."</option>";
}
10.6. ?>
11. ( DOM- spec_dom) ( DOM- gr_dom).
12. Browse. php.
13. nusoap. php:
require_once('nusoap. php');
14. gr gr, POST Index. php:
$gr = $_POST['gr'];
15. SOAP- (. . 5) client.
16. usp gr:
$result = $client->call('usp', array('group' => $gr));
17. DOM- usp_dom:
$usp_dom = new DOMDocument();
$usp_dom -> encoding = "windows-1251";
$usp_dom->loadXml(iconv("windows-1251", "utf-8", $result));
18. TABLE textborder XML-
18.1 :
<?php
18.2 DOM- usp_dom:
foreach ($usp_dom->documentElement->childNodes as $item)
{
18.3 fio, subject, ocenka data XML-:
$fio= iconv("utf-8", "windows-1251", $item->getAttribute('fio'));
$subject = iconv("utf-8", "windows-1251", $item->getAttribute('subject'));
$ocenka = iconv("utf-8", "windows-1251", $item->getAttribute('ocenka'));
$data = iconv("utf-8", "windows-1251", $item->getAttribute('data'));
18.4 ?>
18.5 TR:
<TR>
18.6. ( 30% ). tabletext:
<TD width="30%"><SPAN class="tabletext">
18.7 fio
<?php
echo $fio;
?>
18.8 SPAN TD:
</SPAN></TD>
18.9 subject, data ocenka .
19. Web-
. JSP MySQL