Konuyu Oyla:
  • Derecelendirme: 0/5 - 0 oy
  • 1
  • 2
  • 3
  • 4
  • 5
html içinde php kodu kullanmak while,for döngüsü[php sorusu]
#1
Merhaba
Delphi de yazdığımız aşağıdaki gibi bir kodu php de yazamadım.Yardımcı olur musunuz?
Tablodaki satır sayısını bir while yada for döngüsü içine almak istiyorum.
Yapmak istediğimin delphi karşılığı:

var
i:integer;
i:=0;
with qrUser do
begin
close;
open;
first;
while not eof do
begin
grid.cells[0,i]:=qruserkullanici.value;

...

....

...

i:=i+1;

next;

end;
end;

php tarafında şöyle yapıyorum. bu kodla bağlanıp veriyi cekiyorum.
<?php
    error_reporting($level = 1);    
    
    
        $username="AHMET";
        
        try{
        
        #open database
        $vt=new PDO("sqlite:ippdu.sqlite3");
        
        
        
        $select=$vt->query("SELECT * FROM USERS",PDO::FETCH_ASSOC);
        
        $num=1;
        foreach($select as $row){
            echo $row['ID']    ;    
            echo $row['KULLANICI'];
            echo $row['SIFRE']    ;
            echo $row['EMAIL']    ;
            echo $row['MONITOR']    ;
            echo $row['YONETICI']    ;
            echo $row['SIL']    ;
            $kullanici=$row['KULLANICI']."ddddd"    ;
            $sifre=$row['SIFRE'];
            $kullanicilar[$num]=$row['KULLANICI'];
            $erisim[$num]=$row['YONETICI'];
            $Monitor[$num]=$row['MONITOR'];
            
            $num=$num+1;
    
            }
        
            
    
    }catch(PDOException $e){
        echo $e -> getMessage();
    
    
    
    }        
        
    
    
?>
aldığım veriyi bootstrap tablosundaki satırlara eklemek istiyorum ama burada  n sayıda satır sayısı kullanmak için while yada for döngüsüne ihtiyacım var ama satır tag ları nasıl php for döngüsüne alabilirim.?
<!DOCTYPE html>
<html>
<head>


<meta charset="utf-8" />

<link href="css/bootstrap.css" rel="stylesheet" />

<link href="css/bootstrap-theme.css" rel="stylesheet" />

<title></title>
</head>
<body>

<script src="js/bootstrap.min.js"></script>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
 <a class="navbar-brand" href="#">Navbar</a>
 <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
   <span class="navbar-toggler-icon"></span>
 </button>

 <div class="collapse navbar-collapse" id="navbarSupportedContent">
   <ul class="navbar-nav mr-auto">
     <li class="nav-item active">
       <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
     </li>
     <li class="nav-item">
       <a class="nav-link" href="#">Link</a>
     </li>
     <li class="nav-item dropdown">
       <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
         Dropdown
       </a>
       <div class="dropdown-menu" aria-labelledby="navbarDropdown">
         <a class="dropdown-item" href="#">Action</a>
         <a class="dropdown-item" href="#">Another action</a>
         <div class="dropdown-divider"></div>
         <a class="dropdown-item" href="#">Something else here</a>
       </div>
     </li>
     <li class="nav-item">
       <a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
     </li>
   </ul>
   <form class="form-inline my-2 my-lg-0">
     <input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
     <button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
   </form>
 </div>
</nav>
<table class="table table-striped table-dark">
 <thead>
   <tr>
     <th scope="col">#</th>
     <th scope="col">Users</th>
     <th scope="col">Access Type</th>
     <th scope="col">Monitor</th>
     <th scope="col">Edit</th>
   </tr>
 </thead>
 <tbody>
 
   <tr>
     <th scope="row">1</th>
     <td><?php echo $kullanicilar[1]; ?></td>
     <td><?php echo $erisim[1]; ?></td>
     <td>@mdo</td>
   </tr>
   <tr>
     <th scope="row">2</th>
     <td><?php echo $kullanicilar[1]; ?></td>
     <td>Thornton</td>
     <td>@fat</td>
   </tr>
   <tr>
     <th scope="row">3</th>
     <td><?php echo $kullanicilar[3]; ?></td>
     <td>the Bird</td>
     <td>@twitter</td>
   </tr>
 </tbody>
</table>
<p>"gggggggg"</p>



</body>
</html>
ekran[url=dL3GJZ.png]ekran[/url]
Cevapla
#2
(12-07-2019, Saat: 12:02)41linea41 Adlı Kullanıcıdan Alıntı: Merhaba
Delphi de yazdığımız aşağıdaki gibi bir kodu php de yazamadım.Yardımcı olur musunuz?
Tablodaki satır sayısını bir while yada for döngüsü içine almak istiyorum.
Yapmak istediğimin delphi karşılığı:

var
i:integer;
i:=0;

with qrUser do

begin

close;

open;

first;

while not eof do

begin

grid.cells[0,i]:=qruserkullanici.value;

...

....

...


i:=i+1;

next;

end;



end;

php tarafında şöyle yapıyorum. bu kodla bağlanıp veriyi cekiyorum.
<?php
    error_reporting($level = 1);    
    
    
        $username="AHMET";
        
        try{
        
        #open database
        $vt=new PDO("sqlite:ippdu.sqlite3");
        
        
        
        $select=$vt->query("SELECT * FROM USERS",PDO::FETCH_ASSOC);
        
        $num=1;
        foreach($select as $row){
            echo $row['ID']    ;    
            echo $row['KULLANICI'];
            echo $row['SIFRE']    ;
            echo $row['EMAIL']    ;
            echo $row['MONITOR']    ;
            echo $row['YONETICI']    ;
            echo $row['SIL']    ;
            $kullanici=$row['KULLANICI']."ddddd"    ;
            $sifre=$row['SIFRE'];
            $kullanicilar[$num]=$row['KULLANICI'];
            $erisim[$num]=$row['YONETICI'];
            $Monitor[$num]=$row['MONITOR'];
            
            $num=$num+1;
    
            }
        
            
    
    }catch(PDOException $e){
        echo $e -> getMessage();
    
    
    
    }        
        
    
    
?>
aldığım veriyi bootstrap tablosundaki satırlara eklemek istiyorum ama burada  n sayıda satır sayısı kullanmak için while yada for döngüsüne ihtiyacım var ama satır tag ları nasıl php for döngüsüne alabilirim.?

<!DOCTYPE html>
<html>
<head>


    <meta charset="utf-8" />

    <link href="css/bootstrap.css" rel="stylesheet" />

    <link href="css/bootstrap-theme.css" rel="stylesheet" />

<title></title>
</head>
<body>
    
    <script src="js/bootstrap.min.js"></script>
    <nav class="navbar navbar-expand-lg navbar-light bg-light">
 <a class="navbar-brand" href="#">Navbar</a>
 <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
   <span class="navbar-toggler-icon"></span>
 </button>

 <div class="collapse navbar-collapse" id="navbarSupportedContent">
   <ul class="navbar-nav mr-auto">
     <li class="nav-item active">
       <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
     </li>
     <li class="nav-item">
       <a class="nav-link" href="#">Link</a>
     </li>
     <li class="nav-item dropdown">
       <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
         Dropdown
       </a>
       <div class="dropdown-menu" aria-labelledby="navbarDropdown">
         <a class="dropdown-item" href="#">Action</a>
         <a class="dropdown-item" href="#">Another action</a>
         <div class="dropdown-divider"></div>
         <a class="dropdown-item" href="#">Something else here</a>
       </div>
     </li>
     <li class="nav-item">
       <a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
     </li>
   </ul>
   <form class="form-inline my-2 my-lg-0">
     <input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
     <button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
   </form>
 </div>
