This is my first php program!



Download 6,9 Mb.
Pdf ko'rish
bet65/69
Sana26.02.2022
Hajmi6,9 Mb.
#471647
1   ...   61   62   63   64   65   66   67   68   69
Bog'liq
PHP



210
|
Chapter 8: Databases
if (in_array($row[1], $Biz_Categories)) {
$sql = 'INSERT INTO biz_categories';
$sql .= ' (business_id, category_id)';
$sql .= ' VALUES (?, ?)';
$params = array($biz_id, $row[0]);
$query = $db->prepare($sql);
if (DB::isError($query)) die($query->getMessage( ));
$resp = $db->execute($query, $params);
if (DB::isError($resp)) die($resp->getMessage( ));
$resp = $db->commit( );
if (DB::isError($resp)) die($resp->getMessage( ));
echo "\n";
$selected = true;
}
if ($selected == false) {
echo "\n";
}
} else {
echo "\n";
}
}
?>



















Business Name: value=""
Address: value=""
City: value=""
Telephone: value=""
URL: value=""


Example 8-5. Adding a business (continued)
,ch08.16110 Page 210 Wednesday, March 13, 2002 11:44 AM


This is the Title of the Book, eMatter Edition
Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.
Sample Application
|
211
Displaying the Database
Example 8-6 shows a page that displays the information in the database. The links
on the left side of the page are created from the
categories
table and link back to the
script, adding a category ID. The category ID forms the basis for a query on the
businesses
table and the
biz_categories
table.

// display the submit button on new forms; link to a fresh registration
// page on confirmations
if ($add_record == 1){
echo '
Add Another Business
';
} else {
echo '';
}
?>




// establish the database connection
require_once('db_login.php');
$pick_message = 'Click on a category to find business listings:';
?>




Example 8-5. Adding a business (continued)
,ch08.16110 Page 211 Wednesday, March 13, 2002 11:44 AM


This is the Title of the Book, eMatter Edition
Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.
212
|
Chapter 8: Databases


// build the scrolling pick list for the categories
$sql = "SELECT * FROM categories";
$result = $db->query($sql);
if (DB::isError($result)) die($result->getMessage( ));
while ($row = $result->fetchRow( )){
if (DB::isError($row)) die($row->getMessage( ));
echo '\n";
}
?>
';
echo "";
echo "$row[1]



if ($cat_id) {
$sql = "SELECT * FROM businesses b, biz_categories bc where";
$sql .= " category_id = '$cat_id'";
$sql .= " and b.business_id = bc.business_id";
$result = $db->query($sql);
if (DB::isError($result)) die($result->getMessage( ));
while ($row = $result->fetchRow( )){
if (DB::isError($row)) die($row->getMessage( ));
if ($color == 1) {
$bg_shade = 'dark';
$color = 0;
} else {
$bg_shade = 'light';
$color = 1;
}
echo "\n";
for($i = 0; $i < count($row); $i++) {
echo "\n";
}
echo "\n";
}
}
?>
$row[$i]


This page contains two images.


This page contains two images.



$im = imagecreatefromjpeg('php-tiny.jpg');
$dx = imagesx($im);
$dy = imagesy($im);
for($y = 0; $y < $dy; $y++) {
for($x=0; $x < $dx; $x++) {
$col = imagecolorat($im, $x, $y);
$rgb = imagecolorsforindex($im,$col);
printf('#',
$rgb['red'],$rgb['green'],$rgb['blue']);
}
echo "
\n";
}
imagedestroy($im);
?>

class BookList {
var $parser;
var $record;
var $current_field = '';
var $field_type;
var $ends_record;
var $records;
,ch11.16545 Page 275 Wednesday, March 13, 2002 11:45 AM


This is the Title of the Book, eMatter Edition
Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.

Download 6,9 Mb.

Do'stlaringiz bilan baham:
1   ...   61   62   63   64   65   66   67   68   69




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish