Layout problems (php,html) - php

I made some images which i need, currently i have :
$output .= "
<tr>
<td align='center'><b>{$name}</b></td> </tr>
<tr>
<td align='center'><img src='$avatar'/></td> </tr>
<td align='center'><b>Points</b>: {$points}</td> </tr>
<tr>
<td align='center'><b>Status</b>:<b><font color='green'> {$misc['text_status']}</font></b></td> </tr>
<tr>
<td align='center'><a href='".$link."'><font color='red'><b>See more statistics</b></font></a><hr></td></tr>
";
with script i get this(ie image) http://img717.imageshack.us/img717/7885/thisdn.png .
Now i need to output something like this http://img703.imageshack.us/img703/171/thatq.png (ie image) without mysql. May i have some examples of yours?

move <tr> before your for loop and </tr> after you for loop
or better one, place individual tables with float:left for each member

You could try to wrap every profile information (photo, points etc) in a div and not use tables at all. Then float these div-s to the right or left. Note that every div must have the same class.

Related

TCPDF not printing table rows containing colspan?

I am trying to print this table in TCPDF, the table is rendering fine but it is totally skipping the <tr> row with colspan , this happens to the only row that has the first <td colspan="8"> cell with a colspan.
This is the html table tha:
<table style="font-size:7px;line-height:16px;border:none;" dir="ltr" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="width:17%;"></td>
<td>YTD</td>
<td>2019</td>
<td>2018</td>
<td>2017</td>
<td>2016</td>
<td>2015</td>
<td>2014</td>
</tr>
<tr>
<td>Portfolio</td>
<td>-3.63%</td>
<td>14.51%</td>
<td>-5.11%</td>
<td>11.16%</td>
<td>8.48%</td>
<td>-2.13%</td>
<td>2.45%</td>
</tr>
<tr>
<td>Benchmark </td>
<td>-1.64%</td>
<td>9.78%</td>
<td>-3.84%</td>
<td>7.37%</td>
<td>2.92%</td>
<td>-2.66%</td>
<td>0.08%</td>
</tr>
<tr>
<td colspan="8">Morningstar USD Cautious Allocation</td>
</tr>
<tr>
<td></td>
<td>
<p class="double-line">Annualised Return</p>
</td>
<td>
<p class="double-line">Standard Deviation</p>
</td>
<td>
<p class="double-line">Sharpe Ratio</p>
</td>
<td colspan="4"></td>
</tr>
<tr>
<td>Portfolio</td>
<td>4.45%</td>
<td>5.72%</td>
<td>0.78</td>
<td colspan="4"></td>
</tr>
<tr>
<td>Benchmark </td>
<td>2.08%</td>
<td>2.44%</td>
<td>0.85</td>
<td colspan="4"></td>
</tr>
</tbody>
</table>
output on the browser page is fine (see image)
but output on the PDF removes that row completely:
The issue is solved, the problem was not in TCPDF, It was the table not having a proper closing tag for the row </tr> . The table above was coming from a custom field storing it in the DB of a wordpress site. Since the html is generated through a php code I had minor coding error that I forgot to close the row with </tr>. However when viewing the html content in a wordpress WYSWIG editor , it adds the self closing tags. When you debugging it on the browser page also most browsers add auto closing tags. These made me think that the html structure of the table is good and should be an issue with TCPDF. After checking the HTML in the database I finally figured out the table row wasn't closing properly.
Hopefully this will help someone having a similar issue in the future.

Jquery change table cell value if other cell contains word

I have a basic table and need to change a word if one of the other cells in that row contains a word.
<table>
<tr class="veh-row">
<td class="vehicle_desc">RED CAR</td>
<td>4000 miles</td>
<td class="veh-trans">Manual</td>
<td>Petrol</td>
</tr>
<tr class="veh-row">
<td class="vehicle_desc">RED CAR</td>
<td>4000 miles</td>
<td class="veh-trans">Manual</td>
<td>Petrol</td>
</tr>
<tr class="veh-row">
<td class="vehicle_desc">RED CAR AUTO</td>
<td>4000 miles</td>
<td class="veh-trans">Manual</td>
<td>Petrol</td>
</tr>
</table>
So I need if td.vehicle_desc contains the word AUTO then Manual will change to Automatic in td.veh-trans. How can I do this and only effect that row and not all other rows?
You can use :contains
$('td.vehicle_desc:contains(AUTO)').siblings('.veh-trans').text('Automatic')

simple_html_dom get an input with a partial id value

