Jump to content

custom php training


SparrowBD

Recommended Posts

Hello, I am having a very difficult issue. I have a page "dotrainingrequest.php" which $_POST's data from a form to a sql database. i then have a page in the admin center "trainingrequests.php" which gets all the information from the entire table and cleanly displays it to a html table, using php. My problem is that i want an admin to be able to "update" just one row from the database using a form on the same page, and for the life of me i cant figure out how.

Link to comment
Share on other sites

Pretty simple.

You can use a pop-up box or jQuery Dialog to display the form. For each row have an image or just an edit link which will open this form. First however you would need to assign an id to the row and an id column in phpMyAdmin (assuming that is what you are using). Now, you'd need to use SQL for this so it would be something like:

UPDATE table_name SET id=<?php echo $rowid;?> WHERE LastName='Doe' AND FirstName='John'

Of course this is just an example and will not be an exact code (I have a feeling the PHP part may not be correct), but it's the basic idea. $rowid would need to be the same as the id in the table and would be something like:

<table>

<?php

$id = 1;
$rowid = $id + 1;

foreach ($tablerow as $row){ ?>

<tr id="<?php echo $rowid;?>">
<td><?php echo $table->firstname;?></td>
<td><?php echo $table->lastname;?></td>
</tr>

<?php } ?>

</table>

Also check out http://www.w3schools.../sql_update.asp

Link to comment
Share on other sites

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.

Loading...
×
×
  • Create New...