bobahad Posted December 11, 2007 Share Posted December 11, 2007 Hello guys, I am trying to automatically generate an "edit" link near each Row depending on the number of rows, that's how much "Edit" we will have. The Edit will make the whole row into a textbox where a user can change the database value directly on the spot. Also when "Edit" is clicked, the button will now say save. Please check my PHP code. <?php while($rows=mysql_fetch_array($result)){ ?> <tr> <td align="center" bgcolor="#FFFFFF"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['id']; ?>"></td> <td bgcolor="#FFFFFF"><? echo $rows['id']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['Title']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['Author']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['Publisher']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['ISBN']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['Year']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['Price']; ?></td> <td align="center" bgcolor="#FFFFFF"><input name="Edit[]" type="readonly" id="Edit[]" value="<a href = 'EditBook.php?ID='<? echo $rows['id']; ?> Edit </a>"></td> <?php } ?> It's just the last <td> i am having trouble with, also if it's possible, I would like the editing to happen on the same page. "ViewBooks.php" Thanks guys Quote Link to comment Share on other sites More sharing options...
marcus Posted December 11, 2007 Share Posted December 11, 2007 Use a form. if(!$_POST['submit']){ //show what needs to be edited //on the form, have your submit button be called submit;; <input type="submit" value="Edit" name="submit"> }else { //edit } Quote Link to comment Share on other sites More sharing options...
revraz Posted December 11, 2007 Share Posted December 11, 2007 [/url]"> should be </a> You also can't use ="Edit[]" in your HTML like that. Quote Link to comment Share on other sites More sharing options...
bobahad Posted December 11, 2007 Author Share Posted December 11, 2007 Hey guys, Thanks for the replies, I am already using a submit button to delete rows selected by a checkbox. Here's the code: <?php while($rows=mysql_fetch_array($result)){ ?> <tr> <td align="center" bgcolor="#FFFFFF"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['id']; ?>"></td> <td bgcolor="#FFFFFF"><? echo $rows['id']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['Title']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['Author']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['Publisher']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['ISBN']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['Year']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['Price']; ?></td> <td align="center" bgcolor="#FFFFFF"><input name="Edit[]" type="readonly" id="Edit[]" value="<a href = 'EditBook.php?ID='<? echo $rows['id']; ?> Edit </a>"></td> <?php } ?> <tr> <td colspan="8" align="center" bgcolor="#FFFFFF"><input name="delete" type="submit" id="delete" value="Delete"></td> </tr> Result is here www.welovepluto.com/ViewBooks.php 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.