Im trying to get td fields from a table with the id sid-120390923 or sid-38737122 ignoring any other id value in the table, however the problem is that I can not get these td fields because they all have a slightly different id but with the same start ('sid').
what I want is to be able to grab all the td fields with the starting id sid-, would there be a way to incorporate regex?
here is an example
html
<table>
<tr>
<td id='9sd'></td>
<td id='10sd'></td>
<td id='sid-1239812983'></td>
<td id='sid-1454345345'></td>
<td id='sid-2342345234'></td>
<td id='sid-5656433455'></td>
<td id='sid-1231235664'></td>
<td id='sid-8986757575'></td>
<td id='sid-1232134551'></td>
</tr>
</table>
simple_html_dom
$table = $con->find('table');
foreach($table->find('td#sid-1232134551') as $field){
echo $field."<br>";
}
You can use attribute filters (the 5. tab),
$table->find('td[id^=sid-]');

PHP mySQL - How do i print only different attributes of two things that share a common name?

I'm trying to print out a list of products on a page. This is cake so far..
However Some of my items share names but have different attributes.
Example would be like...:
product:
keyboard
keyboard
size:
25 inches
23 inches
color:
red
blue
My table looks something like this:
id, product, size, color, so on...
So my .php I'm doing my query and print from looks something like this
<div id="accordion">
<?php
$letter = $_GET['letter'];
//echo "$id";
include("database.php");
$result = mysql_query("SELECT UPPER(product) AS upperName, PRODUCTS.* FROM PRODUCTS WHERE product LIKE '$letter%' ORDER BY UPPER(product) ");
$prodName = "";
while($row = mysql_fetch_array($result))
{
if ($row['upperName'] != $prodName)
{
print('<div style="background-color:#666; padding-bottom:25px; margin-bottom:25px;">');
print ("<h1>" . "$row[product]" . "</h1>");
}
print ("$row[ndc]" . "<br />");
print ("$row[size]" . "<br />");
print ("$row[strength]" . "<br />");
print ("$row[imprint]" . "<br />");
print ("$row[form]" . "<br />");
print ("$row[color]" . "<br />");
print('</div>');
$prodName = $row['upperName'];
}
mysql_close($linkID);
?>
</div>
My problem comes from trying to style the attributes..
Do you see that /div tag?
I want to style that stuff within an accordion however that stuff repeats for each product that shares the same name in that accordion. So if i include the div there, it prints out for 3 times with the same name 3 end div tags (hence breaking all my html nooo!!)
Is there a way to maybe loop? or use some kind of conditional logic to print that top stuff, once for the product name that all the products share, then the loop and print all the different attributes, then when each attribute is finished, to then include my closing html?
So if i have 6 products and half are named "keyboard", and the other half are named "shoes"
could i get it to print out
TABLE
product name: KEYBOARD
table for all my attributes
end table for all my attributes
end TABLE
TABLE
product name: SHOES
table for all my attributes
end table for all my attributes
end TABLE
That way i can style all my attributes.
I'm really sorry if this isn't correctly explained I'm still learning.
Any help is appreciated!
Extra stuff that you may not need to figure out my problem just an example of a table i'm printing to and why the way the attributes print is a problem. the 1-2-3-4-5-6-7-8-9 are data for the attributes.
<table cellspacing="0" cellpadding="0" border="0" width="649">
<tr>
<td width="180" height="10" valign="top"></td><td width="36" height="10" valign="top"></td><td width="433" height="10" valign="top"></td>
</tr>
<tr>
<td width="180" valign="top"><img src="images/slide1.gif" width="180" height="200" border="0" /></td>
<td width="36" valign="top"></td>
<td width="433" valign="top"><table cellspacing="0" cellpadding="0" border="0" width="433">
<tr>
<td valign="top"><span class="in-table-head">Name:</span></td>
<td valign="top"><span class="in-table-name">$row[name]</span></td>
</tr>
<tr>
<td valign="top"><span class="in-table-head">Therapeutic Category:</span></td>
<td valign="top"><span class="in-table-name">$row[therapeutic]</span></td>
</tr>
<tr>
<td colspan="2" valign="top"><span class="in-table-providers">Information for Providers</span></td>
</tr>
</table></td>
</tr></table>
<table cellspacing="0" cellpadding="0" border="0" width="649">
<tr>
<td><span class="in-table-att">NDC#:</span></td>
<td><span class="in-table-att">Strength:</span></td>
<td><span class="in-table-att">Size:</span></td>
<td><span class="in-table-att">Imprint:</span></td>
<td><span class="in-table-att">Form:</span></td>
<td><span class="in-table-att">Color:</span></td>
<td><span class="in-table-att">Shape:</span></td>
<td><span class="in-table-att">Pack Size:</span></td>
<td><span class="in-table-att">Rating:</span></td>
</tr>
</table>
<table cellspacing="0" cellpadding="0" border="0" width="649">
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
<td>9</td>
</tr>
</table>
Thank you again to anyone who looks at this problem!
stop matching by name but start using sku’s as a selector. that way you’re always spot on, no matter how many keyboards you have.
set up your pages to pass the sku instead of generic name.
otherwise you need to add more criteria to your where statement like dimensions, weight, color, price etc... to get ta reliable result.
-- Update --
An example.
page.php?product_type=keyboard
<?php
// set up database
$db = mysqli_connect("localhost", "user", "pass", "database_name");
// Just using mysql escape string, you should consider adding more securty checking to prevent injection
$producttype = mysql_real_escape_string($_GET['product_type']);
$result = $db->query("SELECT * FROM `products` WHERE `products`.`type`='$producttype'");
$features["width"][]
$features["height"][]
$features["color"][]
$features["whatever"][]
while ($row = $result->fetch_assoc())
{
$features["width"][] = $row["width"];
$features["height"][] = $row["height"];
$features["color"][] = $row["color"];
$features["whatever"][] = $row["whatever"];
}
// printing the features
echo "You have selected $producttype<BR>";
echo "The following widths can be selected<BR><UL>";
foreach($features["width"] as $width)
echo "<LI>$width</lI>";
echo "</UL><P>The following heights can be selected<BR><UL>";
foreach($features["heights"] as $height)
echo "<LI>$height</lI>";
echo "</UL><P>The following colors can be selected<BR><UL>";
foreach($features["colors"] as $color)
echo "<LI>$color</lI>";
echo "</UL><P>The following whatevers can be selected<BR><UL>";
foreach($features["whatevers"] as $whatevers)
echo "<LI>$whatevers</lI>";
echo "</UL>";
echo "have a nice day";
?>

