Ro'yxatga olish sanasi 10 Fevral 2025
7 Sotish 
                                                                             
                                                                             
                                                                             
                                                                             
                                                                             
                                                                             
                                                                             
                                                                             
                                                                             
                                                                             
                                                                             
                                                                             
                                                                             
                                                                             
                                                                             
                                                                             
                                                                             
                                                                             
                                                                             
                                                                            ![link :  '#'
        },
        {
             title :  'Yangilik 2: Tech Expo 2025 boshlanadi' ,
                        content :   'Tech   Expo   2025   yil   25   yanvar   kuni   Toshkentda   boshlanadi.
Tadbirda...' ,
             link :  '#'
        }
    ];
     const  newsSection =  document . getElementById ( 'news' );
    newsItems. forEach ( item  =>  {
         const  article =  document . createElement ( 'article' );
        article. classList . add ( 'news-item' );
        
         const  title =  document . createElement ( 'h3' );
        title. textContent  = item. title ;
        
         const  content =  document . createElement ( 'p' );
        content. textContent  = item. content ;
         const  link =  document . createElement ( 'a' );
        link. href  = item. link ;
        link. textContent  =  'Batafsil' ;
        article. appendChild (title);
        article. appendChild (content);
        article. appendChild (link);
        
        newsSection. appendChild (article);
    });
</ script >
4.  Backend (PHP va MySQL)
Portalga   ma'lumotlar   bazasidan   ma'lumotlarni   olish   uchun   PHP   va   MySQL
ishlatish   mumkin.   Misol   uchun,   yangiliklar   ro'yxatini   MySQL   ma'lumotlar
bazasidan olish:
PHP kod:
php
КопироватьРедактировать](https://docx.uz/documents/4d288648-1247-431e-a533-d1b19bacdf27/page_21.png?v=1) 
                                                                            ![<?php
$servername  =  "localhost" ;
$username  =  "root" ;
$password  =  "" ;
$dbname  =  "news_portal" ;
// Ma'lumotlar bazasi bilan ulanish
$conn  =  new   mysqli ( $servername ,  $username ,  $password ,  $dbname );
// Ulanish tekshiruvi
if  ( $conn ->connect_error) {
     die ( "Connection failed: "  .  $conn ->connect_error);
}
$sql  =  "SELECT title, content FROM news ORDER BY date DESC" ;
$result  =  $conn -> query ( $sql );
if  ( $result ->num_rows >  0 ) {
     // Yangiliklarni chiqarish
     while ( $row  =  $result -> fetch_assoc ()) {
         echo   "<article class='news-item'>" ;
         echo   "<h3>"  .  $row [ "title" ].  "</h3>" ;
         echo   "<p>"  .  $row [ "content" ].  "</p>" ;
         echo   "<a href='#'>Batafsil</a>" ;
         echo   "</article>" ;
    }
}  else  {
     echo   "Yangiliklar mavjud emas." ;
}
$conn -> close ();
?>
5.  Ma'lumotlar Bazasi (MySQL)
Yangiliklar   ma'lumotlarini   saqlash   uchun   MySQL   ma'lumotlar   bazasini   yaratish
kerak:
sql
КопироватьРедактировать
CREATE  DATABASE news_portal;
USE news_portal;](https://docx.uz/documents/4d288648-1247-431e-a533-d1b19bacdf27/page_22.png?v=1) 
                                                                             
                                                                             
                                                                             
                                                                             
                                                                             
                                                                             
                                                                             
                                                                             
                                                                             
                                                                             
                                                                    Informatsion portal ishlab chiqish