</nav>
    <table class="table table-striped table-dark">
 <thead>
   <tr>
     <th scope="col">#</th>
     <th scope="col">Users</th>
     <th scope="col">Access Type</th>
     <th scope="col">Monitor</th>
     <th scope="col">Edit</th>
   </tr>
 </thead>
 <tbody>
 
 
     
     
     
     
     

     
 
 
     
   <tr>
     <th scope="row">1</th>
     <td><?php echo $kullanicilar[1]; ?></td>
     <td><?php echo $erisim[1]; ?></td>
     <td>@mdo</td>
   </tr>
   <tr>
     <th scope="row">2</th>
     <td><?php echo $kullanicilar[1]; ?></td>
     <td>Thornton</td>
     <td>@fat</td>
   </tr>
   <tr>
     <th scope="row">3</th>
     <td><?php echo $kullanicilar[3]; ?></td>
     <td>the Bird</td>
     <td>@twitter</td>
   </tr>
 </tbody>
</table>
    <p>"gggggggg"</p>



</body>
</html>
ekran[url=dL3GJZ.png]ekran[/url]

Merhabalar,

Araştırarak bulabileceğiniz internette çok fazla örnek mevcut.

https://stackoverflow.com/questions/1790...-a-webpage
https://stackoverflow.com/questions/2693...trap-table
https://php.wekeepcoding.com/article/138...QL+content
http://www.howtobuildsoftware.com/index....-row-click
...
...
...
n



Kolay gelsin.
Amaç, bilginin de/aklın da zekat'ını vermek.
Cevapla
#3
(12-07-2019, Saat: 12:28)hi_selamlar Adlı Kullanıcıdan Alıntı:
(12-07-2019, Saat: 12:02)41linea41 Adlı Kullanıcıdan Alıntı: Merhaba
Delphi de yazdığımız aşağıdaki gibi bir kodu php de yazamadım.Yardımcı olur musunuz?
Tablodaki satır sayısını bir while yada for döngüsü içine almak istiyorum.
Yapmak istediğimin delphi karşılığı:

var
i:integer;
i:=0;

with qrUser do

begin

close;

open;

first;

while not eof do

begin

grid.cells[0,i]:=qruserkullanici.value;

...

....

...


i:=i+1;

next;

end;



end;

php tarafında şöyle yapıyorum. bu kodla bağlanıp veriyi cekiyorum.
<?php
    error_reporting($level = 1);    
    
    
        $username="AHMET";
        
        try{
        
        #open database
        $vt=new PDO("sqlite:ippdu.sqlite3");
        
        
        
        $select=$vt->query("SELECT * FROM USERS",PDO::FETCH_ASSOC);
        
        $num=1;
        foreach($select as $row){
            echo $row['ID']    ;    
            echo $row['KULLANICI'];
            echo $row['SIFRE']    ;
            echo $row['EMAIL']    ;
            echo $row['MONITOR']    ;
            echo $row['YONETICI']    ;
            echo $row['SIL']    ;
            $kullanici=$row['KULLANICI']."ddddd"    ;
            $sifre=$row['SIFRE'];
            $kullanicilar[$num]=$row['KULLANICI'];
            $erisim[$num]=$row['YONETICI'];
            $Monitor[$num]=$row['MONITOR'];
            
            $num=$num+1;
    
            }
        
            
    
    }catch(PDOException $e){
        echo $e -> getMessage();
    
    
    
    }        
        
    
    
?>
aldığım veriyi bootstrap tablosundaki satırlara eklemek istiyorum ama burada  n sayıda satır sayısı kullanmak için while yada for döngüsüne ihtiyacım var ama satır tag ları nasıl php for döngüsüne alabilirim.?

