Précédent   Forum des professionnels en informatique > PHP > PHP & SGBD > PHP & MySQL
PHP & MySQL Forum d'entraide sur les fonctions MySQL avec PHP. Avant de poster -> FAQ MySQL, Cours MySQL et Sources MySQL. Pour les questions concernant le moteur MySQL plutôt que les fonctions PHP, merci d'utiliser le forum MySQL.
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 13/08/2011, 17h17   #1
Candidat au titre de Membre du Club
 
David Taylor
Inscription : mai 2010
Messages : 69
Détails du profil
Informations personnelles :
Nom : David Taylor

Informations forums :
Inscription : mai 2010
Messages : 69
Points : 12
Points : 12
Par défaut Fenêtre parent enfant en php / js

Bonjour,

Voici mon problème:
Je fais une mise à jour d'une donnée venant de la database.
Update sans problème mais quand la page parent se recharge, elle ne m'affiche pas tout le temps la modification effectuée

Pouvez-vous m'aider en fonction du code que vous trouverez ci-dessous?

Merci d'avance
David
Code page parent:
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
 
<script type="text/javascript"> 
<!-- 
function popup_category(page,largeur,hauteur,options) 
{ 
    var top=(screen.height-hauteur)/2; 
    var left=(screen.width-largeur)/2;
    window.open(page,"","top="+top+",left="+left+",width="+largeur+",height="+hauteur+","+options); 
} 
 
--> 
</script>
	<div id="tablewrapper">
		<div id="tableheader">
        	<div class="search">
                <select id="columns" onchange="sorter.search('query')"></select>
                <input type="text" id="query" onkeyup="sorter.search('query')" />
            </div>
            <span class="details">
				<div>Records <span id="startrecord"></span>-<span id="endrecord"></span> of <span id="totalrecords"></span></div>
        		<div><a href="javascript:sorter.reset()">reset</a></div>
        	</span>
        </div>
        <table cellpadding="0" cellspacing="0" border="0" id="table" class="tinytable">
            <thead>
                <tr>
                    <th class="nosort"><h3>ID</h3></th>
                    <th><h3>Name Category</h3></th>
                    <th><h3>Category Free</h3></th>
                    <th><h3>Amount</h3></th>
                    <th class="nosort"><h3></h3></th>
                    <th class="nosort"><h3></h3></th>
                </tr>
            </thead>
            <tbody>
			<?php 
			$sql = "SELECT * FROM category_parent;";
 
			$result = mysql_query($sql);
 
			while($row = mysql_fetch_array($result)){
				echo "<tr>\n";
				echo "<td>".$row["cp_id_category_parent"]."</td>\n";
				echo "<td><a href=\"".htmlentities("?section=manage_category_child&id=".$row["cp_id_category_parent"]."")."\">".$row["cp_name_category"]."</a></td>\n";
				if($row["cp_free"] == 0){
					echo "<td>No</td>\n";
				}else{
					echo "<td>Yes</td>\n";
				}
				echo "<td>".$row["cp_amount"]."</td>\n";
				if($row["cp_active"] == 1){
					echo "<td><a href=\"".htmlentities("?section=active_category&id=".$row["cp_id_category_parent"]."")."\"><img src=\"css/img/yes.png\" width=\"16\" height=\"16\" title=\"Active: Yes\" alt=\"Yes\" /></a></td>\n";
				}else{
					echo "<td><a href=\"".htmlentities("?section=active_category&id=".$row["cp_id_category_parent"]."")."\"><img src=\"css/img/delete.png\" width=\"16\" height=\"16\" title=\"Active: No\" alt=\"No\" /></a></td>\n";
				}
				?>
				<td><a name="tagada" href='javascript:popup_category("<?php echo htmlentities("?section=edit_category&id=".$row["cp_id_category_parent"]."");?>",500,500,"location=no,resizable=no,menubar=no,scrollbars=no,statusbar=no")'><img src="css/img/edit.png" width="16" height="16" title="Edit the category" alt="edit" /></a></td>
				<?
				//echo "<td><a href=\"".htmlentities("?section=edit_category&id=".$row["cp_id_category_parent"]."")."\"><img src=\"css/img/edit.png\" width=\"16\" height=\"16\" title=\"Edit the category\" alt=\"edit\" /></a></td>\n";
				echo "</tr>\n";
			}
			?>
            </tbody>
        </table>
        <table cellpadding="0" cellspacing="0" border="0" class="tinytable">
          <tbody>			
          </tbody>
        </table>
        <div id="tablefooter">
      <div id="tablenav">
            	<div>
                    <img src="css/img/first.gif" width="16" height="16" alt="First Page" onclick="sorter.move(-1,true)" />
                    <img src="css/img/previous.gif" width="16" height="16" alt="First Page" onclick="sorter.move(-1)" />
                    <img src="css/img/next.gif" width="16" height="16" alt="First Page" onclick="sorter.move(1)" />
                    <img src="css/img/last.gif" width="16" height="16" alt="Last Page" onclick="sorter.move(1,true)" />
                </div>
                <div>
                	<select id="pagedropdown"></select>
				</div>
                <div>
                	<a href="javascript:sorter.showall()">view all</a>
                </div>
            </div>
			<div id="tablelocation">
            	<div>
                    <select onchange="sorter.size(this.value)">
                    <option value="5">5</option>
                        <option value="10" selected="selected">10</option>
                        <option value="20">20</option>
                        <option value="50">50</option>
                        <option value="100">100</option>
                    </select>
                    <span>Entries Per Page</span>
                </div>
                <div class="page">Page <span id="currentpage"></span> of <span id="totalpages"></span></div>
            </div>
        </div>
    </div>
	<script type="text/javascript">
	var sorter = new TINY.table.sorter('sorter','table',{
		headclass:'head',
		ascclass:'asc',
		descclass:'desc',
		evenclass:'evenrow',
		oddclass:'oddrow',
		evenselclass:'evenselected',
		oddselclass:'oddselected',
		paginate:true,
		size:10,
		colddid:'columns',
		currentid:'currentpage',
		totalid:'totalpages',
		startingrecid:'startrecord',
		endingrecid:'endrecord',
		totalrecid:'totalrecords',
		hoverid:'selectedrow',
		pageddid:'pagedropdown',
		navid:'tablenav',
		sortcolumn:1,
		sortdir:1,
		//sum:[8],
		//avg:[6,7,8,9],
		columns:[{index:7, format:'%', decimals:1},{index:8, format:'$', decimals:0}],
		init:true
	});
  </script>
