my level of IT knowledge is very very very much beginner.
I learned how to set up DB, create TB and insert, update, delete and sum. I got some basic idea about the sytax although I am not sure at all. I always make sure my code has mysqli things in it.
Than I wanted to process the data via PHP. The condition needs to be defined here and thats where I fail. I cannot make it work. Anyone sees my mistake? (I know there could be errors in the code, forgive or instruct how to repair than). Here is my file listpart.php (this file is supposed to give me plain output from my table called transactions, this and inputpart.php is included in overviewsingle.php).
———————————————
Assume that in sql I added 1more column ´completition' and it can store only 1 character. In html i created checkbox input, if its checked it will insert into related cell little "o". So if in column is "o" that means that the row was completed.
I dont know how to check all the rows if column ´completition' equals "o" or not. If it does do something like "echo 'done if it doesnt do nothing.
I need to use foreach or while that it will check this condition in every row. ——————————————— thanks everybody in advance
<?php
include('config.php');
if(isset($_POST['submit']))
{
$date=mysqli_real_escape_string($query, $_POST['date']);
$amount=mysqli_real_escape_string($query, $_POST['amount']);
$type=mysqli_real_escape_string($query, $_POST['type']);
$purpose=mysqli_real_escape_string($query, $_POST['purpose']);
$detail=mysqli_real_escape_string($query, $_POST['detail']);
$location=mysqli_real_escape_string($query, $_POST['location']);
$completition=mysqli_real_escape_string($query, $_POST['completition']);
$query1=mysqli_query($query, "insert into transactions values('','$date','$amount','$type','$purpose','$detail','$location','$completition')");
echo "insert into transactions values('','$date','$amount','$type','$purpose','$detail','$location','$completition')";
if($query1)
{
header("location:overviewsingle.php");
}
}
?>
<form method="post" action="">
<tr>
<th><label for="date">Date</label></th>
<th><label for="amount">Amount</label></th>
<th><label for="detail">Detail</label></th>
<th><label for="type">Type</label></th>
<th><label for="purpose">Purpose</label></th>
<th><label for="location">Location</label></th>
<th><label for="location">Done</label></th>
</tr>
<tr class="categoryInput">
<td><input type="text" name="date" value="<?php echo date("Y-m-d");?>" style="width:80px"></td>
<td><input type="text" name="amount" style="width: 95px"></td>
<td><input type="text" name="detail" style="width: 145px"></td>
<td><input type="text" name="type" style="width: 35px"></td>
<td><input type="text" name="purpose" style="width: 95px"></td>
<td><input type="text" name="location" style="width: 95px"></td>
<td><input type="checkbox" name="completition" style="width: 30px"></td>
<td colspan="2"><input type="submit" name="submit" id="submit_button" style="width: 50px"></td>
</tr>
</form>
Aucun commentaire:
Enregistrer un commentaire