I'm generating table in a foreach loop
echo "<tr>";
echo "<td align='left' bgcolor='$bgclr'>".$monthName."</td>";
echo "<td align='center' bgcolor='$bgclr'>".$id."</td>";
echo "<td align='center' bgcolor='$bgclr'>".$total."</td>"
echo "</tr>";
I need to increase font size of the table, but i'm not sure how. Does the html table has attribute to set font size or I should use CSS ?
Just use font style css in style attribute :
echo "<tr>";
echo "<td align='left' bgcolor='$bgclr' style='font-size:10px'>".$monthName."</td>";
echo "<td align='center' bgcolor='$bgclr' style='font-size:10px'>".$id."</td>";
echo "<td align='center' bgcolor='$bgclr' style='font-size:10px'>".$total."</td>"
echo "</tr>";
use the html styling on the echoed elements. For example echo '<table style="font-size: 100px">';
You need to define font size in one variable and then use in inline as below code:
foreach{
$fontsize = 'font-size: '.((isset(FONT_SIZE_IN_FOREACH))?FONT_SIZE_IN_FOREACH:12);
echo "<tr>";
echo "<td align='left' bgcolor='$bgclr' style='$fontsize'>".$monthName."</td>";
echo "<td align='center' bgcolor='$bgclr'>".$id."</td>";
echo "<td align='center' bgcolor='$bgclr'>".$total."</td>"
echo "</tr>";
}
You can add class to the table and write css for that class.
HTML:
<table class='fontsize'>
</table>
CSS:
.fontsize {
font-size:16px;
}
Related
I want to sum all numbers in the same div class (class is dinamic variable called $events[2]) and display it on my class div result on the loop but i cant make javascript read the variable $('$events[2]') on the php
<script>
var sum = 0;
$('$events[2]').text(function(i, v) {
sum += parseFloat(v.replace(',', ''));
});
$('.result').text('Result : ' + sum);
</script>
<?php
echo "<td class='tb1'>{$events[0]}</td></div>"; //foto
echo "<td>";
echo "<div class='w_promotora_images'>{$events[7]}</td></div>"; //foto
echo "<td>";
echo "<div class='w_promotora_images'>{$events[3]}</td></div>"; //data
echo "<td class=''>{$events[2]}</td>"; //nome
echo "<td class=' tb1'>{$events[4]}</td>"; //evento
echo "<td class=' tb1'>{$events[5]}</td>"; //horario
echo "<td class=' tb1'>{$events[6]}</td>"; //obs
echo "<td class=' tb1'>{$events[10]}</td>"; //horas
echo "<td class=' tb1'>{$events[9]}</td>"; //valor hora
echo "<td class=' tb1'>{$events[1]}</td>"; //Props
echo "<td ><div class='{$events[2]}'> {$events[8]}</td></div>"; //t parcial
echo "<td class=''><div class='result'> </div> </td></tr>";
}?>
</table>
If your variable is in php, javascript will not be able to parse it. You must output the var in php :
$('.<?= $events[2] ?>').text(function(i, v) {
sum += parseFloat(v.replace(',', ''));
});
I also add the "." for if you don't add it, jquery will not know that you are fetching an element by its class name.
This code is not passing URL to make topic clickable main problem is in third line after while loop. I got this error :
Parse error: syntax error, unexpected 'id' (T_STRING), expecting ',' or ';' in D:\xmapp\htdocs\forum\main_forum.php on line 37
Code :
while($rows=mysql_fetch_array($result))
{
echo "<tr>";
echo "<td align='center' bgcolor=#FFFFFF>",$rows['id'],"</td>";
echo "<td bgcolor='#FFFFFF'>",'$rows['topic']. ',"</td>";
echo "<td align='center' bgcolor='#FFFFFF'>",$rows['view'],"</td>";
echo "<td align='center' bgcolor='#FFFFFF'>",$rows['reply'],"</td>";
echo "<td align='center' bgcolor='#FFFFFF'>",$rows['datetime'],"</td>";
}
Please try this. there is syntax error in your code.
echo "<tr>";
echo "<td align='center' bgcolor=#FFFFFF>",$rows['id'],"</td>";
echo "<td bgcolor='#FFFFFF'>",''.$rows[topic]. ' ',"</td>";
echo "<td align='center' bgcolor='#FFFFFF'>",$rows['view'],"</td>";
echo "<td align='center' bgcolor='#FFFFFF'>",$rows['reply'],"</td>";
echo "<td align='center' bgcolor='#FFFFFF'>",$rows['datetime'],"</td>";
This should correct your problem, Use
echo "<td bgcolor='#FFFFFF'><a href='".$view_topic.".php?id=".$rows['id']."'>".$rows['topic']."</a></td>";
instead of
echo "<td bgcolor='#FFFFFF'>",'$rows['topic']. ',"</td>";
One more thing, Why dont you use php tag only when needed. If you do like this it will be clean and easy.
<?php
while($rows=mysql_fetch_array($result))
{
?>
<tr>
<td> <?php $rows['topic']; ?> </td>
.......
.......
</tr>
<?php } ?>
Try this :
while($rows = mysql_fetch_array($result)){
echo "<tr>";
echo "<td align='center' bgcolor=#FFFFFF>".$rows['id']."</td>";
echo "<td bgcolor='#FFFFFF'><a href='".$view_topic.".php?id=".$rows['id']."'>".$rows['topic']."</a></td>";
echo "<td align='center' bgcolor='#FFFFFF'>".$rows['view']."</td>";
echo "<td align='center' bgcolor='#FFFFFF'>".$rows['reply']."</td>";
echo "<td align='center' bgcolor='#FFFFFF'>".$rows['datetime']."</td>";
}
I want to pass php value as parameter in anchor hreh.Here i have the problem while fetching the 'c_id'.c_id is the primary key.
Here I attached my html code and php code
<?php
include "config.php";
$sql="select c_name from client order by c_name asc limit 10";
$sql1=mysql_query($sql);
echo "<table border='1' align=center width=500 style='border-collapse: collapse;'>";
echo "<tr height =10><td width=300 align=center><b>Client name</b></td><td colspan=2 align=center><b>Action</b></td></tr>";
while($fet=mysql_fetch_assoc($sql1))
{
$id=$fet['c_id'];
echo "<tr>";
echo "<td align=center width=100>".$fet["c_name"]."</td>";
echo "<td align=center width=100><a href='client_details.php?id=".echo $id."'>Edit</a></td><td><a href=''>Delete</a></td>";
echo "</tr>";
echo "</table><br>";
}
?>
Just change:
echo "<td align=center width=100><a href='client_details.php?id=".echo $id."'>Edit</a></td><td><a href=''>Delete</a></td>";
To:
echo "<td align=center width=100><a href='client_details.php?id=".$id."'>Edit</a></td><td><a href=''>Delete</a></td>";
Because you already used the echo. You can't use echo inside another echo.
Try this, I hope It works for you
Read more
I am working with a php document that has tables as well as an image, the way its set up is I have a table with 3 columns, two with text and one with a picture. The problem that I am running into is that the images are all different sizes which cause my text lines to cause spacing in between them, is there a way to format the text to retain its original formatting? Here is an example of what I am talking about http://www.cnghl.biz/cnghldb/test.php?PlayerID=2818
Here is the CSS
<style>
a {text-decoration:none;}
}
td {
vertical-align: top;
}
td img {
vertical-align: top;
}
.space {
line-height: .3 em;
}
.wrap {
float:right;
}
</style>
And here is the PHP
Echo "<td width='659'><div align='center'>";
Echo "<table width='602' border='0'>";
Echo "<tr>";
Echo "<td colspan='3'><h1>".$row['FirstName']." ".$row['LastName']."</h1> </td>";
Echo "</tr>";
Echo "<tr>";
Echo "<td width='164'><strong>Birthdate:</strong>".$row['DOB']."</td>";
$DOB = $row[DOB]; //dd.mm.yyyy
$user_date = new DateTime($DOB);
$curr_date = new DateTime();
$age_cal = $curr_date->diff($user_date);
Echo "<td width='219'><strong>Age:</strong>".$age_cal->y;"</td>";
Echo "<td width='205' rowspan='6'><div align='center'><img src=\"http://www.cnghl.biz/cnghldb/images/".$iPlayerID.".jpg\">";
Echo "</tr>";
Echo "<tr>";
Echo "<td><strong>Nation:</strong>".$row['Nation']."</td>";
Echo "<td><strong>CNGHL Team:</strong>".$row['CNGHLRights']. "</td>";
Echo "</tr>";
Echo "<tr>";
Echo "<td><strong>Position:</strong>".$row['Position']. "</td>";
Echo "<td><strong>Weight:</strong>".$row['Weight']. "</td>";
Echo "</tr>";
Echo "<tr>";
Echo "<td><strong>Height:</strong>".$row['Height']. "</td>";
Echo "<td><strong>NHL Team:</strong>".$row['Team']. "</td>";
Echo "</tr>";
Echo "<tr>";
Echo "<td><strong>Draft Year:</strong>".$row['CNDraftYR']."</td>";
Echo "<td><strong>Draft Position:</strong>".$row['CNDraftPOS']."</td>";
Echo "</tr>";
Echo "<tr>";
Echo "<td height='25'><strong>Drafted By:</strong>".$row['DrTeam']."</td>";
Echo "<td><strong>Current Salary:</strong></td>";
Echo "</tr>";
Echo "</table>";
Echo "</div></td>";
Echo "<td width='141'> </td>";
Echo "</tr>";
Echo "</table>";
Echo "</div>";
I have tried to adjust the size of the image but that does not solve the problem, any help would be greatly appreciated.
Definitely do not use tables for layout purposes. By the way, this is the expected behavior of HTML tables, stretching their size to the content.
You can achieve this using divs, both solving your problem and having a more semantic markup, and having a cleaner markup.
I would also suggest you wrap your player's data into a Definition list (dl element) for a more semantic approach.
Example implementation
If the problem is the images being different sizes, you could give each image a specific width. Or if you don't want to adjust the images themselves, give the div/td that the image is in a specific width and height that is equal to the largest image and doesn't change.
Your rowspan is set to 6 but you have 7 <tr> in your table. The td { vertical-align: top; } is what you need for your CSS.
T have one page on which results are get created dynamically. And I
want to display popup window on clicking image named view.jpg. The
image is hyperlink. So please tell me how should i do it. I am showing
my code as follows.
code :
echo "<table width='' height='' border='1' align='center'>
<tr><td>Title</td>
<td >Type</td>
<td >Date</td>
<td>Expiry Date</td>";
if($typeofuser=='admin' || $typeofuser=='Accountant' || $typeofuser=='secretary')
{
echo "<td>View</td>
<td>Edit</td>
<td>Delete</td>";
}
echo "</tr>";
$qry2 = mysqli_query($con,"SELECT nId,nTitle,nDescription,nDate,nExpiryDate FROM tblnoticemanager where Society_id = '$socId' and category='General'") or die(mysqli_error($con));
while($NoticeData = mysqli_fetch_array($qry2))
{
echo "<tr>";
echo "<td align='center' class='tdletter' style='text-transform:capitalize;'>" .$NoticeData['nTitle']. "</td>";
echo "<td align='center' class='tdletter' ><div class='overflowDiv'>" . $NoticeData['nDescription']."</div></td>";
echo "<td align='center' class='tdletter'>" . $NoticeData['nDate'] ."</td>";
echo "<td align='center' class='tdletter'>" . $NoticeData['nExpiryDate'] ."</td>";
if($typeofuser=='admin' || $typeofuser=='Accountant' || $typeofuser=='secretary')
{
echo "<td align='center' class='tdletter'><div><a href='?id=".urlencode(base64_encode($NoticeData['nId']))."'><img src='images/view.png' width='30' height='30' align='center' /></a></div></td>";
echo "<td align='center' class='tdletter'><div><a href='?id=".urlencode(base64_encode($NoticeData['nId']))."' ><img src='images/edit.jpg' width='30' height='30' align='center'/></a></div></td>";
echo "<td align='center' class='tdletter'><span id='".$NoticeData['nId']."' class='trash'><img src='images/delete1.jpg' width='30' height='30' align='center' /></span></td>";
}
echo "</tr>";
}
echo "</table>";
You can use attribute selector [attribute='value']
$("[src='images/view.png']").click(function(){
alert("clicked");
});