<!DOCTYPE html>
<html>
<head>


    <meta charset="utf-8" />

    <link href="css/bootstrap.css" rel="stylesheet" />

    <link href="css/bootstrap-theme.css" rel="stylesheet" />

<title></title>
</head>
<body>
    
    <script src="js/bootstrap.min.js"></script>
    <nav class="navbar navbar-expand-lg navbar-light bg-light">
 <a class="navbar-brand" href="#">Navbar</a>
 <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
   <span class="navbar-toggler-icon"></span>
 </button>

 <div class="collapse navbar-collapse" id="navbarSupportedContent">
   <ul class="navbar-nav mr-auto">
     <li class="nav-item active">
       <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
     </li>
     <li class="nav-item">
       <a class="nav-link" href="#">Link</a>
     </li>
     <li class="nav-item dropdown">
       <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
         Dropdown
       </a>
       <div class="dropdown-menu" aria-labelledby="navbarDropdown">
         <a class="dropdown-item" href="#">Action</a>
         <a class="dropdown-item" href="#">Another action</a>
         <div class="dropdown-divider"></div>
         <a class="dropdown-item" href="#">Something else here</a>
       </div>
     </li>
     <li class="nav-item">
       <a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
     </li>
   </ul>
   <form class="form-inline my-2 my-lg-0">
     <input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
     <button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
   </form>
 </div>
</nav>
    <table class="table table-striped table-dark">
 <thead>
   <tr>
     <th scope="col">#</th>
     <th scope="col">Users</th>
     <th scope="col">Access Type</th>
     <th scope="col">Monitor</th>
     <th scope="col">Edit</th>
   </tr>
 </thead>
 <tbody>
 
 
     
     
     
     
     

     
 
 
     
   <tr>
     <th scope="row">1</th>
     <td><?php echo $kullanicilar[1]; ?></td>
     <td><?php echo $erisim[1]; ?></td>
     <td>@mdo</td>
   </tr>
   <tr>
     <th scope="row">2</th>
     <td><?php echo $kullanicilar[1]; ?></td>
     <td>Thornton</td>
     <td>@fat</td>
   </tr>
   <tr>
     <th scope="row">3</th>
     <td><?php echo $kullanicilar[3]; ?></td>
     <td>the Bird</td>
     <td>@twitter</td>
   </tr>
 </tbody>
</table>
    <p>"gggggggg"</p>



</body>
</html>
ekran[url=dL3GJZ.png]ekran[/url]

Merhabalar,

Araştırarak bulabileceğiniz internette çok fazla örnek mevcut.

https://stackoverflow.com/questions/1790...-a-webpage
https://stackoverflow.com/questions/2693...trap-table
https://php.wekeepcoding.com/article/138...QL+content
http://www.howtobuildsoftware.com/index....-row-click
...
...
...
n



Kolay gelsin.
php bena zor geldi açıkcası 1 saat uğraştıktan sonra tırnak problemlerini de çözünce yapabildim.
ilginiz için teşekkürler.
PHP Kod: (Select All)
<?php
        error_reporting
($level 1);    
        
$username="AHMET";
        try{
        
#open database
        
$vt=new PDO("sqlite:ippdu.sqlite3");
                
        
$select=$vt->query("SELECT * FROM USERS",PDO::FETCH_ASSOC);
            
        
#foreach($select as $row) {
                 
  
             
       
#     echo $row["KULLANICI"];
 
       #         echo $row["YONETICI"]; 
 
           
             
            
            
#}
        
}catch(PDOException $e){
        echo 
$e -> getMessage(); 

        }                    
?> 

<!DOCTYPE html>
<html>
<head><body>
    <script src="js/bootstrap.min.js"></script>
    