Displaying the text in the multiple lines when retrieving from database

Hi
I have a table in which my row contains the text which i retrieve from the database.But i have a small width of row and the data i retrieve is large.And the text exceeds the width of my row so i want to break the data i retrieve into multi lines inside the table row.How can i do it.
My code is here:
$list = $mfidao1->fetchMfi($_GET['id']);
//print_r($list);
//die;
if(!empty($list))
{
foreach($list as $menu)
{
?>
<tr style="border:none; background-color:#FBFBFB;" >
<td class="topv">Social Mission</td>
<td class="topm" ><div class="txt"><?php echo $menu->mfi_1_a;?></div></td>
</tr>
<tr bgcolor="#E8E8E8">
<td class="topv">Address</td>
<td class="topm"><?php echo $menu->mfi_ii_c;?></td>
</tr>
<tr bgcolor="#FBFBFB">
<td class="topv">Phone</td>
<td class="topm"><?php echo $menu->mfi_ii_e;?></td>
</tr>
<tr bgcolor="#E8E8E8">
<td class="topv">Email</td>
<td class="topm"><?php echo $menu->mfi_ii_d;?></td>
</tr>
<tr bgcolor="#FBFBFB">
<td class="topv">Year Established</td>
<td class="topm"><?php echo $menu->mfi_i_c;?></td>
</tr>
<tr bgcolor="#E8E8E8">
<td class="topv">Current Legal Status</td>
<td class="topm"><?php echo $menu->mfi_i_d;?></td>
</tr>
<tr bgcolor="#FBFBFB">
<td class="topv">Respondent</td>
<td class="topm"><?php echo $menu->mfi_ii_a;?></td>
</tr>
<?php
}
}
?>
</table>
Set width of <td>. I think this is the best way to do this rather than word_wrap().
In your css for the table, use "table-layout:fixed" - This fixes the td elements width according to the way you want.
" word-wrap: break-word; " - this breaks the text in it so that it doesnt go beyond the boundary of the box.
You need to wrap the text in your td tags. Here is a link to a similar question
You could use the function wordwrap().
It wraps a string to a given number of characters using a string break character.
you can either use the php function
php wordwrap
or styling the td with css so that it uses the word-wrap attribute
css wordwrap
Not sure if this is what you want, but sound like you could use chunk_split()

Categories