This is my first php program!



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

Sample Application
|
207
When the administrator submits a new category, we construct a query to add the
category to the database. Another query displays the table of all current categories.
Figure 8-4 shows the page with five records loaded.
Adding a Business
Example 8-5 shows the page that lets a business insert data into the
business
and
biz_categories
tables. Figure 8-5 shows the form.
When the user enters data and clicks on the Add Business button, the script calls
itself to display a confirmation page. Figure 8-6 shows a confirmation page for a
company listing assigned to two categories.
In the confirmation page, the Add Business button is replaced by a link that will
invoke a fresh instance of the script. A success message is displayed at the top of
the page. Instructions for using the scrolling pick list are replaced with explanatory
text.
As shown in Example 8-5, we build the scrolling list from a query to select all the cat-
egories. As we produce HTML for each of the results from that query, we also check
to see whether the current category was one of the categories submitted for the new
business. If it was, we add a new record to the
biz_categories
table.





require_once('db_login.php');
// fetch query parameters
$add_record = $_REQUEST['add_record'];
$Biz_Name = $_REQUEST['Biz_Name'];
$Biz_Address = $_REQUEST['Biz_Address'];
$Biz_City = $_REQUEST['Biz_City'];
$Biz_Telephone = $_REQUEST['Biz_Telephone'];
$Biz_URL = $_REQUEST['Biz_URL'];
$Biz_Categories = $_REQUEST['Biz_Categories'];
$pick_message = 'Click on one, or control-click on
multiple ';
$pick_message .= 'categories:';
// add new business
if ($add_record == 1) {
$pick_message = 'Selected category values
are highlighted:';
$sql = 'INSERT INTO businesses (name, address, city, telephone, ';
$sql .= ' url) VALUES (?, ?, ?, ?, ?)';
$params = array($Biz_Name, $Biz_Address, $Biz_City, $Biz_Telephone, $Biz_URL);
$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 '
Record inserted as shown below.
';
$biz_id = $db->getOne('SELECT max(business_id) FROM businesses');
}
?>




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