How to open file by using windowpopup - php

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>";?>

Related

How to submit a value from a PHP defined table to a php page for further processing?

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>

How can i use the a tag

I have some code and would like to add an hyperlink to each entry on my database
tried using the 'a' tag
<tr>
<td><?php echo $row['id']; ?></td>
<td><a href='details.php'><?php echo $row['game_name']; ?></a></td>
<td><?php echo $row['game_year']; ?></td>
<td><?php echo $row['system']; ?></td>
<td style="text-align: center; color:green"><?php echo $row['owned']; ?></td>
<td style="text-align: center; color:blue"><?php echo $row['completed']; ?></td>
<td><?php echo $row['media']; ?></td>
<td><?php echo $row['launcher']; ?></td>
<tr>
would like to be able to link to a details page
<a href='details.php?gameID=<?=$row['id']?>'>
And in your details.php page you could fetch your DB:
$gameID = (int)$_GET['gameID'] and a bit more error handling

Use variables in PHP foreach loop

I use a foreach loop in php to fill a table, after that I use id and data-id to work with the line of the table.
The problem is that I can't figured how to increment a variable during the loop and add it in the id like this :
id='addr0' data-id="0",
id='addr1' data-id="1"
// etc.
Here is my loop :
foreach($result as $key => $value): ?>
<tr id='addr0' data-id="0">
<td><?php echo $value['Nom']; ?></td>
<td><?php echo $value['Prenom']; ?></td>
<td><?php echo $value['Adresse']; ?></td>
<td><?php echo $value['Date de naissance']; ?></td>
<td><?php echo $value['Numero de telephone']; ?></td>
<td data-name="del">
<button nam"del0" class='btn btn-danger glyphicon glyphicon-remove row-remove'></button>
</td>
</tr>
<?php endforeach; ?>
Try the following.
$counter = 0;
foreach($result as $key => $value): ?>
<tr id='addr<?php echo $counter?>' data-id="<?php echo $counter?>">
<td><?php echo $value['Nom']; ?></td>
<td><?php echo $value['Prenom']; ?></td>
<td><?php echo $value['Adresse']; ?></td>
<td><?php echo $value['Date de naissance']; ?></td>
<td><?php echo $value['Numero de telephone']; ?></td>
<td data-name="del">
<button name = "del<?php echo $counter?>" class='btn btn-danger glyphicon glyphicon-remove row-remove'></button>
</td>
</tr>
<?php
$counter++;
endforeach;
?>
You can get auto increment in two way.
Case 1 : If your $result is indexed array.
foreach($result as $key => $value): ?>
<tr id="addr<?php echo $key ?>" data-id="<?php echo $key ?>">
<td><?php echo $value['Nom']; ?></td>
<td><?php echo $value['Prenom']; ?></td>
<td><?php echo $value['Adresse']; ?></td>
<td><?php echo $value['Date de naissance']; ?></td>
<td><?php echo $value['Numero de telephone']; ?></td>
<td data-name="del">
<button nam"del<?php echo $key ?>" class='btn btn-danger glyphicon glyphicon-remove row-remove'></button>
</td>
</tr> <?php endforeach; ?>
Case 2 : If your $result is associative array.
<?php
$i = 0;
foreach($result as $key => $value): ?>
<tr id="addr<?php echo $i ?>" data-id="<?php echo $i ?>">
<td><?php echo $value['Nom']; ?></td>
<td><?php echo $value['Prenom']; ?></td>
<td><?php echo $value['Adresse']; ?></td>
<td><?php echo $value['Date de naissance']; ?></td>
<td><?php echo $value['Numero de telephone']; ?></td>
<td data-name="del">
<button nam"del<?php echo $i ?>" class='btn btn-danger glyphicon glyphicon-remove row-remove'></button>
</td>
</tr>
<?php
$i++;
endforeach;
?>

PHP MYSQL Table delete button not working

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>

Replace buttons with image in PHP code

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;" />

Categories