saradrungta Posted January 4, 2009 Share Posted January 4, 2009 hello friends, i m designing a form i which i want to insert a edit button. and pass some value with it like 'UID' <input type="submit" name="edit" value="<?php echo $rows['UID']; ?>"> can some one help me..... thanks in advance. Quote Link to comment Share on other sites More sharing options...
Clinton Posted January 4, 2009 Share Posted January 4, 2009 What exactly is the question here? What are you trying to do? Quote Link to comment Share on other sites More sharing options...
gevans Posted January 4, 2009 Share Posted January 4, 2009 <input type="hidden" name="uid" value="hidden" /> send that above the button Quote Link to comment Share on other sites More sharing options...
saradrungta Posted January 4, 2009 Author Share Posted January 4, 2009 actually i m displaying all the records in my DB, and want to allow user to see and edit any data which he wish to edit. but the code i mentioned, it display the UID on BUTTON, instead i want that it should display EDIT on button and pass UID in $_POST['edit'] pls help Quote Link to comment Share on other sites More sharing options...
gevans Posted January 4, 2009 Share Posted January 4, 2009 <input type="hidden" name="uid" value="hidden" /> send that above the button thats what i did, that will pass the uid in a hidden field, and you can call your button edit Quote Link to comment Share on other sites More sharing options...
Clinton Posted January 4, 2009 Share Posted January 4, 2009 No, gevans, you're hiding the button. He wants: <form> <input type="hidden" name="uid" value="<?php echo $rows['UID']; ?>" /> <input type="submit" name="edit" value="EDIT"> Then on the next form you justget $_POST['uid'] and go from there. Quote Link to comment Share on other sites More sharing options...
gevans Posted January 4, 2009 Share Posted January 4, 2009 No, I was hidding the input, the button is just a button Quote Link to comment Share on other sites More sharing options...
Clinton Posted January 4, 2009 Share Posted January 4, 2009 You're right, my apologies. Quote Link to comment Share on other sites More sharing options...
saradrungta Posted January 4, 2009 Author Share Posted January 4, 2009 thanks for ur advise, but i m still facing a problem When i display all records with ur code it stores the last UID of my records in all the EDIT button.... Quote Link to comment Share on other sites More sharing options...
Clinton Posted January 4, 2009 Share Posted January 4, 2009 Can you show us your code? Quote Link to comment Share on other sites More sharing options...
saradrungta Posted January 4, 2009 Author Share Posted January 4, 2009 <?php // Connect to server and select databse. mysql_connect("localhost","root","")or die("cannot connect"); mysql_select_db("sarad")or die("cannot select DB"); //Display all the Records// $sql="SELECT * FROM studentrec"; $result=mysql_query($sql); mysql_num_rows($result); ?> <form method="post" action="adelete.php"> <table width="100%" border="1" cellpadding="3" cellspacing="1"> <tr> <th colspan="5" align="center">Delete multiple rows in mysql</th> </tr> <tr> <th>DELETE</th> <th>Edit</th> <th>Id</th> <th>Name</th> <th>Age</th> <th>City</th> </tr> <?php while($rows=mysql_fetch_array($result)){ ?> <tr> <td><input type="checkbox" name= "delid[]" value="<?php echo $rows['UID']; ?>"></td> <td><input type="hidden" name="uid" value="<?php echo $rows['UID']; ?>" /> <input type="submit" name="edit" value="EDIT"></td> <td><?php echo $rows['UID']; ?></td> <td><?php echo $rows['Name']; ?></td> <td><?php echo $rows['age']; ?></td> <td><?php echo $rows['city']; ?></td> </tr> <?php } ?> <tr> <td colspan="5" align="center" bgcolor="#FFFFFF"><input name="delete" type="submit" id="delete" value="Delete"></td> </tr> <?php //checking edit button value if(isset($_POST['edit'])){ echo $_POST['uid']; } // Check if delete button active, start this if($_POST['delete']){ $del_id = $_POST['delid']; foreach($_POST['delid'] as $id){ $delque="delete from studentrec where(UID='$id')"; $q=mysql_query($delque) or die(mysql_error()); printf("Records deleted: %d\n", mysql_affected_rows()); } // if successful redirect to delete_multiple.php if($q){ echo "<meta http-equiv=refresh content=0;URL=adelete.php>"; } } mysql_close(); ?> </table> </form> </td> </tr> </table> Quote Link to comment Share on other sites More sharing options...
saradrungta Posted January 4, 2009 Author Share Posted January 4, 2009 hi friends..... thanks for ur reply... i found a solution. <input type="button" Value="edit" onClick="document.location.href='adelete.php?euid=<?php echo $rows['UID'];?>' " /> 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.