Bloglar | Sayt yaratish bo'yicha | Dasturlash uslubi(3-qism)
Keling, ba'zi misollarni ko'rib chiqaylik.Odatda, SQLni saqlash uchun vaqtinchalik satrlarga $ so'rov (so'rov) deb nom berilgan - bu SQL so'roviga bog'liq bo'lgan juda yaxshi ism.Odatda bu barcha tugaydi.Ikkinchi so'rovlar paydo bo'lganda, ikkinchi o'zgaruvchilar nomi $ query1 oladi - bu yomon amaldir.Odatda bitta skript ichidagi so'rovlar o'zlarining harakatlarida farq qiladi: bitta SQL so'rovi (UPDATE), boshqa bir misolni (SELECT) amalga oshirishi mumkin, shuning uchun o'zgaruvchini operator harakati ifodasi bilan belgilash yaxshiroq: $ query_update va $ query_select.
Kodni tez-tez ko'rishingiz mumkin

#000000">
/> <?php
#0000BB"><?php
/>
$query
=#007700">= style="color: #DD0000">"SELECT * FROM catalog" style="color: #007700">;
/>
$query1#0000BB">$query1 style="color: #007700">= style="color: #0000BB">mysql_query style="color: #007700">( style="color: #0000BB">$query style="color: #007700">);
/>
while(
$result#0000BB">$result style="color: #007700">= style="color: #0000BB">mysql_fetch_array style="color: #007700">( style="color: #0000BB">$query1 style="color: #007700">))
/>
{

/* Код обработки */
#FF8000">/* Код обработки */
/>
}
#007700">}
/>
?>
#0000BB">?>

/>


Bu erda mysql_query () funktsiyasi tomonidan qaytarilgan so'rovlar identifikatori $ query1 deb ataladi, dasturni ishlab chiqaruvchisi va o'quvchini aralashtirib yuborish juda yaxshi.Ta'rifchining jismoniy ma'nosi yo'q - bu faqat natijaning kalitidir, shuning uchun uni jadvalning qisqartirilgan nomi deb atash yaxshiroqdir.

#000000">
/> <?php
#0000BB"><?php
/>
$query
=#007700">= style="color: #DD0000">"SELECT * FROM catalog" style="color: #007700">;
/>
$cat#0000BB">$cat style="color: #007700">= style="color: #0000BB">mysql_query style="color: #007700">( style="color: #0000BB">$query style="color: #007700">);
/>
while(
$catalog#0000BB">$catalog style="color: #007700">= style="color: #0000BB">mysql_fetch_array style="color: #007700">( style="color: #0000BB">$cat style="color: #007700">))
/>
{

/* Код обработки */
#FF8000">/* Код обработки */
/>
}
#007700">}
/>
?>
#0000BB">?>

/>

Ma'lumotlar
Yaratilgan vaqt: 15 Aug 2018, 14:19
Muallif: @Ashurov (54)
Raxmat aytishgan: 1 kishi
Fikrlar: 0 ta
Ko'rilgan: 13 marta
Shikoyatim bor
Blog bilan bo'lishish
www.uzmasters.ru Onlayn 137 (0/137)
www.uzmasters.ru Forumga a'zo bo'lish
www.uzmasters.ru Forumdan qidirish
www.uzmasters.ru Bosh sahifa
Яндекс.Метрика UzMasterS.Ru