darish Posted April 28, 2015 Share Posted April 28, 2015 [m]include "config.php";$id=$_GET['id'];$qry=mysql_query("select * from register where id='$id'");$count=mysql_num_rows($qry);while($get=mysql_fetch_array($qry)){$radio=$get['active'];?>Primeiro NomeUltimo NomeNumeroEmailCidadeEmpresaMorada Submit Its and EDITING PAGE. But the only thing its working = When I change the name on "Morada" ... it changes the name of "email" instead ... and thats the only thing that is working :S , maybe u can send me a code of update? :S Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted April 28, 2015 Share Posted April 28, 2015 Please not when posting code to wrap it within tags or click the <> button in the editor. But the only thing its working = When I change the name on "Morada" ... it changes the name of "email" instead The only thing I can suggest is to make sure you have used unique names for the Email and Morada form fields and that you are using the correct variables in the php code where it updates these fields. Quote Link to comment Share on other sites More sharing options...
darish Posted April 29, 2015 Author Share Posted April 29, 2015 (edited) <?php include "config.php"; $id=$_GET['id']; $qry=mysql_query("select * from register where id='$id'"); $count=mysql_num_rows($qry); while($get=mysql_fetch_array($qry)) {$radio=$get['active'];?> <tr> <th width="40%">Primeiro Nome</th> <th> <input type="text" name="email"class="form-control" placeholder="Introduz Nome" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="<?php echo $get['fname']; ?>" required> <script> function alpha(e) { var k; document.all ? k = e.keyCode : k = e.which; return ((k > 64 && k < 91) || (k > 96 && k < 123) || k == 8 || k == 32 || (k >= 48 && k <= 57)); } </script> </th></tr> <tr> <th width="40%">Ultimo Nome</th> <th> <input type="text" name="email"class="form-control" placeholder="Intrudos Apelido" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="<?php echo $get['lname']; ?>" required> <script> function alpha(e) { var k; document.all ? k = e.keyCode : k = e.which; return ((k > 64 && k < 91) || (k > 96 && k < 123) || k == 8 || k == 32 || (k >= 48 && k <= 57)); } </script> </th></tr> <tr> <th width="40%">Numero</th> <th> <input type="text" name="email"class="form-control" placeholder="Introduz Numero" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="<?php echo $get['mobile']; ?>" required> <script> function alpha(e) { var k; document.all ? k = e.keyCode : k = e.which; return ((k > 64 && k < 91) || (k > 96 && k < 123) || k == 8 || k == 32 || (k >= 48 && k <= 57)); } </script> </th></tr> <tr> <th width="40%">Email</th> <th> <input type="text" name="email"class="form-control" placeholder="Introduz Email" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="<?php echo $get['email']; ?>" required> <script> function alpha(e) { var k; document.all ? k = e.keyCode : k = e.which; return ((k > 64 && k < 91) || (k > 96 && k < 123) || k == 8 || k == 32 || (k >= 48 && k <= 57)); } </script> </th></tr> <tr> <th width="40%">Cidade</th> <th> <input type="text" name="email"class="form-control" placeholder="Introduz Cidade" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="<?php echo $get['city']; ?>" required> <script> function alpha(e) { var k; document.all ? k = e.keyCode : k = e.which; return ((k > 64 && k < 91) || (k > 96 && k < 123) || k == 8 || k == 32 || (k >= 48 && k <= 57)); } </script> </th></tr> <tr> <th width="40%">Empresa</th> <th> <input type="text" name="email"class="form-control" placeholder="Introduz Empresa" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="<?php echo $get['company']; ?>" required> <script> function alpha(e) { var k; document.all ? k = e.keyCode : k = e.which; return ((k > 64 && k < 91) || (k > 96 && k < 123) || k == 8 || k == 32 || (k >= 48 && k <= 57)); } </script> </th></tr> <tr> <th width="40%">Morada</th> <th> <input type="text" name="email"class="form-control" placeholder="Introduz Morada" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="<?php echo $get['address']; ?>" required> <script> function alpha(e) { var k; document.all ? k = e.keyCode : k = e.which; return ((k > 64 && k < 91) || (k > 96 && k < 123) || k == 8 || k == 32 || (k >= 48 && k <= 57)); } </script> </th></tr> I think this will be good now :S , so it only changes the last one -.- ("morada" in this case) and it changes email instead :/ Edited April 29, 2015 by darish Quote Link to comment Share on other sites More sharing options...
Solution Muddy_Funster Posted April 29, 2015 Solution Share Posted April 29, 2015 you shouldn't re-declare the same function multiple times. only declare it once at the start. I don't understand the following: it only changes the last one -.- ("morada" in this case) and it changes email instead email is the third one, not the last one. Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted April 29, 2015 Share Posted April 29, 2015 You have given all your input fields the same name of email <input type="text" name="email" ... All fields in a form must have a unique name. Quote Link to comment Share on other sites More sharing options...
darish Posted April 30, 2015 Author Share Posted April 30, 2015 So I changed name in all , to their real name :S, but still the same problem... u told me to re-declare the same function multiple times .. but I need to change something o.O I think... ? Quote Link to comment Share on other sites More sharing options...
Muddy_Funster Posted April 30, 2015 Share Posted April 30, 2015 (edited) I told you not to declare the function multiple times, declare it only once at the start of your page and then refference it mutiple times: function myFunct(){ ... } ... ...onClick = "myFunct()"... ... ...onChange = "myFunct()"... ... If you have made changes to your code please repost the new code with the current behaviour: What it doesn't do + What it does do + What it should do | and include a summary of your changes. help us to help you. Edited April 30, 2015 by Muddy_Funster Quote Link to comment Share on other sites More sharing options...
darish Posted April 30, 2015 Author Share Posted April 30, 2015 <tbody> <?php include "config.php"; $id=$_GET['id']; $qry=mysql_query("select * from register where id='$id'"); $count=mysql_num_rows($qry); while($get=mysql_fetch_array($qry)) {$radio=$get['active'];?> <tr> <th width="40%">Primeiro Nome</th> <th> <input type="text" name="fname"class="form-control" placeholder="Introduz Nome" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="<?php echo $get['fname']; ?>" required> <script> function alpha(e) { var k; document.all ? k = e.keyCode : k = e.which; return ((k > 64 && k < 91) || (k > 96 && k < 123) || k == 8 || k == 32 || (k >= 48 && k <= 57)); } </script> </th></tr> <tr> <th width="40%">Ultimo Nome</th> <th> <input type="text" name="lname"class="form-control" placeholder="Intrudos Apelido" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="<?php echo $get['lname']; ?>" required> <script> function alpha(e) { var k; document.all ? k = e.keyCode : k = e.which; return ((k > 64 && k < 91) || (k > 96 && k < 123) || k == 8 || k == 32 || (k >= 48 && k <= 57)); } </script> </th></tr> <tr> <th width="40%">Numero</th> <th> <input type="text" name="mobile"class="form-control" placeholder="Introduz Numero" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="<?php echo $get['mobile']; ?>" required> <script> function alpha(e) { var k; document.all ? k = e.keyCode : k = e.which; return ((k > 64 && k < 91) || (k > 96 && k < 123) || k == 8 || k == 32 || (k >= 48 && k <= 57)); } </script> </th></tr> <tr> <th width="40%">Email</th> <th> <input type="text" name="email"class="form-control" placeholder="Introduz Email" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="<?php echo $get['email']; ?>" required> <script> function alpha(e) { var k; document.all ? k = e.keyCode : k = e.which; return ((k > 64 && k < 91) || (k > 96 && k < 123) || k == 8 || k == 32 || (k >= 48 && k <= 57)); } </script> </th></tr> <tr> <th width="40%">Cidade</th> <th> <input type="text" name="city"class="form-control" placeholder="Introduz Cidade" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="<?php echo $get['city']; ?>" required> <script> function alpha(e) { var k; document.all ? k = e.keyCode : k = e.which; return ((k > 64 && k < 91) || (k > 96 && k < 123) || k == 8 || k == 32 || (k >= 48 && k <= 57)); } </script> </th></tr> <tr> <th width="40%">Empresa</th> <th> <input type="text" name="company"class="form-control" placeholder="Introduz Empresa" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="<?php echo $get['company']; ?>" required> <script> function alpha(e) { var k; document.all ? k = e.keyCode : k = e.which; return ((k > 64 && k < 91) || (k > 96 && k < 123) || k == 8 || k == 32 || (k >= 48 && k <= 57)); } </script> </th></tr> <tr> <th width="40%">Morada</th> <th> <input type="text" name="address"class="form-control" placeholder="Introduz Morada" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="<?php echo $get['address']; ?>" required> <script> function alpha(e) { var k; document.all ? k = e.keyCode : k = e.which; return ((k > 64 && k < 91) || (k > 96 && k < 123) || k == 8 || k == 32 || (k >= 48 && k <= 57)); } </script> </th></tr> <tr> <th>Activo/Suspendido</th> <td> Activo<input type='radio' name='radio' id='radio' value="1" <?php if ($radio=='1') echo "checked=checked"; ?>/> Suspendido<input type='radio' name='radio' id='radio' value="0" <?php if ($radio=='0') echo "checked=checked"; ?>/> <input type="hidden" name="id" value="<?php echo $_GET['id'];?>" /> <input type="hidden" value="Submit" name="submit" /> </td> </tr> </tbody> </table> <header class="panel-heading"><div align="center"><button type="submit" class="btn btn-primary">Editar</button></div></header></form> <?php } ?> what it doesnt do : It doesnt edit at all :S what it does do : it shows all the things from the data base, and it only edit the "email" , thats the only thing that it works o.O what should do : Edit all 7 things .. not only the email :S Quote Link to comment Share on other sites More sharing options...
Muddy_Funster Posted April 30, 2015 Share Posted April 30, 2015 you are still decalring the same function multiple times, move the function decleration out of the loop above the table code. and try changing your code to something more like to following (it's been a long time since I used mysql_ so it will probably need a bit of tweeking: <script> function alpha(e) { var k; document.all ? k = e.keyCode : k = e.which; return ((k > 64 && k < 91) || (k > 96 && k < 123) || k == 8 || k == 32 || (k >= 48 && k <= 57)); } </script> ... <tbody> <?php include "config.php"; $id=$_GET['id']; $qry=mysql_query("select * from register where id='$id'"); $count=mysql_num_rows($qry); $results = =mysql_fetch_assoc($qry); foreach($results as $row){ if($row['active'] == 1){ $ckeckboxes = "<td> Activo<input type='radio' name='radio' id='radio' value='1' checked='checked' />\n\r Suspendido<input type='radio' name='radio' id='radio' value='0' />"; } else{ $ckeckboxes = "<td> Activo<input type='radio' name='radio' id='radio' value='1' />\n\r Suspendido<input type='radio' name='radio' id='radio' value='0' checked='checked' />"; } $pageOut = <<<PAGEOUT <tr> <th width="40%">Primeiro Nome</th> <th><input type="text" name="fname" class="form-control" placeholder="Introduz Nome" onKeyPress="alpha(event)" style="text-transform:lowercase;" value="{$row['fname']}" required></th> </tr> <tr> <th width="40%">Ultimo Nome</th> <th><input type="text" name="lname" class="form-control" placeholder="Intrudos Apelido" onKeyPress="alpha(event)" style="text-transform:lowercase;" value="{$row['lname']}" required></th> </tr> <tr> <th width="40%">Numero</th> <th><input type="text" name="mobile" class="form-control" placeholder="Introduz Numero" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="{$row['mobile']}" required></th> </tr> <tr> <th width="40%">Email</th> <th><input type="text" name="email"class="form-control" placeholder="Introduz Email" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="{$row['email']}" required></th> </tr> <tr> <th width="40%">Cidade</th> <th><input type="text" name="city"class="form-control" placeholder="Introduz Cidade" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="{$row['city']}" required></th> </tr> <tr> <th width="40%">Empresa</th> <th><input type="text" name="company"class="form-control" placeholder="Introduz Empresa" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="{$row['company']}" required></th> </tr> <tr> <th width="40%">Morada</th> <th><input type="text" name="address"class="form-control" placeholder="Introduz Morada" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="{$row['address']}" required></th> </tr> <tr> <th>Activo/Suspendido</th> {$checkboxes} <input type="hidden" name="id" value="{$_GET['id']}" /> <input type="hidden" value="Submit" name="submit" /> </td> </tr> PAGEOUT; echo $output; } echo "</tbody> \n\r </table> \n\r <header class='panel-heading'><div align='center'><button type='submit' class='btn btn-primary'>Editar</button></div></header></form>" ?> Quote Link to comment Share on other sites More sharing options...
darish Posted May 6, 2015 Author Share Posted May 6, 2015 It doesnt work :S I apllied your code, and then boom , everything dissapear in main page... everything wont wrong :S can u help me via skype? or something? Quote Link to comment Share on other sites More sharing options...
Muddy_Funster Posted May 6, 2015 Share Posted May 6, 2015 meh, I echoed the wrong variable name, sorry: change echo $output; to echo $pageOut; Quote Link to comment Share on other sites More sharing options...
darish Posted May 6, 2015 Author Share Posted May 6, 2015 it only fixed one thing, not it doesnt appear 2 edit buttoms... but it still , everything dissapears :S Quote Link to comment Share on other sites More sharing options...
Muddy_Funster Posted May 6, 2015 Share Posted May 6, 2015 Right...I think I get what's going on here, give me a moment... Quote Link to comment Share on other sites More sharing options...
darish Posted May 6, 2015 Author Share Posted May 6, 2015 ok, thanks Quote Link to comment Share on other sites More sharing options...
Muddy_Funster Posted May 6, 2015 Share Posted May 6, 2015 (edited) right, I have this working with the test data included - by working I meen that it renders the table on screen and provides individual buttons for each from. <script> function alpha(e) { var k; document.all ? k = e.keyCode : k = e.which; return ((k > 64 && k < 91) || (k > 96 && k < 123) || k == 8 || k == 32 || (k >= 48 && k <= 57)); } </script> ... <table> <tbody> <?php //Your Database Connection Code: /* include "config.php"; $id=$_GET['id']; $qry=mysql_query("select * from register where id='$id'"); $count=mysql_num_rows($qry); $results = mysql_fetch_assoc($qry); */ //offline test dataset to map out variables into table elements $results = array( array( 'id'=>'1', 'active'=>'1', 'fname'=>'Adam', 'lname'=>'Zacharia', 'mobile'=>'0125555225', 'email'=>'adam@your.net', 'city'=>'New Heaven', 'company'=>'Angel Investment Inc', 'address'=>'123 wherever lane, 905668' ), array( 'id'=>'2', 'active'=>'0', 'fname'=>'Charles', 'lname'=>'Lindberg', 'mobile'=>'0168755225', 'email'=>'Chic@your.net', 'city'=>'Old Hampshire', 'company'=>'Global Avionics LTD', 'address'=>'456 nowhere place, 998768' ) ); // end of test data foreach($results as $key=>$row){ if($row['active'] == 1){ $checkboxes = "<td> Activo<input type='radio' name='radio{$row['id']}' id='radio{$row['id']}' value='1' checked='checked' />\n\r Suspendido<input type='radio' name='radio' id='radio' value='0' />"; } else{ $checkboxes = "<td> Activo<input type='radio' name='radio{$row['id']}' id='radio{$row['id']}' value='1' />\n\r Suspendido<input type='radio' name='radio' id='radio' value='0' checked='checked' />"; } $pageOut = <<<PAGEOUT <form method="POST" action='#'> <tr> <th width="40%">Primeiro Nome</th> <th><input type="text" name="fname" class="form-control" placeholder="Introduz Nome" onKeyPress="alpha(event)" style="text-transform:lowercase;" value="{$row['fname']}" required></th> </tr> <tr> <th width="40%">Ultimo Nome</th> <th><input type="text" name="lname" class="form-control" placeholder="Intrudos Apelido" onKeyPress="alpha(event)" style="text-transform:lowercase;" value="{$row['lname']}" required></th> </tr> <tr> <th width="40%">Numero</th> <th><input type="text" name="mobile" class="form-control" placeholder="Introduz Numero" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="{$row['mobile']}" required></th> </tr> <tr> <th width="40%">Email</th> <th><input type="text" name="email"class="form-control" placeholder="Introduz Email" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="{$row['email']}" required></th> </tr> <tr> <th width="40%">Cidade</th> <th><input type="text" name="city"class="form-control" placeholder="Introduz Cidade" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="{$row['city']}" required></th> </tr> <tr> <th width="40%">Empresa</th> <th><input type="text" name="company"class="form-control" placeholder="Introduz Empresa" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="{$row['company']}" required></th> </tr> <tr> <th width="40%">Morada</th> <th><input type="text" name="address"class="form-control" placeholder="Introduz Morada" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="{$row['address']}" required></th> </tr> <tr> <th>Activo/Suspendido</th> {$checkboxes} <input type="hidden" name="id" value="{$row['id']}" /> <input type="hidden" value="Submit" name="submit" /> </td> </tr> <tr> <td><header class='panel-heading'><div align='center'><button type='submit' class='btn btn-primary'>Editar</button></div></header></td><td></td> </tr> </form> PAGEOUT; echo $pageOut; } echo "</tbody> \n\r </table> \n\r " ?> see how that gets on. Edited May 6, 2015 by Muddy_Funster Quote Link to comment Share on other sites More sharing options...
darish Posted May 6, 2015 Author Share Posted May 6, 2015 well, now it appears everything, but looks like some css efects dissapear, all stayed to close and some more issues... and the same thing is appearing twice x) Quote Link to comment Share on other sites More sharing options...
darish Posted May 6, 2015 Author Share Posted May 6, 2015 oh , more issues , it doesnt work o.O it doesnt edit at all ... and it doesnt appear the right information :S , looks to me than this is a hard thing to do :/ Quote Link to comment Share on other sites More sharing options...
Muddy_Funster Posted May 6, 2015 Share Posted May 6, 2015 (edited) I can't help any with the CSS, since it's not in the included code, but paste this into the appropriate part of the code I gave you to see an example of how to catch the info from the form: ... // end of test data //sample catch form output: if(!isset($_POST['submit'])){ } else{ echo"<pre>"; print_r($_POST); echo "</pre>"; } //end sample form catch foreach($results as $key=>$row){ if($row['active'] == 1){ $checkboxes = "<td> Activo<input type='radio' name='radio{$row['id']}' id='radio{$row['id']}' value='1' checked='checked' />\n\r Suspendido<input type='radio' name='radio{$row['id']}' id='radio{$row['id']}' value='0' />"; } else{ $checkboxes = "<td> Activo<input type='radio' name='radio{$row['id']}' id='radio{$row['id']}' value='1' />\n\r Suspendido<input type='radio' name='radio{$row['id']}' id='radio{$row['id']}' value='0' checked='checked' />"; } ... Edited May 6, 2015 by Muddy_Funster Quote Link to comment Share on other sites More sharing options...
darish Posted May 7, 2015 Author Share Posted May 7, 2015 well, I tried a lot of things, still error, can u help me via chat? if u are going to help me from here, it will take to much time :S I just want edit page, nothing more xD Quote Link to comment Share on other sites More sharing options...
Muddy_Funster Posted May 7, 2015 Share Posted May 7, 2015 I can't commit to a prolonged conversation, but if you link me (either here or in a PM) to a download for your actual code pages I'll try and fix it for you (include any database interactions, but not actual credentials) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.