Code Page popup (enfant) :

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
 
<?php 
$sql = "SELECT cp_id_category_parent,cp_name_category FROM category_parent
		WHERE cp_id_category_parent='".$_GET["id"]."';";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);		
 
if(isset($_POST["button"])){
	$error = "";
	$id_category = $_POST["id_category"];
	$category_parent = $_POST["category_parent"];
	if(empty($_POST["category_parent"])){
		$error .= "<p class\"message\">The fiels Category Parent is empty.</p>";
	}
	if($error == 0){
		$sql = "UPDATE category_parent SET cp_name_category='".$category_parent."'
				WHERE cp_id_category_parent='".$id_category."';";
		$result = mysql_query($sql);		
	}
	if($result){
		echo "<script language=\"javascript\" type=\"text/javascript\"> setTimeout(\"window.close()\", 2000); </script>";
	}	
}
?>
<!--<script language="JavaScript" type="text/javascript">-->
<script type="text/javascript">
function refresh(){
/*window.opener.location.href="?section=manage_category";*/
window.opener.location = window.opener.location;
}
</script>
<?php 
if($error != ""){
	echo $error;
}
?>
<form name="edit_category" action="?section=edit_category" method="post" >
	<h1>Modifify this Category : <?php echo $row["cp_name_category"];?></h1>
	<p>Name of the Parent Category :</p>
	<input name="id_category" type="hidden" value="<?php echo $row['cp_id_category_parent'];?>"/>
	<input type="text" name="category_parent" value="<?php echo $row["cp_name_category"];?>" />
	<input type="submit" name="button" value="Update" onclick="refresh()" />
</form>
soksabaidee est déconnecté   Envoyer un message privé Réponse avec citation 01
Vieux 13/08/2011, 17h26   #2
Rédacteur
 
Avatar de jreaux62
 
Homme Jérôme Réaux
Webdesigner
Inscription : août 2008
Messages : 2 993
Détails du profil
Informations personnelles :
Nom : Homme Jérôme Réaux
Âge : 45
Localisation : France, Pas de Calais (Nord Pas de Calais)

Informations professionnelles :
Activité : Webdesigner
Secteur : Arts - Culture

Informations forums :
Inscription : août 2008
Messages : 2 993
Points : 5 786
Points : 5 786
Envoyer un message via Skype™ à jreaux62
Bonjour,
vu qu'il n'y a aucun commentaire dans ton code, et que tu es plutôt avare d'explications,
... tu attends quoi exactement ?

Ne serait-ce pas :
Code :
1
2
3
4
5
<script type="text/javascript">
function refresh(){
	window.parent.reload();
}
</script>
__________________
"Ce qui se conçoit bien s'énonce clairement - Et les mots pour le dire arrivent aisément."
Nicolas Boileau-Despréaux, Homme de lettres français (1636-1711), principal théoricien de l'esthétique classique.
Site perso Mes tutos DVP : Gestion-Affichage de Nouvelles - Affichage en tableau HTML - Fonctions de redimensionnement d'images
jreaux62 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 13/08/2011, 23h02   #3
Membre confirmé
 
Inscription : juillet 2011
Messages : 146
Détails du profil
Informations personnelles :
Localisation : France

Informations forums :
Inscription : juillet 2011
Messages : 146
Points : 253
Points : 253
En fait c'est tout bête

Tu fait ton select avant de vérifier si tu doit updater tes datas.

Donc forcement les données affichées post update ne sont plus les bonnes

Met juste ton select après ton update et tout ira mieux
Tolriq est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 16/08/2011, 05h27   #4
Candidat au titre de Membre du Club
 
David Taylor
Inscription : mai 2010
Messages : 69
Détails du profil
Informations personnelles :
Nom : David Taylor

Informations forums :
Inscription : mai 2010
Messages : 69
Points : 12
Points : 12
Voici la solution afin de ben recharger les données:

Code :
1
2
 
echo "<body onunload=\"self.opener.location.reload();\">\n";
Merci encore ;-)
soksabaidee est déconnecté   Envoyer un message privé Réponse avec citation 01
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 15h48.


 
 
 
 
Partenaires

Hébergement Web