:
<?php
if (!($row = sql_fetch_row ($result))) {
print ": ";
exit;
}
do {
print "$row[0]: $row[1]\n<br>\n";
}
while ($row = sql_fetch_row ($result));
?>
:
sql_fetch_row(), . - $result sql_num_rows():
<?php
if (sql_num_rows ($result) <= 0) {
print ": ";
exit;
}
while ($row = sql_fetch_row ($result)){
print "$row[0]: $row[1]\n<br>\n";
}
?>
do..while, " " sql_num_row() $row, - .
- sql_fetch_row() . . sql_fetch_array(), : :
<?php
$row = sql_fetch_array ($result);
print $row[1]; //
print $row[name]; // name -
?>
: . ( name) .
? , . :
<?php
if (sql_num_rows ($result) <= 0) {
print ": ";
exit;
}
while ($row = sql_fetch_array ($result)) {
print "$row[name]: $row[phone_number]\n<br>\n";
}
?>
SQL: ,
(SQL) . ( SQL) , (, PHP). PHP - .
SQL- - WHERE SQL.
, id 5:
<?php
//
// , $conn
// .
$statement = "SELECT name, phone, id FROM samp_table";
$result = @sql_query ($statement, $conn);
if (!$result) {
die (sprintf (" [%d]: %s", sql_errno (), sql_error ()));
|
|
}
if (@sql_num_rows ($result) <= 0) {
die (" ");
}
while ($row = @sql_fetch_array ($result)){
if ($row[id] & 5) {
print ": $row[name]\n<br>\n";
print ": $row[phone]\n<br>\n";
break;
}
}
?>
: PHP; , .
: SQL- WHERE:
<?php
$statement = "SELECT name, phone FROM samp_table";
$statement.= " WHERE id='5'";
WHERE . . "id=5".
, PHP :
<?php
if (@sql_num_rows ($result)!= 1) {
die (" ");
}
$row = @sql_fetch_array ($result);
print ": $row[name]\n<br>\n";
print ": $row[phone]\n<br>\n";
?>
PHP
, PHP. , SQL , PHP.
SQL (ORDER BY), PHP- ksort().
ksort() (name):
<?php
$statement = "SELECT name, email, phone FROM some_table ";
$statement.= "WHERE name IS LIKE '%baggins'";
$result = @sql_db_query ($statement, "samp_db", $conn);
if (!$result) {
die (sprintf (" [%d]: %s", sql_errno (),sql_error ()));
}
while ($row = @sql_fetch_array ($result)){
$matches[ $row[name] ] = array ($row[email], $row[phone]);
}
ksort ($matches);
?>
: ? .
, ksort() SQL-, ORDER BY:
<?php
$statement = "SELECT name, email, phone FROM some_table ";
$statement.= "WHERE name IS LIKE '%baggins' ORDER BY name";
?>
. HTTP
HTTP. HTTP /. - - :
, URI, , , , .
. URL-: http:bsu.by/my.php :
URL- :
- HTTP.
- , bsu. by.
- , , /my.php.
HTTP, :
GET /my.php HTTP/1.1
Accept: image/gif, image/png, image/jpeg, */*
|
|
Accept-Language: en-us
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0;
Windows XP;.NET CLR 1.1.4322)
Host:bsu.by
Connection: Keep-Alive
:
GET HTTP : " , /.php, , HTTP 1.1".
Accept " ".
Accept-Language ", , ". Accept-Encoding " , gzip deflate".
User-Agent " Microsoft Explorer 8, Windows XP".
Host " /my.php , feedster.com".
Connection: Keep-Alive " HTTP , ". , . Keep-Alive Web- .
Web- , , /my. php.
.
, ( - ), MIME- , , , , . (response) () :
/1.1 200 0
Date: , 08 Dec 2003 16:46:40 GMT
Server: Apache/1.3.27 (Unix) mod_throttle/3.1.2 PHP/4.3.2
X-Powered-By: PHP/4.3.2
X-Accelerated-By: PHPA/1.3.3r2
Connection: close
Content-Type: text/html; charset=utf-8
<html lang="en-US" xml:lang="en-US" nlns="http://www.w3.org/1999/xhtml">
<head>
<script>
HTTP- . - (response header). . (body). :
HTTP/1.1 , HTTP 1.1. 200 HTTP : " , ".
Date , , . GMT, .
Server , .
X-Powered-By (, ).
X-Accelerated-By ( - ).
Connection , , .
Content-Type , . .
HTTP
HTTP , Web-, -, HTTP-. :
GET-. HTTP, GET. , Web- URL-. HTTP , GET , .
POST-. Web-, POST. , Web- Web-.
HEAD-. URL, URL, HEAD.
|
|
GET URL, POST . JavaScript, PHP.
HTTP Firefox, HttpFox .
HttpFox localhost.
HTML-
PHP HTML . , . . , .
, , HTML- <form...> n</form>. , , , , checkbox, jpg gif. . PHP.
, <form...> - . , , , , , , , . , web-, .
- php.ini - register_globals on, , , - : - , checkbox - True False , - . , , , $_POST_ $_GET. <input type=text name=myname size=30> $_POST['myname']) $_GET['myname']). , GET , POST - . $_POST $_GET , , . . . , PHP register_globals off . PHP: $_GET[], $_POST[], $_REQUEST[], $_COOKIE[], $_FILES[], $_SERVER[], $_ENV[], $_SESSION[].