示例#1
0
function listingAdherents($filename)
{
    $output = "";
    $rows = file($filename);
    // resultat sous forme de tableau indéxé
    foreach ($rows as $rows) {
        $elements = explode(";", $rows);
        // subdivise la chaine de caractere en plusieurs élémentsstocké dans un tb indx
        if (count($elements) === 7) {
            $output .= "<tr>\n                      <td>" . $elements[1] . "</td>\n                      <td>" . $elements[2] . "</td>\n                      <td>" . $elements[3] . "</td>\n                      <td>" . calculAge($elements[4]) . "</td>\n                      <td>" . $elements[5] . "</td>\n                      <td>" . $elements[6] . "</td>\n                      <tr>";
        }
    }
    return $output;
}
示例#2
0
function listingAdherents($conn)
{
    $query = "SELECT * FROM adherents order by date_naissance ASC";
    // requete de type select sur la table adhrents
    $statement = $conn->query($query);
    $output = "";
    foreach ($statement as $row) {
        $output .= "<tr>";
        // boucle d'affichage des résultats ligne par ligne
        $output .= "<td>" . $row['civilite'] . "</td>";
        // utf8_encode fonction native permet l'affichage en
        $output .= "<td>" . utf8_encode($row['nom']) . "</td>";
        // utf8_encode fonction native permet l'affichage en
        $output .= "<td>" . utf8_encode($row['prenom']) . "</td>";
        // utf8_encode fonction native permet l'affichage en
        $output .= "<td>" . $row['email'] . "</td>";
        $output .= "<td>" . calculAge($row['date_naissance']) . "</td>";
        $output .= "<td>\n                <ul>\n                <li><a href='adherent.php?action=voir&id=" . $row['id_adherent'] . "'>Voir</a></li>\n                <li><a href='adherent.php?action=modifier&id=" . $row['id_adherent'] . "'>Modifier</a></li>\n                <li><a href='#' onclick='redirectMe(" . $row['id_adherent'] . ");'>Supprimer</a></li>";
        $output .= "</ul>\n                </td>";
        $output .= "</tr>";
    }
    return $output;
}