Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在HTML表中使用Oci_fetch_数组显示数据_Php - Fatal编程技术网

Php 在HTML表中使用Oci_fetch_数组显示数据

Php 在HTML表中使用Oci_fetch_数组显示数据,php,Php,我试图使用OCi_FETCH_数组函数将打印数据放入html表中,因为我使用的是Oracle。我在这里要做的是显示数据库中的信息,如果有数据,否则我会按按钮添加日期显示。 这是我正在使用的php代码: <?php for ($i=1; $i<=4;$i++) { $stid = oci_parse($conn, 'SELECT * from SEANCE'); oci_execute($sti

我试图使用OCi_FETCH_数组函数将打印数据放入html表中,因为我使用的是Oracle。我在这里要做的是显示数据库中的信息,如果有数据,否则我会按按钮添加日期显示。 这是我正在使用的php代码:

    <?php 

    for ($i=1; $i<=4;$i++)
    {
                $stid = oci_parse($conn, 'SELECT * from SEANCE');
                oci_execute($stid);
                $row = oci_fetch_array($stid,OCI_BOTH);
        echo "<tr><td></td>";        
        for ($j=1; $j<=5;$j++)
            {
            //echo "".$row['DATES']."-".$row['HEURE']."/";
            if($row['ETAT']==1 && $row['DATES']==$j && $row['HEURE']==$i)
               {
                    echo '<td><b>'.$row['ID_INSTRUCTEUR'].'</b><br><i>'.$row['ID_MODULE'].'</i><br>Salle : '.$row['ID_SALLE'].'</td>';
               }
            else
               {
                echo "<td><button class='btn red-bg'  onclick=asd(2,".$j.",".$i.")>Ajouter </button></td>";
               } 
            }
        echo "<tr>";
}
oci_free_statement($stid);
oci_close($conn);
    ?>

我通过以下方式将数据保存到另一个数组来解决此问题:

    <?php 
$array=array(1=>"08:00-9:30",2=>"10:00-11:30",3=>"12:00-13:30",4=>"15:00-16:30");
    $stid = oci_parse($conn, 'SELECT count(IDSEANCE) from SEANCE');
    oci_execute($stid);
    $row = oci_fetch_array($stid,OCI_BOTH);
    //echo $row[0];
    //Verifie rows
    if( $row[0] == 0){
        for ($i=1; $i<=4;$i++)
    {
            echo "<tr><td><b>".$array[$i]."</b></td>"; 

            for ($j=1; $j<=5;$j++){
              echo "<td><button class='btn red-bg'  onclick=asd(2,".$j.",".$i.")>Ajouter </button></td>";
                }
            }
            echo "<tr>";
    } else
    {
    //Problem avec la boucle For.
    $array2=array();
    $stid = oci_parse($conn, 'SELECT * from SEANCE where ID_PROGRAMME=' . intval($_GET['idss']) . '');
    oci_execute($stid);
    while($row = oci_fetch_array($stid,OCI_BOTH))
    {   
    $array2[$row[5]][$row[4]]="<td><b>".$row['ID_INSTRUCTEUR']."</b><br><i>".$row['ID_MODULE']."</i><br>Salle : ".$row['ID_SALLE']."<button style='background-color:#8DCB79;color:#ffffff;border: 1px solid transparent;float:right;' onclick=asd(2,".$row[4].",".$row[5].")>Modifie </button></td>";
    }
    for ($i=1; $i<=4;$i++)
    {

            echo "<tr><td><b>".$array[$i]."</b></td>"; 

            for ($j=1; $j<=5;$j++)
            {

                if(empty($array2[$i][$j])){
                    $array2[$i][$j] = "<td><button class='btn red-bg'  onclick=asd(2,".$j.",".$i.")>Ajouter </button></td>";

                } 
                echo($array2[$i][$j]);
            }
            echo "<tr>";
    }
    }
oci_free_statement($stid);
oci_close($conn);
?>

我通过以下方式将数据保存到另一个数组来解决此问题:

    <?php 
$array=array(1=>"08:00-9:30",2=>"10:00-11:30",3=>"12:00-13:30",4=>"15:00-16:30");
    $stid = oci_parse($conn, 'SELECT count(IDSEANCE) from SEANCE');
    oci_execute($stid);
    $row = oci_fetch_array($stid,OCI_BOTH);
    //echo $row[0];
    //Verifie rows
    if( $row[0] == 0){
        for ($i=1; $i<=4;$i++)
    {
            echo "<tr><td><b>".$array[$i]."</b></td>"; 

            for ($j=1; $j<=5;$j++){
              echo "<td><button class='btn red-bg'  onclick=asd(2,".$j.",".$i.")>Ajouter </button></td>";
                }
            }
            echo "<tr>";
    } else
    {
    //Problem avec la boucle For.
    $array2=array();
    $stid = oci_parse($conn, 'SELECT * from SEANCE where ID_PROGRAMME=' . intval($_GET['idss']) . '');
    oci_execute($stid);
    while($row = oci_fetch_array($stid,OCI_BOTH))
    {   
    $array2[$row[5]][$row[4]]="<td><b>".$row['ID_INSTRUCTEUR']."</b><br><i>".$row['ID_MODULE']."</i><br>Salle : ".$row['ID_SALLE']."<button style='background-color:#8DCB79;color:#ffffff;border: 1px solid transparent;float:right;' onclick=asd(2,".$row[4].",".$row[5].")>Modifie </button></td>";
    }
    for ($i=1; $i<=4;$i++)
    {

            echo "<tr><td><b>".$array[$i]."</b></td>"; 

            for ($j=1; $j<=5;$j++)
            {

                if(empty($array2[$i][$j])){
                    $array2[$i][$j] = "<td><button class='btn red-bg'  onclick=asd(2,".$j.",".$i.")>Ajouter </button></td>";

                } 
                echo($array2[$i][$j]);
            }
            echo "<tr>";
    }
    }
oci_free_statement($stid);
oci_close($conn);
?>