Hey guys, me again.

OK, I have this form that gets and populates the select boxes with the necessary info.
Now, what I would like to do is to take the id field of the select box and use that to do a select query on the relevant table. So when the user selects, for eg a person, and then hits the edit person button I would like a new page to open and a form to be filled with the person's details from the database. Then the user should be able to edit that info and submit any changes to the database.

Here is the code that populates the initial select boxes to choose what to edit.

<form class="semantic" method="post" action="">
<fieldset>
<ul>
<li>
<legend>View and/or Edit Person</legend>
<?php
$ops = '';
$sql_select = "select person_id, first_name, middle_name, last_name from `person` order by `last_name` asc ";
$retval_selectperson = mysql_query( $sql_select, $conn );
if(! $retval_selectperson ) { die('Could not select data: ' . mysql_error()); }
while($row = mysql_fetch_assoc($retval_selectperson)) 
{
$ops .=  "<option value='{$row['person_id']}'>{$row['first_name']} {$row['middle_name']} {$row['last_name']}</option>";
}
?>
<div>
<label for="person_id">Select a Person</label>
<select name="person_id" id="person_id">
<option value="">--- Select a Person ---</option>
<?php echo $ops;?>
</select>
</div>
<div class="button-row">
<input name="edit" type="submit" id="edit_person" value="Edit Person">
</div>
</li>

So when the submit button is clicked, a new page opens and the record is displayed and then the editing of that record, if necessary, can take place and then if changed it can be updated to the database using an update query.

I need to know how to go to another page and actually do that.

Recommended Answers

All 7 Replies

The mysqli extensions will be used when the site goes live, so just concentrating on getting the code working locally first and will worry about pdo or mysqli when everything has been done and works.

Member Avatar for diafol

have a form element around the fields and set it to...

<form action="somefile.php" target="_blank" ...>

I think that should open the somefile.php in a new window and your data will be passed via GET (or POST if you specify that).

So each different area its own form? Can do that.

Member Avatar for diafol

Why each different area in its own form?

That's what I understood a form element to be?
Each button has it's own id. Is that what is to be used as a form element?

Member Avatar for diafol

Sorry, I missed the

<form class="semantic" method="post" action="">

at the top - just replace it with

<form class="semantic" method="post" action="" target="_blank">

but you may want to send the form to a different page? If so change the action

Will give that a go tomorrow. Cheers buddy!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.