appeler une fonction php dans une fonction javaScript
j'ai un code php qui affiche les résultat de recherche dans un tableaux ce que je veux faire c'est de limiter la taille du ligne du tableau a 10 et si j'ai 40 enregistrement j'aurai 4 tableau a afficher comme solution j'ai organisé ça dans un select "1 pour dire enregistrement de 1 a 11, 2 dire enregistrement de 12 a 23 ....." le problème comment je vais changer l'affichage du tableau lorsque je clique par exemple sur 2 dans le select
je vois comme solution d'appeler une fonction php avec un paramètre qui vas être le début d'affichage "11, 23...." mais j'arrive pas a faire ça ?!!!!
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
| <?php
if (isset( $_POST['title'] ) && !(empty($_POST['title'])) ){
$serveurBD = "localhost";
$nomUtilisateur = "root";
$motDePasse = "";
$baseDeDonnees = "antiqutebdd";
@mysql_connect($serveurBD,$nomUtilisateur, $motDePasse)
or die("Impossible de se connecter au serveur de bases de données.");
@mysql_select_db($baseDeDonnees) or die("Cette base de donnees n'existe pas");
$query = mysql_query('SELECT COUNT(*) FROM projet WHERE titre_projet = "' . mysql_real_escape_string($_POST['title']). '" ');
$count = mysql_result($query,0,0);
if ($count == 0) echo " aucun resultat trouver";
else{
$sql=mysql_query('select * from projet WHERE titre_projet = "' . mysql_real_escape_string($_POST['title']). '"');
echo ("<div class='table'>");
echo ("<table class='listing' cellpadding='0' cellspacing='0'>");
echo ("<tr>");
echo ("<th width='16%' >titre du projet</th>");
echo ("<th width='20%' >description</th>");
echo ("<th width='20%' >commentaire</th>");
echo ("<th width='15%' >modifier le projet</th>");
echo ("<th width='15%' >ajouter un texte</th>");
echo ("<th width='15%' >supprimer le projet</th>");
echo ("</tr>");
while($data=mysql_fetch_array($sql)){
echo ("<tr >");
echo ("<td > $data[2] </td>");
echo ("<td > $data[3] </td>");
echo ("<td > $data[4] </td>");
echo("<td><a href='modifierProjet.php?id=$data[0]' ><img src='images/edit-icon.gif' width='16' height='16' alt='' /></a></td> ");
echo("<td><a ><img src='images/add-icon.gif' width='16' height='16' alt='' /></a></td> ");
echo("<td><a onclick=confirmSubmit('supprimerProjet.php?id=$data[0]') href='#' ><img src='images/hr.gif' width='16' height='16' alt='' /></a></td> ");
echo ("</tr>");
}
echo ("</table>");
echo ("<div class='select'>");
echo ("<strong>Autres Pages: </strong>");
echo ("<select>");
echo ("<option>1</option>");
echo ("</select>");
echo ("</div>");
echo ("</div>");
}
mysql_close();
} elseif ( /*empty($_POST['title']) && */ isset( $_POST['titlehidden'] ) ){
function page1(arg){
$serveurBD = "localhost";
$nomUtilisateur = "root";
$motDePasse = "";
$baseDeDonnees = "antiqutebdd";
@mysql_connect($serveurBD,$nomUtilisateur, $motDePasse)
or die("Impossible de se connecter au serveur de bases de données.");
@mysql_select_db($baseDeDonnees) or die("Cette base de donnees n'existe pas");
$query = mysql_query('SELECT COUNT(*) AS num FROM projet ');
$count = mysql_result($query,0,0);
if ($count == 0) echo " aucun resultat trouver";
else{
$result1=mysql_result($query,0);
$result2 = (int)($result1/10);
$result3 = $result1%10;
if($result3 !=0){
$result2=$result2+1;
}
$result4=$result1;
$sql=mysql_query('select * from projet limit 10,10');
echo ("<div class='table'>");
echo ("<table class='listing' cellpadding='0' cellspacing='0'>");
echo ("<tr>");
echo ("<th width='16%' >titre du projet</th>");
echo ("<th width='20%' >description</th>");
echo ("<th width='20%' >commentaire</th>");
echo ("<th width='15%' >modifier le projet</th>");
echo ("<th width='15%' >ajouter un texte</th>");
echo ("<th width='15%' >supprimer le projet</th>");
echo ("</tr>");
while($data=mysql_fetch_array($sql)){
echo ("<tr >");
echo ("<td > $data[2] </td>");
echo ("<td > $data[3] </td>");
echo ("<td > $data[4] </td>");
echo("<td><a href='modifierProjet.php?id=$data[0]' ><img src='images/edit-icon.gif' width='16' height='16' alt='' /></a></td> ");
echo("<td><a ><img src='images/add-icon.gif' width='16' height='16' alt='' /></a></td> ");
echo("<td><a onclick=confirmSubmit('supprimerProjet.php?id=$data[0]') href='#' ><img src='images/hr.gif' width='16' height='16' alt='' /></a></td> ");
echo ("</tr>");
}
echo ("</table>");
echo ("<div class='select'>");
echo ("<strong>Autres Pages: </strong>");
echo ("<select name='numPage' id='numPage' onchange=change_page(this) >");
while($result2>0){
echo ("<option value=$result2 >".$result2."</option>");
$result2 = $result2 - 1;
}
echo ("</select>");
echo ("</div>");
echo ("</div>");
}
mysql_close();
}
}
?> |
mon code javascript
Code:
1 2 3 4 5
| function change_page(seldd) {
// si le select egale a 1 donc page1(1)
// si le select egale a 2 donc page1(11)
// si le select egale a 3 donc page1(23)
} |
pour le début j'ai une fonction seulement sur la deuxième partie du mon code php
merci d'avance