<table class="table table-striped table-dark">
  <thead>
    <tr>
      <th scope="col">#</th>
      <th scope="col">Users</th>
      <th scope="col">Access Type</th>
      <th scope="col">Monitor</th>
      <th scope="col">Edit</th>
    </tr>
  </thead>
  <tbody>
          

        <?php foreach($select as $row) { ?>
                    <tr>
                      <th scope="row">2</th>
                      <td><?php echo $row["KULLANICI"]; ?></td>
                      <td><?php echo $row["YONETICI"]; ?></td>
                      <td><?php echo $row["MONITOR"]; ?></td>
                      <td>Edit</td>
                     </tr>
     
         <?php ?> 
    
  </tbody>


    
</body>
</html> 
Cevapla
#4
(12-07-2019, Saat: 18:22)41linea41 Adlı Kullanıcıdan Alıntı:
(12-07-2019, Saat: 12:28)hi_selamlar Adlı Kullanıcıdan Alıntı: Merhabalar,

Araştırarak bulabileceğiniz internette çok fazla örnek mevcut.

https://stackoverflow.com/questions/1790...-a-webpage
https://stackoverflow.com/questions/2693...trap-table
https://php.wekeepcoding.com/article/138...QL+content
http://www.howtobuildsoftware.com/index....-row-click
...
...
...
n



Kolay gelsin.
php bena zor geldi açıkcası 1 saat uğraştıktan sonra tırnak problemlerini de çözünce yapabildim.
ilginiz için teşekkürler.
PHP Kod: (Select All)
<?php
        error_reporting
($level 1);    
        
$username="AHMET";
        try{
        
#open database
        
$vt=new PDO("sqlite:ippdu.sqlite3");
                
        
$select=$vt->query("SELECT * FROM USERS",PDO::FETCH_ASSOC);
            
        
#foreach($select as $row) {
                 
  
             
       
#     echo $row["KULLANICI"];
 
       #         echo $row["YONETICI"]; 
 
           
             
            
            
#}
        
}catch(PDOException $e){
        echo 
$e -> getMessage(); 

        }                    
?> 

<!DOCTYPE html>
<html>
<head><body>
    <script src="js/bootstrap.min.js"></script>
    
<table class="table table-striped table-dark">
  <thead>
    <tr>
      <th scope="col">#</th>
      <th scope="col">Users</th>
      <th scope="col">Access Type</th>
      <th scope="col">Monitor</th>
      <th scope="col">Edit</th>
    </tr>
  </thead>
  <tbody>
          

        <?php foreach($select as $row) { ?>
                    <tr>
                      <th scope="row">2</th>
                      <td><?php echo $row["KULLANICI"]; ?></td>
                      <td><?php echo $row["YONETICI"]; ?></td>
                      <td><?php echo $row["MONITOR"]; ?></td>
                      <td>Edit</td>
                     </tr>
     
         <?php ?> 
    
  </tbody>


    
</body>
</html> 

Merhabalar,

Sorunu çözdüğünüze ve çözüm yolunu paylaştığınız için teşekkürler.

Kolay gelsin.
Amaç, bilginin de/aklın da zekat'ını vermek.
Cevapla


Konu ile Alakalı Benzer Konular
Konular Yazar Yorumlar Okunma Son Yorum
  UniDBGrid HTML OnClick m_ekici 15 3.438 16-02-2024, Saat: 10:31
Son Yorum: m_ekici
  TMS Web Core - JavaScript Kullanmak rmzgenius 2 1.015 23-11-2023, Saat: 13:20
Son Yorum: nehirnnn
  TMS Web Core - Kod tarafından HTML Etkileşimi Örneği rmzgenius 4 1.371 16-03-2022, Saat: 10:39
Son Yorum: rmzgenius
  html de kullanınal özel karakterler powerghost 9 3.002 27-04-2021, Saat: 00:32
Son Yorum: powerghost
  unigui mobil de butona ile css kodu ibrahim.aydin@perga.com.tr 6 3.850 11-09-2020, Saat: 12:06
Son Yorum: ibrahim.aydin@perga.com.tr



Konuyu Okuyanlar: 1 Ziyaretçi