コード例 #1
0
function ligneConGroupe($wh = '', $ord = '', $sens = 'ASC', $page = 1, $nelt)
{
    $returnHTML = '';
    $returnTble = array();
    //HTML, nbreTotal,
    //Where clause
    $where = '';
    isset($wh) and $wh != '' ? $where = " WHERE {$wh} " : ($where = "");
    //Oerder condition
    $order = '';
    isset($ord) and $ord != '' ? $order = " ORDER BY {$ord} {$sens}" : ($order = " ORDER BY ID_GROUPE  ASC");
    //Nombre d'éléments
    $returnTble['NE'] = nombreGroupe($where);
    if ($returnTble['NE'] > 0) {
        //Calcule des limites
        $i = ($page - 1) * $nelt;
        $sql = "SELECT * FROM groupe {$where} {$order} LIMIT {$i}, {$nelt};";
        //Exécution
        try {
            $cnx = new PDO(DBD, DBUSER, DBPWD, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
            //Connexion to database
        } catch (PDOException $error) {
            //Treat error
            //("Erreur de connexion : " . $error->getMessage() );
            header('location:errorPage.php');
        }
        $query = $cnx->prepare($sql);
        //Prepare the SQL
        $query->execute();
        //Execute prepared SQL => $query
        $i = 0;
        $j = 6;
        while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
            $i % 2 == 0 ? $col = "tableOddRow" : ($col = "tableEvenRow");
            $returnHTML .= '
			<tr align="left" valign="middle" class="' . $col . '">
	            <td><input type="checkbox" name="rowSelection[]" value="' . $row['ID_GROUPE'] . '" onClick="go(' . $row['ID_GROUPE'] . ',' . $j . ');"></td>
                <td class="text" >' . stripslashes($row['GRPE_LIBELLE']) . '</td>
				<td class="text" align="center"></td>
				<td class="text" align="center"></td>
				<td class="text" align="center"></td>
				<td class="text" align="center"></td>
            </tr>';
            $i++;
            $j++;
        }
    } else {
        if ($ilang == '1' && $ilang != '') {
            $returnHTML .= '<tr><td colspan="4" class="text">Aucune donn&eacute;e...</td></tr>';
        }
        if ($ilang == '2' && $ilang != '') {
            $returnHTML .= '<tr><td colspan="4" class="text">No data...</td></tr>';
        }
        if ($ilang == '3' && $ilang != '') {
            $returnHTML .= '<tr><td colspan="4" class="text">Nenhum dado...</td></tr>';
        }
    }
    $returnTble['L'] = $returnHTML;
    return $returnTble;
}
コード例 #2
0
function ligneEtatListeGroupe($wh = '')
{
    $userName = getField('LOGIN', $_SESSION['GL_USER']['LOGIN'], 'LOGIN', 'compte');
    $ilang = getCodelangue($userName);
    $returnHTML = '';
    $returnTble = array();
    //HTML, nbreTotal,
    //Where clause
    $where = '';
    isset($wh) and $wh != '' ? $where = " WHERE {$wh} " : ($where = "");
    //Oerder condition
    $order = '';
    isset($ord) and $ord != '' ? $order = " ORDER BY {$ord} {$sens}" : ($order = " ORDER BY ID_GROUPE  ASC");
    //Nombre d'éléments
    $nbre = nombreGroupe($where);
    if ($nbre > 0) {
        //Calcule des limites
        $sql = "SELECT * FROM groupe {$where} {$order};";
        //Exécution
        try {
            $cnx = new PDO(DBD, DBUSER, DBPWD, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
            //Connexion to database
        } catch (PDOException $error) {
            //Treat error
            //("Erreur de connexion : " . $error->getMessage() );
            header('location:errorPage.php');
        }
        $query = $cnx->prepare($sql);
        //Prepare the SQL
        $query->execute();
        //Execute prepared SQL => $query
        $i = 1;
        while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
            $i % 2 == 0 ? $col = "tableOddRow" : ($col = "tableEvenRow");
            $returnHTML .= '
			<tr align="left" valign="middle" class="' . $col . '">
	            <td class="botBorderTdall" align="center">' . $i . '</td>
                <td class="botBorderTdall" >' . stripslashes($row['GRPE_LIBELLE']) . '</td>
           </tr>';
            $i++;
        }
    } else {
        if ($ilang == '1' && $ilang != '') {
            $returnHTML .= '<tr><td colspan="4" class="text">Aucune donn&eacute;e...</td></tr>';
        }
        if ($ilang == '2' && $ilang != '') {
            $returnHTML .= '<tr><td colspan="4" class="text">No data...</td></tr>';
        }
        if ($ilang == '3' && $ilang != '') {
            $returnHTML .= '<tr><td colspan="4" class="text">Nenhum dado...</td></tr>';
        }
    }
    return $returnHTML;
}