I have a table of students for attendance which enrolls in my course... in the table course end date is also mentioned
Table Code is Given Below:
<thead>
<tr>
<th><?php echo "Student Name"; ?></th>
<th><?php echo "Joining Date"; ?></th>
<th><?php echo "Batch End Date"; ?></th>
</tr>
</thead>
Table Body Code
<tbody>
<td><?php echo $value['firstname'] . " " . $value['lastname']; ?></td>
<td><?php echo $value['admission_date']; ?></td>
<td><?php echo $value['course_end_date']; ?></td>
</tbody>
The Body Data is In Variable Which Picks Data from another List and Showed Content... Look Like in the Front View
<tbody>
<td>Kapil</td>
<td>09/15/2019</td>
<td>10/20/2019</td>
</tbody>
The Above code is using For Student Attendence
What I am looking for is:
student detail or row doesn't show once his Batch End Date Passed.
and the row changes color on the last day of the Batch End Date.
Related
Let's say for example column dropdown represents a type of membership and depending on the value of dropdown, I would like to be able to display a column next to it that indicates the maximum number of companions I could bring. Is there a way to do it via javascript or PHP or maybe SQL itself?
<?php
foreach ($dbh->query($sql) as $rows){
?>
<tr>
<td><?php echo $rows['name']?></td>
<td><?php echo $rows['email']?></td>
<td><?php echo $rows['number']?></td>
<td><?php echo $rows['org']?></td>
<td><?php echo $rows['dropdown']?></td>
<td><?php echo $rows['date']?></td>
</tr>
<?php
}
?>
Code:
<?php
foreach ($dbh->query($sql) as $rows){
?>
<tr>
<td id="<?=$rows['id']?>"><?php echo $rows['name']?></td>
</tr>
<?php
}
?>
By clicking on the ajax button you will take the ID attribute of the column, send a request with the received id and add the value to the column created next to it.
If I understand you correctly.
errors i get
I have a table that contains details one of this being emails. When i click a link i have outlook mail opening but i want to take the email of that row in the table and put it into the 'to' part of the email. Below i have code for what i am currently doing.
the code below displays the data from my database in a table format
<table class="table table-striped custab">
<thead>
<tr>
<th> </th>
<th>Booking ID</th>
<th> Name</th>
<th>Email</th>
<th>Date</th>
<th>time</th>
<th>No. of guests</th>
<th>Booking Reason</th>
<th>Comments</th>
<th width="110" class="ac">Approved?</th>
</tr>
<thead>
<!-- php function to only select the bookings that have not yet been approved/rejected -->
<?php
include 'config.php';
$select = "SELECT * FROM `booking` WHERE `status`IS NULL ";
$result = $conn->query($select);
while($row = $result->fetch_assoc()){
?>
<tr>
<td><input type="checkbox" class="checkbox" /></td>
<td><?php echo $row['customer_ID'] ?></td>
<td><?php echo $row['Name'] ?></td>
<td><?php echo $row['Email'] ?></td>
<td><?php echo $row['booking_date'] ?></td>
<td><?php echo $row['booking_time'] ?></td>
<td><?php echo $row['attendee_no'] ?></td>
<td><?php echo $row['booking_reason'] ?></td>
<td><?php echo $row['comments'] ?></td>
<td>
Email this Codesnippet</a>
</td>
</tr>
<?php
}
?>
</table>
The function below gets the pop up to display for outlook mail
<script type="text/javascript"> TriggerOutlook(Email)
{
var $to = 'Email';
var body = "your booking has been approved";
<!-- var body = escape(window.document.title + String.fromCharCode(13)+ window.location.href); --->
var subject = "Your booking request";
window.location.href = "mailto:?body="+body+"&to="+$to+"&subject="+subject;
}
</script>
if i put in an email manually into the var $to = the outlook pop up works however if i try to take the email from the table it doesnt, can anyone help me out to identity where i am going wrong? Thanks!
1 You don't need the PHP $ declaration for variables, thus:
var $to = 'Email';
should be:
var to = 'Email';
more descriptive variables could make future updates easier:
var toAddr = 'Email';
2 Your JavaScript function should be preceded with the function tag
<script type="text/javascript"> TriggerOutlook(Email)
{
changes to:
<script type="text/javascript">
function TriggerOutlook(Email){
3 Use a button rather than link
Replace
Email this Codesnippet</a>
With
<button
onclick="TriggerOutlook(<?php echo $row['Email'];?>)"
value="submit"
>Email this Codesnippet</button>
I wrote this part of code:
<table class="table table-hover">
<thead>
<tr>
<th>Status</th>
<th>MPK</th>
<th>Full Name</th>
<th>Phone Number</th>
<th>Project Start Date</th>
<th>Project End Sales Date</th>
<th>Project Installation Date</th>
<th>Project End Date</th>
<th>General Manager</th>
<th>IT Project Manager</th>
<th>Notes</th>
</tr>
</thead>
<?php
$file = '/var/lib/jenkins/workspace/Update_JSON/terminarz.json';
$fp_terminarz = fopen($file, 'r');
$toecho = fread($fp_terminarz, filesize($file));
$data = json_decode($toecho, true);
fclose($fp_terminarz);
foreach($data as $key=>$value){ ?>
<tbody>
<tr>
<td>Opening process</td>
<td><?php echo $value["MPK"]; ?></td>
<td><?php echo $value["Restaurant Name"]; ?></td>
<td><?php echo $value["Phone Number"]; ?></td>
<td><?php echo $value["Project Start Date"]; ?></td>
<td><?php echo $value["Project End Sales Date"]; ?></td>
<td><?php echo $value["Project Installation Date"]; ?></td>
<td><?php echo $value["Project End Date"]; ?></td>
<td><?php echo $value["Restaurant Manager"]; ?></td>
<td><?php echo $value["IT Project Manager"]; ?></td>
<td><?php echo $value["Notes"]; ?></td>
</tr>
<?php } ?>
</tbody>
</table>
I show JSON content in HTML table using PHP script.
My problem is - I want to have possibility to edit any row (one at a time) and after saving changes update file terminarz.json.
What is the best way to do this? I was thinking about js scripts, which would change css style of row and show Edit button near row (after pointing it with mouse cursor).
Is this good approach to this task? Or how should I do this? I would appreciate any advice.
For the UI/UX part:
Why not have an edit icon in the last column of table with a column heading Edit.
Have hidden input fields with proper names and value pre-filled.
On click of the edit icon, simply hide the data and show the input fields, so the user can edit the data. Also, switch the edit icon to save and also give an option to cancel out.
Something like this: http://nathancahill.github.io/table-edits/
For updating the data:
$jsonString = file_get_contents('terminarz.json');
$data = json_decode($jsonString, true);
foreach ($data as $key => $entry) {
if ($entry['id'] == $updated_row_id) {
$data[$key]['name'] = "value";
}
}
And then save it back using:
$newJsonString = json_encode($data);
file_put_contents('terminarz.json', $newJsonString);
Its a good approach just do one more thing wrap table in form and make input hidden element for each field when you edit a single row then update that hidden element with new entry and at last submit the form which contain all the entries and on server side catch that data and convert into json and save it
I'm trying to get data from database using PHP this the Sql request you'll see that I have 3 tables but in table Milestoneevent I have various values for column libelle so I want to display like this
Id num libelle1 libelle2 libelle3 ..... sql reql request and php
select DISTINCT file.num,file.id as filenumber,file.numlta,milestones.id,milestones.libelle,milestoneevent.idmilestone,milestoneevent.dat,milestoneevent.idfile from file,milestones,milestoneevent where milestoneevent.idfile=FILE.num and milestoneevent.idmilestone=milestones.id
while (row=mysqlfetchassoc(
rs_result)) {
//print_r( $row ); // debug code ?>
<tr>
<td><input type='checkbox' name="approve[]" id="check" value=<?php echo $row['num']?>></td>
<td><?php echo $row['filenumber']; ?></td>
<td><?php echo $row['numlta']; ?></td>
<td><?php echo $row['designation']; ?></td>
<td><?php echo $row['libelle']; ?></td>
<td><?php echo $row['milestonedate']; ?></td>
</tr>
in the picture you see that a row cqn have multiple values for column libelle in different dates
edit
As requested in comments, here is my expected output:
I was forced to add picture here cause in comment discussion can not add it
You can use GROUP_CONCAT, in your query:
select...,GROUP_CONCAT(milestones.libelle SEPARATOR ';'),..FROM....WHERE...GROUP BY milestones.id
I have a table that its' rows are dynamically generated. I am hiding the second row so the user can expand that row if he or she chooses to do so. I need to have an alternating background for every first and third row, and the second row will take the background color of the row before it.. Here's a picture to help explain:
The CSS I am currently using is this: (Provided from #rusmus)
.tbody tr:nth-child(4n), tbody tr:nth-child(4n- 1){
background-color: #FF0000;
}
And here is a link to his working example: http://jsfiddle.net/Lutkz/1/
For some reason though, it's not applying the color to the after the affected like the jsfiddle
Side note: The whole table is in a foreach() that displays each row from the database into the table.
Code of the table:
<div class="table-wrapper" id="monthly-payers">
<table border="0" cellpadding="0" cellspacing="0" class="portfolio table table-striped-improved">
<thead>
<tr>
<th class="persist essential security">Security</th>
<th class="persist essential">Symbol</th>
<th class="optional">Number<br>of Shares</th>
<th class="optional">Cost<br>Basis</th>
<th>Current<br>Price</th>
<th>Stock<br />Return %</th>
<th>Buy<br>Under</th>
<th>Dividend<br>Yield</th>
<th>Ex-Dividend<br>Date</th>
<th class="persist">Payout<br>Date</th>
<th>Cumulative<br>Dividend</th>
</tr>
</thead>
<tbody>
<?php if( isset($open_trades['monthly-payers']) && !empty($open_trades['monthly-payers']) ){ ?>
<?php foreach( $open_trades['monthly-payers'] as $trade ){
$numShares = empty($trade['num_shares'])? 1 : intval($trade['num_shares']);
?>
<tr>
<td><?php echo $trade['security']; ?></td>
<td><?php echo $trade['symbol']; ?></td>
<td><?php echo !empty($trade['num_shares']) ? $trade['num_shares'] : '–'; ?></td>
<td><?php echo is_numeric($trade['entry_price']) ? '$' . sprintf("%.02f", $trade['entry_price']) : '–'; ?></td>
<td><?php echo is_numeric($trade['current_price']) ? '$' . sprintf("%.02f", $trade['current_price']) : '–'; ?></td>
<td><?php echo (is_numeric($trade['current_price']) && is_numeric($trade['entry_price'])) ? sprintf("%.02f", ($trade['current_price'] - $trade['entry_price']) / $trade['entry_price'] * 100)."%" : ''; ?></td>
<td><?php echo is_numeric($trade['buy_under']) ? '$' . sprintf("%.02f", $trade['buy_under']) : '–'; ?></td>
<td><?php echo is_numeric($trade['dividend_yield']) ? sprintf("%.02f", $trade['dividend_yield']) . '%' : '–'; ?></td>
<td><?php echo date('m/d/y', $trade['ex_dividend_date']); ?><?php echo !empty($trade['estimated']) ? ' Est.' : ''; ?></td>
<td><?php echo date('m/d/y', $trade['payout_date']); ?></td>
<td><?php echo is_numeric($trade['total_dividend']) ? '$' . $trade['total_dividend'] : '–'; ?></td>
</tr>
<tr>
<td><?php echo $trade['stock_type']; ?></td>
</tr>
<?php } ?>
That second row, $trade['stock_type'] is what is causing the whole thing to go wonky.
I am going to have comments in that row that the user can hide, or show, that's why I need the alternating color to skip that row, and just apply the color of the above it.. (which changes with each row in the foreach())
So what you're wanting is for the rows to alternate 2 at a time. So they go dark dark, light light, dark dark
I think, similar to #rusmus solution, you should apply a class to the rows.
Put this right before your foreach loop:
$black = true;
$rownumber = 0;
Put this in your loop
if(($rownumber % 2) == 0){//if the number is even
$black = !$black; //switch the state
if($black){
$class = 'blackRow';
}else{
$class = 'whiteRow';
}
}
$rownumber++;
Basically what I've done is check if the row number is even. If it is, then we switch the color from being light to dark.
On your table row do something like this:
<tr class='<?php echo $class; ?>' >
Here's a codepad example:
http://codepad.org/JR4KOri4
Why are you using two rows for 1 row of information?
You could put a linebreak <br/> after "Advent Claymore Convertible Securities & Income Fund", then the t is showed on the next line and you get the colors you want. Like this:
<td><?php echo $trade['security']; ?><br/><?php echo $trade['security']; ?></td>
instead of
<td><?php echo $trade['security']; ?></td>
You could just apply a class to the rows that you want to have a different background, and target that class in css.
But if you want to do it without modifying you markup you could do something like:
tr:nth-child(4n), tr:nth-child(4n - 1){
background-color: #FF0000;
}
The above selects every 4th row, as well as the row before it. An illustration:
<table>
<tr><td>Foo</td></tr>
<tr><td>Foo</td></tr>
<tr><td>Foo</td></tr> <!-- row 4n - 1 (for n=1) -->
<tr><td>Foo</td></tr> <!-- row 4n (for n=1) -->
<tr><td>Foo</td></tr>
<tr><td>Foo</td></tr>
<tr><td>Foo</td></tr> <!-- row 4n - 1 (for n=2) -->
<tr><td>Foo</td></tr> <!-- row 4n (for n=2) -->
<tr><td>Foo</td></tr>
<tr><td>Foo</td></tr>
</table>
Fiddle: http://jsfiddle.net/Lutkz/1/
Checked to work in chrome, firefox, ie11, ie10 and ie9.