I need to convert HTML in template.
As seen in image content should show as a template.
I am using table to show . but now i need to show it in template output
Here is my Code:
<table id="datatable" class="tablesorter">
<span id='errfrmMsg'></span>
<thead>
<tr>
<th scope="col" id="">Name</th>
<th scope="col" id="">Content</th>
</tr>
</thead>
<tbody>
<?php
$templ_id = $_REQUEST['templ_id'];
$getTemplateQuery = mysql_query("select * from templates where id = $templ_id");
$getTemplateRow = mysql_fetch_array($getTemplateQuery);
?>
<tr>
<td valign="top" width="125"><?php echo $getTemplateRow['templ_name'];?></td>
<td valign="top" width="319">
<?php
echo $templContent = $getTemplateRow['templ_content'];
?>
</tr>
</tbody>
</table>
Here is an Output:
From what I can gather from your question, try outputting with:
$html = htmlspecialchars_decode($content)
EDIT:
echo $templContent = htmlspecialchars_decode($getTemplateRow['templ_content']);
Try this this will help You
<?php
echo $htmlContent = htmlspecialchars_decode($getTemplateRow['templ_content'])
?>
Related
Trying to use a Bootstrap 5 Collapse. This same code has been copied from a similar page, but the rows do not expand to show the collapsed (hidden) row. Instead I get the above error on the browser console.
The browser's console has these lines at the bottom ( I can click the top row to expand the remaining rows, which looks like the attached pic):
SyntaxError: The string did not match the expected pattern.
querySelector - index.js:64
e - index.js:64
(anonymous function) - collapse.js:317
If I tap any of the lines after the f symbols, the browser redirects me to the "Sources" tab to the relevant JS file for Bootstrap.
The code is - not the full page, this is exerted:
<?php
$x = 1;
$leadingScore = -100;
if (isset($leaderboard)) {
foreach ($leaderboard as $score) {
$pid = (string) $score['playerId'];
?>
<div class="collapse">
<tr data-bs-toggle='collapse' data-bs-target='#<?=$pid?>'>
<th scope="row">
<?php
if ($leadingScore != $score['score'])
echo $x;
?>
</th>
<td style="text-align: left;">
<?php echo $score['playerName']." (".$score['hcap'].")"; ?>
</td>
<td>
<?php
echo $score['score'];
$leadingScore = $score['score'];
?>
</td>
<td>
<?php
echo $score['thru'];
?>
</td>
</tr>
<tr id='<?=$pid?>' class='collapse'>
<td colspan=4>
<table class='table'>
<tr>
<th class='sub-th' scope='col'></th>
<th class='sub-th' scope='col'>1</th>
<th class='sub-th' scope='col'>2</th>
<th class='sub-th' scope='col'>3</th>
<th class='sub-th' scope='col'>4</th>
<th class='sub-th' scope='col'>5</th>
<th class='sub-th' scope='col'>6</th>
<th class='sub-th' scope='col'>7</th>
<th class='sub-th' scope='col'>8</th>
<th class='sub-th' scope='col'>9</th>
<th class='sub-th' scope='col'>TOTAL</th>
</tr>
</table>
</td>
</tr>
</div>
<?php
$x++;
}
}
?>
The output in the browser source, the primary table row HTML is:
<div class="collapse">
<tr data-bs-toggle='collapse' data-bs-target='#609d0993906429612483cf49'>
The collapsable row HTML is:
<tr id='609d0993906429612483cf49' class='collapse'>
<td colspan=4>
<table class='table'>
...
So it has the target and id tags populated from the DB.
As stated by #johansenja, starting the div id with character not integer resolved the issue.
<?php session_start();
require_once('SessionSet.php');
require_once('connection.php');
include('top.php');
if(isset($_GET['ClassID']) && isset($_GET['SectionId']) )
{
$ClassID = $_GET['ClassID'];
$SectionId = $_GET['SectionId'];
$ClassName = $_GET['ClassName'];
$SectionName = $_GET['SectionName'];
$GetCurrentMonth = date('M');
/* select latest Academic Year*/
$GetAcademicQ = "select * from study_year order by StudyYearId desc limit 1";
$GetAcademicQR = mysqli_query($con,$GetAcademicQ);
$GetAcademicRow = mysqli_fetch_assoc($GetAcademicQR);
$AcademciyearId = $GetAcademicRow['StudyYearId'];
$YearName = $GetAcademicRow['YearName'];
/* Get Students and Students Class + Fee Records */
$GetStudentClassQ = "select * from studentclass where
AcademicYearId='$AcademciyearId' and StudentClassId='$ClassID'
and StudentSectionId='$SectionId';";
$GetStudentClassQR = mysqli_query($con,$GetStudentClassQ);
$GetStudentClassNum = mysqli_num_rows($GetStudentClassQR);
if($GetStudentClassNum>0)
{
while($GetStudentClassRow = mysqli_fetch_assoc($GetStudentClassQR))
{
$StudentID = $GetStudentClassRow['StudentID'];
$RollNumber = $GetStudentClassRow['RollNumber'];
$RollNumber = $GetStudentClassRow['RollNumber'];
$StuentClassFee = $GetStudentClassRow['StuentClassFee'];
/* Get Stduent Name and bio data */
$GetStudentQ = "select * from students where Student_ID='$StudentID';";
$GetStudentQR = mysqli_query($con,$GetStudentQ);
$GetStudentRow = mysqli_fetch_assoc($GetStudentQR);
$Name = $GetStudentRow['Name'];
$FatherName = $GetStudentRow['FatherName'];
$StudentPhoto = $GetStudentRow['StudentPhoto'];
$Student_ID = $GetStudentRow['Student_ID'];
/* Get Stduent Name and bio data */
$GetfeeQ = "select * from fee where FeeStudentID='$StudentID';";
$GetfeeQR = mysqli_query($con,$GetfeeQ);
$GetfeeRow = mysqli_fetch_assoc($GetfeeQR);
$FeeAmount = $GetfeeRow['FeeAmount'];
$FeePaid = $GetfeeRow['FeePaid'];
?>
<div id="page-wrapper">
<div class="container-fluid">
<div class="row">
<table class="table table-hover table-bordered print-table" style="width:100% !important" align="center">
<!--Office Copy-->
<tr class="warning">
<th>Student ID</th>
<td>
<?php echo $Student_ID;?>
</td>
<th>Class</th>
<td>
<?php echo $ClassName;?>
</td>
<th>Section Name</th>
<td>
<?php echo $SectionName;?>
</td>
<th>Roll Number</th>
<td>
<?php echo $RollNumber;?>
</td>
<th>Academic Year </th>
<td>
<?php echo $YearName;?>
</td>
<!--td rowspan="5" style="text-align:center"><img src="StudentImages/<?php/* echo $StudentPhoto;*/?>"/ alt="Stdudent Image not found" style="width:150px; height:200px"></td-->
</tr>
<tr class="warning">
<th>Student Name</th>
<td colspan="4">
<?php echo $Name;?>
</td>
<th>Father Name</th>
<td colspan="4">
<?php echo $FatherName;?>
</td>
</tr>
<tr class="warning">
<th>Fee Month </th>
<td>
<?php echo $GetCurrentMonth;?>
</td>
<th>Fee Amount</th>
<td style="font-size:20px;">
<?php echo $StuentClassFee;?>
</td>
<th>Previous Dues</th>
<td style="font-size:20px;">
<?php echo $FeeAmount-$FeePaid;?>
</td>
<th>Due Date</th>
<td>12 -
<?php echo $GetCurrentMonth;?>
</td>
<th>After Due Date</th>
<td>
<?php echo $StuentClassFee+50;?>
</td>
</tr>
<hr>
<!--Student Copy-->
</table>
<table class="table table-hover table-bordered print-table" style="width:100% !important" align="center" >
<tr class="warning">
<th>Student ID</th>
<td>
<?php echo $Student_ID;?>
</td>
<th>Class</th>
<td>
<?php echo $ClassName;?>
</td>
<th>Section Name</th>
<td>
<?php echo $SectionName;?>
</td>
<th>Roll Number</th>
<td>
<?php echo $RollNumber;?>
</td>
<th>Academic Year </th>
<td>
<?php echo $YearName;?>
</td>
<!--td rowspan="5" style="text-align:center"><img src="StudentImages/<?php/* echo $StudentPhoto;*/?>"/ alt="Stdudent Image not found" style="width:150px; height:200px"></td-->
</tr>
<tr class="warning">
<th>Student Name</th>
<td>
<?php echo $Name;?>
</td>
<th>Father Name</th>
<td>
<?php echo $FatherName;?>
</td>
<th>Fee Month </th>
<td>
<?php echo $GetCurrentMonth;?>
</td>
<th>Fee Amount</th>
<td style="font-size:20px;">
<?php echo $StuentClassFee;?>
</td>
<th>Previous Dues</th>
<td style="font-size:20px;">
<?php echo $FeeAmount-$FeePaid;?>
</td>
</tr>
</table>
</div>
<!-- row end here -->
</div>
</div>
<!-- page-wrapper end here -->
<?php
}
}
else
{
}
?>
<?php
}
?>
i am building a php school management application. when I try to print report after pressing ctrl+p one recored is being shown on each page. but i want to show atleast 3 records on a single page after giving printing command. I have attached snapshots of records before and after print command.
enter image description here
here is picture after giving print command
enter image description here
Your question has nothing to do with PHP, this is a question about CSS, specifically print styles.
In the absence of an example of plain HTML and CSS, take a look at the CSS properties page-break-before, page-break-after and page-break-inside. In this case you may want to look at something like:
#media print {
.row, table {
page-break-before: avoid;
page-break-after: avoid;
}
}
Learn a little bit more about the page-break-* properties at this CSS Tricks article. If you are generally new to CSS print styles, I wrote a primer for .NET magazine.
Bear in mind that whatever styles you use, these are only suggestions to the browser. Paper size, page orientation, font size, zoom level, user margins, etc. will all work together to mess with your plans. Content that you force to be too wide for the page may also be an issue.
Finally, don't use any inline styles. Use your CSS file for that (so get rid of that width:100% inline style I saw.
If you want more help, post the raw HTML output and your CSS.
Hello i just create my support system and i get ticket detalis with echo but it show all td line as picture i need to show only the first line
my code
<table cellpadding="0" cellspacing="0" border="0" class="data">
<thead>
<tr>
<th width="115"><p2>Ticket ID</p2></th>
<th width="90"><p2>Status</p2></th>
<th width="160"><p2>Ticket Topic</p2></th>
<th width="160"><p2>Client</p2></th>
</tr>
</thead>
<tr> <?php
echo "<td><a href='?page=ticket&id=".$row[id]."'</a>#".$row[id]."</td>";
echo "<td>".$row[status]."</td>";
echo "<td>".$row[naslov]."</td>";
$userr = mysql_query('SELECT * FROM client WHERE clientid='.$row["user_id"].'');
$useri = mysql_fetch_array($userr);
echo "<td><a href='clientsummary.php?id=".$row[user_id]."'</a>".$useri['firstname']." ".$useri['lastname']."</td>";
?>
</tr>
you need to move your table header outside the loop. without seeing the mechanics of the loop, I'm guessing it will need to look similar to this:
<table cellpadding="0" cellspacing="0" border="0" class="data">
<thead>
<tr>
<th width="115"><p2>Ticket ID</p2></th>
<th width="90"><p2>Status</p2></th>
<th width="160"><p2>Ticket Topic</p2></th>
<th width="160"><p2>Client</p2></th>
</tr>
</thead>
<tbody>
<?php include 'missing.query.on.other.script.php';
while ($row = mysql_fetch_array($whatever_resource)){
?>
<tr> <?php
echo "<td><a href='?page=ticket&id=".$row[id]."'</a>#".$row[id]."</td>";
echo "<td>".$row[status]."</td>";
echo "<td>".$row[naslov]."</td>";
$userr = mysql_query('SELECT * FROM client WHERE clientid='.$row["user_id"].'');
$useri = mysql_fetch_array($userr);
echo "<td><a href='clientsummary.php?id=".$row[user_id]."'</a>".$useri['firstname']." ".$useri['lastname']."</td>";
?>
</tr>
<?php } // end while ?>
</tbody>
</table>
I got this in my heredoc in my TCPDF.
I basically want to create a dynamic pdf with the data of my database.
$html = <<<EOD
<table border="1">
<thead>
<tr>
<th>firstname</th>
<th>lastname<th>
</tr>
</thead>
<tbody>
<tr>
<th></th>
<th></th>
</tr>
</tbody>
</table>
EOD;
I want to make this dynamic like this, to create the data from my database dynamically.
<?php
foreach($result_set as $result) {
?>
<tr>
<td>
<?php echo $result['firstname']; ?>
</td>
<td>
<?php echo $result['lastname']; ?>
</td>
</tr>
<?php
}
?>
I tried this so far but I cannot find a suitable solution:
$html = <<<EOD
<table border="1">
<thead>
<tr>
<th>Vorname</th>
<th>Nachname</th>
<th>Von</th>
<th>Bis</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<?php echo $result['firstname']; ?>
</td>
<td>
<?php echo $result['lastname']; ?>
</td>
</tr>
</tbody>
</table>
EOD;
can anyone help please.
Ok I somehow did it, but still if there is any better solution feel free to post:)
Code:
$loopHereFirstname = '';
$loopHereLastname = '';
foreach($result_set_random_01 as $result_dish_usr_01) {
$tr_start = '<tr>';
$tr_end = '</tr>';
$td_start = '<td>';
$td_end = '</td>';
$loopHereFirstname .= $result_dish_usr_01['firstname']."\n";
$loopHereLastname .= $result_dish_usr_01['lastname']."\n";
}
$html = <<<EOD
<table border="1">
<thead>
<tr>
<th>firstname</th>
<th>lastname</th>
</tr>
</thead>
<tbody>
$tr_start
$td_start
$loopHereFirstname
$td_end
$td_start
$loopHereLastname
$td_end
$tr_end
</tbody>
</table>
EOD;
You've to break your code into two part if you want to use a loop with <<
<?php
$html =<<<EOD
<table border="1">
<thead>
<tr>
<th>Vorname</th>
<th>Nachname</th>
<th>Von</th>
<th>Bis</th>
</tr>
</thead>
<tbody>
EOD;
foreach($result_set as $result) {
$html.=<<<EOD
<tr>
<td>
{$result['firstname']}
</td>
<td>
{$result['lastname']}
</td>
</tr>
EOD;
}
$html .= '</tbody></table>';
I'm working on a php/mysql application and need to make the output of one column, one row an html link to another html page. Have not been able to find any relavant information. The "" needs to be the link. Thanks for any help.
<table id="display" style="width:800px;">
<tr>
<th width="40">ID</th>
<th width="70">Last</th>
<th width="70">First</th>
<th width="10">Middle</th>
<th width="70">Birth</th>
<th width="70">Death</th>
<th width="170">Notes</th>
<th width="100">Cemetery</th>
</tr>
<?
while($objResult = mysql_fetch_array($objQuery))
{
?>
<tr>
<td style='text-align:center;'><?=$objResult["id"];?></td>
<td style='text-align:center;'><?=$objResult["last"];?></td>
<td style='text-align:center;'><?=$objResult["first"];?></td>
<td style='text-align:center;'><?=$objResult["middle"];?></td>
<td style='text-align:center;'><?=$objResult["birth"];?></td>
<td style='text-align:center;'><?=$objResult["death"];?></td>
<td><?=$objResult["notes"];?></td>
<td style='text-align:center;'><?=$objResult["cemetery"];?></td>
</tr>
<?
}
?>
</table>