I am not sure what is going wrong. But the system is printing the same values again and again, where it should echo the value only once where it is matching student_id in the delivery table. The full code I have edited as requested. This is not executing the query but able display the Table headings.
The code is :
<?php $min = $this->db->get_where('academic_settings' , array('type' =>'minium_mark'))->row()->description;?>
<?php $running_year = $this->db->get_where('settings' , array('type' => 'running_year'))->row()->description; ?>
<div class="content-w">
<div class="conty">
<?php include 'fancy.php';?>
<div class="header-spacer"></div>
<div class="content-i">
<div class="content-box">
<div class="row">
<div class="table-responsive">
<table width="100%" class="table table-striped table-lightfont">
<tbody>
<tr>
<td style="color:black !important; text-transform:uppercase; text-align:center;">
<?php echo get_phrase('Subject_Name');?> :
<span><?php echo $row['name'];?></span>
</td>
</tr>
<tr>
<td>
<table class="table table-padded">
<thead style="background-color:#90be2e; color:white;">
<tr style="padding-bottom:4px; padding-top:4px;">
<th style="color:white;"><?php echo get_phrase('Publish Date');?></th>
<th style="color:white;"><?php echo get_phrase('Assignment');?></th>
<th style="color:white;"><?php echo get_phrase('Faculty');?></th>
<th style="color:white;"><?php echo get_phrase('Last Date');?></th>
<th style="color:white;"><?php echo get_phrase('Submitted On');?></th>
<th style="color:white;"><?php echo get_phrase('Marks');?></th>
<th style="color:white;"><?php echo get_phrase('Feedback');?></th>
</tr>
</thead>
<tbody>
<?php
$uploader_id_student = $this->db->get_where('student', array('student_id' => $this->session->userdata('login_user_id')))->row()->student_id;
$invoices = $this->db->get_where('deliveries', array('student_id' => $uploader_id_student))->result_array();
foreach($invoices as $row2):
?>
<tr>
<td>
<?php echo $this->db->get_where('homework' , array('homework_code'=>$row2['homework_code']))->row()->upload_date;?>
</td>
<td>
<?php
$get_homework_data = $this->db->get_where('homework' , array('homework_code'=>$row2['homework_code']))->row();
echo wordwrap($get_homework_data->title,15,"<br>\n");
?>
</td>
<td>
<?php
echo $this->db->get_where('teacher' , array('teacher_id'=>$get_homework_data->uploader_id))->row()->first_name;
?>
<?php
echo $this->db->get_where('teacher' , array('teacher_id'=>$get_homework_data->uploader_id))->row()->last_name;
?>
</td>
<td>
<?php
$sampleDate1 = $this->db->get_where('homework' , array('homework_code'=>$row2['homework_code']))->row()->date_end;
$convertDate1 = date("d-m-Y", strtotime($sampleDate1));
echo $convertDate1;
?>
</td>
<td>
<?php
$sampleDate = $row2['date'];
$convertDate = date("d-m-Y", strtotime($sampleDate));
echo $convertDate;
?>
</td>
<td style="text-align:center;">
<?php echo $row2['mark'];?>
</td>
<td>
<?php echo wordwrap($row2['teacher_comment'],25,"<br>\n");?>
</td>
</tr>
<?php endforeach;?>
<!--<?php endforeach;?> -->
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
attached is screenshot of table Deliveries is there Deliveries Picture Download
Here is your code updated to fix the performance issues mentioned by Arnold Daniels.
<?php
$uploader_id_student = $this->session->userdata('login_user_id');
$invoices = $this->db->get_where('deliveries', array('student_id' => $uploader_id_student))->result_array();
foreach($invoices as $row2) {
$get_homework_data = $this->db->get_where('homework' , array('homework_code'=>$row2['homework_code']))->row();
$teacher = $this->db->get_where('teacher' , array('teacher_id'=>$get_homework_data->uploader_id))->row();
?>
<tr>
<td>
<?= $get_homework_data->upload_date ?>
</td>
<td>
<?= wordwrap($get_homework_data->title,25,"<br>\n") ?>
</td>
<td>
<?= $teacher->first_name . ' ' . $teacher->last_name ?>
</td>
</tr>
<?php
}
?>
It appears to be working fine as far as I could test it. Is there anything missing from the snippet you posted that could help reproduce your issue?
Edit:
So the complete code would be:
<?php
$min = $this->db->get_where('academic_settings' , array('type' =>'minium_mark'))->row()->description;
$running_year = $this->db->get_where('settings', array('type' => 'running_year'))->row()->description;
?>
<div class="content-w">
<div class="conty">
<?php include 'fancy.php'; ?>
<div class="header-spacer"></div>
<div class="content-i">
<div class="content-box">
<div class="row">
<div class="table-responsive">
<table width="100%" class="table table-striped table-lightfont">
<tbody>
<tr>
<td style="color:black !important; text-transform:uppercase; text-align:center;">
<?php echo get_phrase('Subject_Name'); ?> :
<span><?php echo $row['name']; ?></span>
</td>
</tr>
<tr>
<td>
<table class="table table-padded">
<thead style="background-color:#90be2e; color:white;">
<tr style="padding-bottom:4px; padding-top:4px;">
<th style="color:white;"><?php echo get_phrase('Publish Date'); ?></th>
<th style="color:white;"><?php echo get_phrase('Assignment'); ?></th>
<th style="color:white;"><?php echo get_phrase('Faculty'); ?></th>
<th style="color:white;"><?php echo get_phrase('Last Date'); ?></th>
<th style="color:white;"><?php echo get_phrase('Submitted On'); ?></th>
<th style="color:white;"><?php echo get_phrase('Marks'); ?></th>
<th style="color:white;"><?php echo get_phrase('Feedback'); ?></th>
</tr>
</thead>
<tbody>
<?php
$uploader_id_student = $this->db->get_where('student', array('student_id' => $this->session->userdata('login_user_id')))->row()->student_id;
$invoices = $this->db->get_where('deliveries', array('student_id' => $uploader_id_student))->result_array();
foreach ($invoices as $row2) :
$homework_data = $this->db->get_where('homework', array('homework_code' => $row2['homework_code']))->row();
$teacher = $this->db->get_where('teacher', array('teacher_id' => $get_homework_data->uploader_id))->row();
?>
<tr>
<td>
<?php echo $homework_data->title->upload_date; ?>
</td>
<td>
<?php
echo wordwrap($homework_data->title, 15, "<br>\n");
?>
</td>
<td>
<?php
echo $teacher->first_name;
?>
<?php
echo $teacher->last_name;
?>
</td>
<td>
<?php
$sampleDate1 = $homework_data->date_end;
$convertDate1 = date("d-m-Y", strtotime($sampleDate1));
echo $convertDate1;
?>
</td>
<td>
<?php
$sampleDate = $row2['date'];
$convertDate = date("d-m-Y", strtotime($sampleDate));
echo $convertDate;
?>
</td>
<td style="text-align:center;">
<?php echo $row2['mark']; ?>
</td>
<td>
<?php echo wordwrap($row2['teacher_comment'], 25, "<br>\n"); ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
I would need to see the contents of the included file "fancy.php" to be sure. There was an extra endforeach statement, but I'm guessing that it came from somewhere beyond the scope of the snippet you updated. I would need to see the whole content of the file and the content of the included script in order to determine the true nature of the error.
<!--<?php endforeach;?> -->
Remove this Line
This question already has answers here:
How do I highlight table row when fetching all information with array?
(2 answers)
Closed 3 months ago.
Given the following code, I want to highlight the row of a table wherein the $listing->Full == '1'.
<table id="datatable-responsive" cellspacing="0" width="100%">
<thead>
<tr>
<th align="center">Qty</th>
<th align="center">Posted Date</th>
<th align="center">Expiration</th>
<th align="center">Full Pkg</th>
</tr>
</thead>
<tbody>
<?php foreach($listings as $listing):
?>
<tr>
<td align="center"><?php echo $listing->quantity; ?></td>
<td align="center"><?php
$pdate = new DateTime($listing->posted_at);
echo $pdate->format('m/d/y'); ?></td>
<td align="center"><?php
$date = new DateTime($listing->expdate);
echo $date->format('m/d/y');
?>
</td>
<td align="center"><?php
if($listing->full == '1'):
?>
<?php echo "Yes"; ?>
<?php else:
?>
<?php echo "No"; ?>
<?php endif; ?>
</td>
<?php endif; ?>
</tr>
<?php endforeach; ?>
</tbody>
</table>
So ideally, the highlight color would be FFFFE6. Any help is greatly appreciated. This is an MVC site, so changing the CSS isn't conveniently an option.
Test before you set the style. Here is an inline example:
<?php
if($listing->full == '1'):
?>
<td align="center" style="background:#FFFFE6">
<?php echo "Yes"; ?>
<?php else: ?>
<td align="center">
<?php echo "No"; ?>
<?php endif; ?>
</td>
<?php endif; ?>
Here is an example using a class in your CSS:
CSS
.highlight {
background: #FFFFE6;
}
PHP/HTML
<?php
if($listing->full == '1'):
?>
<td align="center" class="highlight">
<?php echo "Yes"; ?>
<?php else: ?>
<td align="center">
<?php echo "No"; ?>
<?php endif; ?>
</td>
<?php endif; ?>
i currently have the following:
<?php
$field_name = "text_field";
$field = get_field_object($field_name);
if( isset($field['value'] ): ?>
<table class="">
<tbody>
<tr class="">
<th><?php echo $field['label']; ?></th>
<td><?php echo $field['value']; ?></td>
</tr>
</tbody>
</table>
<?php endif; ?>
my goal is to make the entire table row collapse and not display if there is no value entered.
clearly a novice. thanks for taking a look.
As per ACF documentation, field[‘value’] will always be set.
Instead do if (!empty($field['value']) or just if ($field['value']).
Thus it should look like this:
<?php
$field_name = "text_field";
$field = get_field_object($field_name);
?>
<table>
<tbody>
<?php
if ($field['value']): ?>
<tr>
<th><?php echo $field['label']; ?></th>
<td><?php echo $field['value']; ?></td>
</tr>
<?php endif; ?>
</tbody>
</table>
how can I pass values/ variables between tabs in html using php
I have 3 tabs those are fetched from database. each tab has separate id.
<div class="tab-nav">
<?php while ($row1 = mysql_fetch_array($result1)) : ?>
<?php $row1['name']; ?>
<?php endwhile ?>
</div>
tabs
<div class="tab-holder">
<div class="tab">
<table class="table table-striped">
<thead>
<tr>
<th width="34%">Job Title</th>
<th width="15%">Experience</th>
<th width="29%">Location</th>
<th width="8%">Salary</th>
<th width="7%"></th>
</tr>
</thead>
<tbody>
<?php
while($row = mysql_fetch_array($result)) {
$cat = $row['cat'];
if ($cat =='6') {
$jobtitle = $row['vVacjobtitle'];
?>
<tr>
<td>
<span class="pill medium green"><?php echo $row['vVacjobtitle'] ?></span>
</td>
<td><?php echo $row['experience'] ?></td>
<td><?php echo $row['vVacLocation'] ?></td>
<td><?php echo $row['salary'] ?></td>
<td>
Apply
</td>
</tr>
<?php
}
} ?>
</tbody>
</table>
</div>
how can i get id when clicking the tab
if ($cat == 6)
i want to place id in the place of 6
Thanks in advance .. :)
Since you're passing the value of id as a GET parameter, so you can access it by $_GET['id'] in your PHP code
print data after inner join of two tables in table format
I am getting following error in below code:
Parse error: syntax error, unexpected end of file in
/home/bina/public_html/studentzend/application/views/scripts/index/index.phtml
on line 57
Here is my code:
<?php if (count($this->messages)) : ?>
<ul id="messages">
<?php foreach ($this->messages as $message) : ?>
<li><?php echo $this->escape($message); ?></li>
<?php endforeach; ?> </ul>
<?php endif; ?>
<div class="row">
<div class="span12">
<a class="btn btn-primary" role="button" href="<?php echo $this->url(array('controller' => 'Index', 'action' => 'create')); ?>">Create Student</a>
<h3>Recent Students</h3>
<table class="table table-condensed">
<thead>
<tr>
<th>#</th>
<th>FirstName</th>
<th>LastName</th>
<th>Email</th>
<th>Actions</th>
</tr>
</thead>
<body>
<?php
if(empty($this->students))
{
echo "<tr>";
echo "<td><center>NO records found</center></td>";
echo "</tr>";
}
else
{
//print_r($this->students);exit;
$students=$this->students;
$length= sizeof($this->students);
//echo $length;exit;
for($i=0;$i<$length;$i++){ ?>
<tr>
<td><?php echo $students[$i]['id']; ?> </td>
<td><?php echo $students[$i]['firstname']; ?> </td>
<td><?php echo $students[$i]['lastname']; ?> </td>
<td><?php echo $students[$i]['email']; ?></td>
<td>
Edit |
Delete</td>
</tr>
<?php } ?>
</body>
</table>
</div>
You are just missing a closing brace } for your else statement.
Delete</td>
</tr>
<?php }} ?>
//^-------- Add one there