クエリを知っているmysqlデータベースにデータを更新したい。クエリは問題ではありません..
私が直面している問題は、IDページを他のページに送信する方法です..
ページ skill_edit.php?id=7 にいて、更新ボタンをクリックすると、フォームの POST メソッドを使用して skill_edit.php から skill.php に移動するとします。
しかし、ページのIDまたはテーブルの行のIDを「skills.php」に送信するにはどうすればよいですか
私のデータベース:
skill_edit.php のマイ フォーム
<form class="form-horizontal row-fluid" method="post" action="skills.php">
<?php //Skill Name ?>
<div class="form-row control-group row-fluid">
<label class="control-label span3" for="with-placeholder">Skill Name</label>
<div class="controls span7">
<input type="text" name="skill_name" id="with-placeholder" class="row-fluid" value="<?php echo $showskillname; ?>">
</div>
</div>
<?php //Skill Description ?>
<div class="form-row control-group row-fluid">
<label class="control-label span3" for="elastic-textarea">Skill Desc <span class="help-block">My Skill Description</span> </label>
<div class="controls span7">
<textarea name="skill_desc" rows="3" style=" height:80px;" class="row-fluid autogrow" id="elastic-textarea"><?php echo $showskilldesc; ?></textarea>
</div>
</div>
<?php //Selecting Language ?>
<div class="form-row control-group row-fluid">
<label class="control-label span3">Select with search</label>
<div class="controls span7">
<select name="skill_rating" data-placeholder="Choose a Language...." class="chzn-select">
<option value="<?php echo $showskillrating; ?>"><?php echo $showskillrating; ?></option>
<option value="1">1 Star</option>
<option value="2">2 Star</option>
<option value="3">3 Star</option>
<option value="4">4 Star</option>
<option value="5">5 Star</option>
</select>
</div>
</div>
<?php //Buttons ?>
<div class="form-actions row-fluid">
<div class="span7 offset3">
<button name="updatebtn" style=" float:left; margin-left:40px;" type="submit" class="btn btn-primary">Save changes</button>
<button formaction="skills.php" style=" float:right; margin-right:40px;" type="submit" class="btn btn-secondary">Cancel</button>
</div>
</div>
</form>
データを取得する自分の skill.php ページ
if(isset($_POST['updatebtn']))
{
$updatedskillname = mysql_real_escape_string($_POST['skill_name']);
$updatedskilldesc = mysql_real_escape_string($_POST['skill_desc']);
$updatedskillrating = mysql_real_escape_string($_POST['skill_rating']);
$last_updated = mysql_real_escape_string(date('F j, Y, g:i a'));
$update=update_skill($updatedskillname, $updatedskilldesc, $updatedskillrating, $last_updated);
}
関数の中身はこちら
//Update Skill
//skills.php
function update_skill($updatedskillname, $updatedskilldesc, $updatedskillrating, $last_updated)
{
$query="UPDATE cv_skills SET
skill_name='$updatedskillname',
skill_desc='$updatedskilldesc',
skill_rating='$updatedskillrating',
last_updated='$last_updated' WHERE skill_id='$pageid'";
$result=mysql_query($query);
$error=mysql_error();
return $error;
}
では、クエリで skill_id を取得するにはどうすればよいですか??