Click here to Skip to main content
15,920,896 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Good morning I am seeking for a help regarding on my php code. I have a problem updating a value in database using get method.

Here is the function I have a form method which is GET and i have a forloop where in inside that loop counts the number of data with the same tracking code now. for example i have a 3 same tracking code so i have a 3 textbox and also i have a 3 submit button. Now i want to update the textbox 1 and click submit it will automatically updated.

For reference here is my code:

<form method="get" action="view-reservation.php">
<table class="table table-striped">
<tr>
<td>January</td>
<td>February</td>
<td>March</td>
<td>April</td>
<td>May</td>
<td>June</td>
<td>July</td>
<td>August</td>
<td>September</td>
<td>October</td>
<td>November</td>
<td>December</td>
<td></td>
</tr>
<?php foreach ($view as $key => $data):?>
<tr>
<td><input type="hidden" name="track" size="1" value="<?php echo $data->track?>">
<input type="hidden" name="pid" size="1" value="<?php echo $data->pid?>">
<input type="text" name="jan" size="1" value="<?php echo $data->jan?>"></td>
<td><input type="text" name="feb" size="1" value="<?php echo $data->feb?>"></td>
<td><input type="text" name="mar" size="1" value="<?php echo $data->mar?>"></td>
<td><input type="text" name="apr" size="1" value="<?php echo $data->apr?>"></td>
<td><input type="text" name="may" size="1" value="<?php echo $data->may?>"></td>
<td><input type="text" name="jun" size="1" value="<?php echo $data->jun?>"></td>
<td><input type="text" name="jul" size="1" value="<?php echo $data->jul?>"></td>
<td><input type="text" name="aug" size="1" value="<?php echo $data->aug?>"></td>
<td><input type="text" name="sep" size="1" value="<?php echo $data->sept?>"></td>
<td><input type="text" name="oct" size="1" value="<?php echo $data->oct?>"></td>
<td><input type="text" name="nov" size="1" value="<?php echo $data->nov?>"></td>
<td><input type="text" name="dec" size="1" value="<?php echo $data->dec?>"></td>
<td>

<a href="view-reservation.php?track=<?php echo $data->track?>&&pid=<?php echo $data->pid?>&&jan=<?php echo $data->jan?>"
class="label label-danger">Update Payment</a></td>
</tr>
<?php endforeach;?>
<?php endif?>
</form>
</table>

Here is my query when i execute:
if(isset($_GET['track']) && isset($_GET['pid']) && isset($_GET['jan']))
{
//
$jan = filter($_GET['jan']);
$track = filter($_GET['track']);
$pid = filter($_GET['pid']);
$query = $con->query("update payment set jan = '500' where track = '$track' and pid='$pid'") or die(mysqli_errno());
if($query)
{
echo'updated';
}
}
Posted
Comments
ZurdoDev 30-Mar-15 8:59am    
What exactly is your question?

1 solution

Your php code is a basic mess:

You end many statements with '?' instead of ';',
such as: <input type="text" name="jan" size="1" value="jan?>">

You also have incomplete ?: conditionals,
$data):?>

At first I thought this to be an odd font translation but as ";" end some statements at the bottom of your query and some that aren't even part of php (maybe VB or something) I realize it's just in need of your learning php that's the problem.

Try: PHP Tutorial^
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900