Here is the query statement that I have. For some reason it works for another table I have but doesn't work with this table. I checked phpmyadmin to see if I would create an error but there were zero errors.
$Store_ID = filter_input(INPUT_POST,'Store_ID',FILTER_VALIDATE_INT);
//DELETE the Store
$query="DELETE FROM store_location WHERE Store_ID = :Store_ID";
$statement2=$db->prepare($query);
$statement2->bindValue(':Store_ID',$Store_ID);
$statement2->execute();
$statement2->closeCursor();
Here is the table code for the Delete Button
<?php foreach ($stores as $s) : ?>
<tr>
<td><?php echo $s['Store_ID']; ?></td>
<td><?php echo $s['Loc_Street']; ?></td>
<td><?php echo $s['Loc_City']; ?></td>
<td><?php echo $s['Loc_State']; ?></td>
<td><?php echo $s['Rent']; ?></td>
<td><?php echo $s['License']; ?></td>
<td><?php echo $s['Inspect']; ?></td>
<td><form action="stores.php" method="post">
<input type ="hidden" name ="Store_ID" value ="<?php echo $s['Store_ID']; ?>"/>
<input type="button" name="delete" value="Delete"/>
</form></td>
</tr>
<?php endforeach; ?>
</table>
Related
How to know the max number in each row of mysql database and return the column name or return name in phpmysql
I want the dominant row to display the max value of a row , the row has this column (o_result, c_result,e_result,_result )
My code is
<tbody>
<?php
$result= mysqli_query($connection,"select * from test_report order by test_id ASC" ) or die (mysqli_error($connection));
while ($row= mysqli_fetch_array ($result) ){
$id=$row['test_id'];
?>
<tr>
<td><?php echo $row['test_id']; ?></td>
<td><?php echo $row['date_of_submission']; ?></td>
<td><?php echo $row['status']; ?></td>
<td><?php echo $row['o_result']; ?></td>
<td><?php echo $row['c_result']; ?></td>
<td><?php echo $row['e_result']; ?></td>
<td><?php echo $row['a_result']; ?></td>
<td><?php echo $row['n_result']; ?></td>
<td><?php echo $row['dominant']; ?></td>
<td><button class="btn search"></button>
<button class="btn edit"></button>
<button class="btn btn-danger"></button>
</td>
</tr>
<?php } ?>
</tbody>
You want to identify the greatest value on each row, and the name of the column that holds that value.
A simple method uses greatest() and case:
select
t.*,
greatest(o_result, c_result, e_result, a_result, n_result) as max_result,
case greatest(o_result, c_result, e_result, a_result, n_result)
when o_result then 'o_result'
when c_result then 'c_result'
when a_result then 'a_result'
when n_result then 'n_result'
end as max_column_name
from mytable t
I am using a form to submit data to a php page and then presenting it as a table using the method which is working fine for me. Now I want to submit one of the data field ($row->id) to another php page for processing detailed user profile. I tried using the form method as shown in the code but it doesn't work and keeps submitting same value for every profile.
<tr>
<td><?php echo $n++; ?></td>
<td><?php echo $row->id; ?></td>
<td><?php echo $lang[$row->gender]; ?></td>
<td><?php echo $row->age; ?></td>
<td><?php echo $row->height; ?></td>
<td><?php echo $row->edn; ?></td>
<td><?php echo $lang[$row->income]; ?></td>
<td><form action= 'compact.php' method='post'>
<input type ='hidden' name='pid' value="<?php echo $row->id?>">
<input type='submit' name='submit' value='View Details'></td>
</tr>
Any help will be highly appreciated. Thanks
Based on suggestions in the comments to above question, I changed my script as follows and used GET instead of POST at compact.php and was able to successfully capture the posted variable for further processing:
<tr>
<td><?php echo $n++; ?></td>
<td><?php echo $row->id; ?></td>
<td><?php echo $lang[$row->gender]; ?></td>
<td><?php echo $row->age; ?></td>
<td><?php echo $row->height; ?></td>
<td><?php echo $row->edn; ?></td>
<td><?php echo $lang[$row->income]; ?></td>
<td><a href="compact.php?pid=<?php echo $row->id?>">
View details</a></td>
</tr>
I have file (feeColect.php) which display information by using php, now I want to run (stockreportPDF.php) file after click Export PDF button, its real confuse me that what is wrong with the code while I used the same on previous project
1: this is (feeColect.php) file.
<tr><td><?php echo $list->idnumber; ?></td>
<td><?php echo $list->name; ?></td>
<td><?php echo $list->class; ?></td>
<td><?php echo $list->boarding_fee; ?></td>
<td><?php echo $list->school_fee; ?></td>
<td><?php echo $list->trans_fee; ?></td>
<td><?php echo $balance; ?></td>
<td><?php echo $list->term; ?></td>
<input type="hidden" name="id" id="id" value="<?php echo $list->id; ?>">
<?php $url_PDFstock ="stockreportPDF.php?from_date=$from_date&to_date=$to_date "; ?>
this is button that it suppose to open windowpop after click
<?php echo "<p> <a onclick=\"return windowpop('". $url_PDFstock ."')\">
<input class='btn btn-round btn-orange' type='button' value='Export PDF'></a></p>";?>
This are my view code:
<?php
foreach($books as $books) {
echo $books->book_id;
echo $books->book_name;
echo $books->description;
echo $books->author;
echo $books->publisher;
echo $books->pages;
echo $books->publication_date;
echo $books->price;
echo $books->status;
echo $books->quantity;
echo $books->genres;
echo $books->user_rating;
echo $books->reviews;
}
?>
the output is
However i want the output to be like Book ID:1, Book Name:qweqweqweqweqwe, price 123.00 and so on, in a table form am i able to do it?
I hope this will help you..
<table>
<th>
<td>Book Id</td>
<td>Book Name</td>
<td>Description</td>
<td>Author</td>
<td>Publisher</td>
<td>Pages</td>
<td>Publication Date</td>
<td>Price</td>
<td>status</td>
<td>Quantity</td>
<td>Genres</td>
<td>User Rating</td>
<td>Reviews</td>
</th>
<?php foreach($books as $book) { ?>
<tr>
<td><?php echo $book->book_id ?></td>
<td><?php echo $book->book_name ?></td>
<td><?php echo $book->description ?></td>
<td><?php echo $book->author ?></td>
<td><?php echo $book->publisher ?></td>
<td><?php echo $book->pages ?></td>
<td><?php echo $book->publication_date ?></td>
<td><?php echo $book->price ?></td>
<td><?php echo $book->status ?></td>
<td><?php echo $book->quantity ?></td>
<td><?php echo $book->genres ?></td>
<td><?php echo $book->user_rating ?></td>
<td><?php echo $book->reviews ?></td>
</tr>
<?php } ?>
</table>
concat your string with php function.
echo "Book ID:".$books->book_id.", Book Name: ".$books->book_name;
Like this way.
Use like this:
echo "Book ID : $books->book_id";
double quotes will automatically identify variables and execute them.
you can also try:-
echo 'Book ID:'. $books->book_id;
Please choose which one easily readable for you.
I am trying to display images in place of buttons for various activities like Edit Record, Delete Record, Download, Save, Reset. I am able to show the image but the result is very output is looks very childish and nonprofessional. Actually images are coming on button as shown in image
But I want image to display like this
Here is the code which gives the 1st image output.
<tr style="background-color: rgb(253, 253, 183); color: rgb(42, 16, 179);font-size: 13px;" >
<td><?php echo $row->eq_application_no; ?></td>
<td><?php echo $row->eq_class; ?></td>
<td><?php echo $row->eq_name;?></td>
<td><?php echo $row->mid_name; ?></td>
<td><?php echo $row->last_name; ?></td>
<td><?php echo $row->eq_sex; ?></td>
<td><?php echo $row->father_name; ?></td>
<td><?php echo $row->eq_dob; ?></td>
<td><?php echo $row->age.",".$row->month.",".$row->day;?></td>
<td><?php echo $row->scat_id;?></td>
<td><?php echo $row->parent_cate_id;?></td>
<td><?php echo $row->no_of_transfer;?></td>
<td><?php echo $tc_case; ?></td>
<td><?php echo$row->last_school_type; ?></td>
<td><?php echo $row->eq_prv_acdmic;?></td>
<td><?php if($row->kv_tc_date=="1970-01-01"){echo "-";}else{echo $row->kv_tc_date;}?></td>
<td><?php echo $row->kv_tc_no;?></td>
<td><?php echo $row->last_class_cgpa;?></td>
<!--value="Edit"-->
<td><input type="button" id="<?php echo $row->es_enquiryid;?>" onclick="edit_record(<?php echo $row->es_enquiryid;?>)" style="background-image:url(images/edit24.png);width:24px;height:24px;"></td><td>
<!--value="Delete"-->
<input type="button" id="<?php echo $row->es_enquiryid;?>" onclick="delete_record(<?php echo $row->es_enquiryid;?>)" style="background-image:url(images/delete24.png);width:24px;height:24px;" ></td><td><?php
if($eligible=="Y")
{?><input type="checkbox" class="app" name="app[]" d="
<?php echo $row->es_enquiryid;?>" value="<?php echo $row->es_enquiryid;?>">
<?php }
else
{
echo"-";
}
?></td>
</tr>
<?php } ?>
</tbody>
</table>
<table>
<tr>
Add image directly then:
<img src="images/delete24.png" id="<?php echo $row->es_enquiryid;?>" onclick="delete_record(<?php echo $row->es_enquiryid;?>)" style="cursor:pointer;width:24px;height:24px;" />