admin管理员组文章数量:1122846
I am trying to edit the data from the table in the frontend. when I click the edit the form doesn't anything it show only empty field
Html Code
<form action="" id="postjob" method="post">
<table>
<tr>
<td><label for="team_uniqueid">UniqueID:</label></td>
<td><input type="text" name="team_uniqueid" id="team_uniqueid" value=""/></td>
</tr>
<tr>
<td><label for="team_firstname">FirstName:</label></td>
<td><input type="text" name="team_firstname" id="team_firstname" value="" /></td>
</tr>
<tr>
<td><label for="team_lastname">LastName:</label></td>
<td><input type="text" name="team_lastname" id="team_lastname" /></td>
</tr>
<tr>
<td><label for="team_emailid">EmailId:</label></td>
<td><input type="text" name="team_emailid" id="team_emailid" /></td>
</tr>
<tr>
<div class="full_wrap">
<div class="sub_wrap">
<select name="page_id" id="page_id">
<?php
global $post;
$args = array( 'numberposts' => -1);
$posts = get_posts($args);
foreach( $posts as $post ) : setup_postdata($post); ?>
<option value="<?php echo $post->ID; ?>"><?php the_title(); ?></option>
<?php endforeach; ?>
</select>
<select>
<option class="au">Australia</option>
<option class="Ind">India</option>
<option class="US">United States</option>
<option class="UK">United Kingdom</option>
</select>
</div>
</div>
</tr>
<tr>
<td><button type="submit" name="insert_member">Submit</button></td>
</tr>
</table>
</form>
Edit Code
if (isset($_GET['edit'])) {
$id = $_GET['edit'];
$update = true;
$record = $wpdb->get_results("SELECT * FROM $tablename WHERE team_emailid = '".$id."'");
if($record->num_rows){
$n = $record->fetch_array();
$team_uniqueid = $n['team_uniqueid'];
$team_firstname = $n['team_firstname'];
$team_lastname = $n['team_lastname'];
$team_emailid1 = $n['team_emailid'];
}
}
I am trying to edit the data from the table in the frontend. when I click the edit the form doesn't anything it show only empty field
Html Code
<form action="" id="postjob" method="post">
<table>
<tr>
<td><label for="team_uniqueid">UniqueID:</label></td>
<td><input type="text" name="team_uniqueid" id="team_uniqueid" value=""/></td>
</tr>
<tr>
<td><label for="team_firstname">FirstName:</label></td>
<td><input type="text" name="team_firstname" id="team_firstname" value="" /></td>
</tr>
<tr>
<td><label for="team_lastname">LastName:</label></td>
<td><input type="text" name="team_lastname" id="team_lastname" /></td>
</tr>
<tr>
<td><label for="team_emailid">EmailId:</label></td>
<td><input type="text" name="team_emailid" id="team_emailid" /></td>
</tr>
<tr>
<div class="full_wrap">
<div class="sub_wrap">
<select name="page_id" id="page_id">
<?php
global $post;
$args = array( 'numberposts' => -1);
$posts = get_posts($args);
foreach( $posts as $post ) : setup_postdata($post); ?>
<option value="<?php echo $post->ID; ?>"><?php the_title(); ?></option>
<?php endforeach; ?>
</select>
<select>
<option class="au">Australia</option>
<option class="Ind">India</option>
<option class="US">United States</option>
<option class="UK">United Kingdom</option>
</select>
</div>
</div>
</tr>
<tr>
<td><button type="submit" name="insert_member">Submit</button></td>
</tr>
</table>
</form>
Edit Code
if (isset($_GET['edit'])) {
$id = $_GET['edit'];
$update = true;
$record = $wpdb->get_results("SELECT * FROM $tablename WHERE team_emailid = '".$id."'");
if($record->num_rows){
$n = $record->fetch_array();
$team_uniqueid = $n['team_uniqueid'];
$team_firstname = $n['team_firstname'];
$team_lastname = $n['team_lastname'];
$team_emailid1 = $n['team_emailid'];
}
}
Share
Improve this question
asked Oct 14, 2020 at 19:44
SnowSnow
1
4
|
1 Answer
Reset to default 0Good day! To edit the existing field, you need to put the values inside your input fields. You can do that in this way-
<tr>
<td><label for="team_uniqueid">UniqueID:</label></td>
<td><input type="text" name="team_uniqueid" id="team_uniqueid" value="<?php echo $team_uniqueid; ?>"/></td>
</tr>
I hope, this will help.
本文标签: databaseHow to edit custom table data in frontend
版权声明:本文标题:database - How to edit custom table data in frontend 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736282384a1926628.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
SELECT *
you're running a query to get ALL so by default it returns an array of results, even if it only finds one. So you may need to specify which offset in the array you're looking for. – Tony Djukic Commented Oct 14, 2020 at 20:40