Jump to content

Generating an Edit that edits database fields.


bobahad

Recommended Posts

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 :)

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.