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. Link to comment https://forums.phpfreaks.com/topic/139452-passing-value-with-buttonpls-help/ 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? Link to comment https://forums.phpfreaks.com/topic/139452-passing-value-with-buttonpls-help/#findComment-729469 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 Link to comment https://forums.phpfreaks.com/topic/139452-passing-value-with-buttonpls-help/#findComment-729470 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 Link to comment https://forums.phpfreaks.com/topic/139452-passing-value-with-buttonpls-help/#findComment-729477 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 Link to comment https://forums.phpfreaks.com/topic/139452-passing-value-with-buttonpls-help/#findComment-729478 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. Link to comment https://forums.phpfreaks.com/topic/139452-passing-value-with-buttonpls-help/#findComment-729481 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 Link to comment https://forums.phpfreaks.com/topic/139452-passing-value-with-buttonpls-help/#findComment-729484 Share on other sites More sharing options...
Clinton Posted January 4, 2009 Share Posted January 4, 2009 You're right, my apologies. Link to comment https://forums.phpfreaks.com/topic/139452-passing-value-with-buttonpls-help/#findComment-729488 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.... Link to comment https://forums.phpfreaks.com/topic/139452-passing-value-with-buttonpls-help/#findComment-729491 Share on other sites More sharing options...
Clinton Posted January 4, 2009 Share Posted January 4, 2009 Can you show us your code? Link to comment https://forums.phpfreaks.com/topic/139452-passing-value-with-buttonpls-help/#findComment-729492 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> Link to comment https://forums.phpfreaks.com/topic/139452-passing-value-with-buttonpls-help/#findComment-729494 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'];?>' " /> Link to comment https://forums.phpfreaks.com/topic/139452-passing-value-with-buttonpls-help/#findComment-729512 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.