Windows live mail places all tables in 1 row, instead beneath eachother - php

Edit: Added example below.
I have the following code (simplified for example) which I send as newsletter:
<table width="700">
<tr>
<td width="700"><!-- Really trying to set 700 as max) -->
<table width="700"> <!-- simple table content, not bigger than 700 --></table>
<table width="350"> <!-- simple table content, not bigger than 350 --></table>
<table width="350"> <!-- simple table content, not bigger than 350 --></table>
</td>
</tr>
</table>
Expected result:
[------ table 700 ------]
[ table 350 ][ table 350 ]
Result in Windows Live Mail: (working fine in Mac's Mail)
[------ table 700 ------][ table 350 ][ table 350 ]
It's all in 1 row, though the wrapping TD and table are set to 700, I'm expected it starting on new lines.
I can not add breaks, this is dynamic code, I have more parts, and I dont know in the code which is the last of a line.
I can't find topics about this, other than "start sending mails, with tables"-novice solutions.
Anyone got a clue?

The problem/solution is using align="left". Any table with align=left will have the next table stuck to it. Example of prefered result:
[---- 100 ----]
[--50--][--50--]
[25][25][25][25]
If all those tables have align="left", it would result in one long line:
[---- 100 ----][--50--][--50--][25][25][25][25]
I removed the align=left from the first table, which results like this:
[---- 100 ----]
[--50--][--50--][25][25][25][25]
I can'r remove the align=left from the other tables, because I want those inline-block. In order to get them properly, I added a 'split' in my code. The split-table is a table without the align=left and no height. All tables haves align=left, apart from the split:
[---- 100 ----](split)
[--50--][--50--](split)
[25][25][25][25]

Add style="display:block;" to your top table.
However you'd be better off putting them into their own <td>'s instead of float/aligning them there.
Like this:
<table width="700" border="0" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#eeeeee">
...
</td>
</tr>
<tr>
<td>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="350" bgcolor="#cccccc">
...
</td>
<td width="350" bgcolor="#dddddd">
...
</td>
</tr>
</table>
</td>
</tr>
</table>
Here is a similar question/answer here that explains another issue you'd likely face with aligning tables like you have.
If you are trying to go responsive, you can use <td>'s with display:block; instead to make them 'pop' down when the media query triggers. Example here

Related

How to create a table using smarty/PHP?

I've been working on this all day and have tried every possible solution I could find but nothing seems to be working. Here's a copy of my code (using Smarty template system):
<tr><td style="border-top: none;">
<table>
<tr><th colspan="7">TITLE OF THE TABLE</th></tr>
{foreach from=$data.history item=tmp name=item}
<tr><td colspan="1" class='{cycle name=color values="odd,even"}'>{$tmp->history}</td></tr>
{/foreach}
</table>
</td><tr>
If you looks in the foreach statement you'll see that I'm trying to create a new td for each piece of information. This is actually working. However, the problem is that it's not spanning them in the table like I want it to do.
I want each td to have its own column and for there to be a maximum of 7 columns. As of right now, there's only one column showing and every is just split between rows.
Ideally, I want there to be 7 columns per row, even if some of them have to be empty because there's not enough data to pull. Is there any way to do this?
I think you are missing a final </tr>
<tr><td style="border-top: none;">
<table>
<tr><th colspan="7">TITLE OF THE TABLE</th></tr>
{foreach from=$data.history item=tmp name=item}
<tr><td colspan="1" class='{cycle name=color values="odd,even"}'>{$tmp->history}</td></tr>
{/foreach}
</table>
</td><tr>
^^^ ------------> should be </tr>

Pull data from a webpage to use [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
To give some background, I sell Lego parts online. The order total when you place the order is based on the price of the parts you purchased, and the shipping costs.
Shipping costs vary depending on the weight of the order, and the country of shipment.
I am not a techie buff, and thats why I need some help. I know the basics, but not much else, though I'd love to learn and I've been trying around with this for days before coming here.
The source code of an order page, the only place where you can see the weight is this:
<FONT CLASS="fv">Estimated Weight of Order:</FONT></TD><TD ALIGN="RIGHT"><FONT CLASS="fv">2.17oz 61.44g</FONT>
It is the same for every single order.
So, I know where the data I want is.
What I need help with is, coding something that pulls the data out of this webpage (say it's inside a webpage called order.com/order.asp and the document contains a bunch of other data apart from the weight) and exporting a shipping price based on the weight it inputed. I don't know whether you can do this with PHP or Python, etc.
I would have on my server a... say a table with the shipping costs based on weight. Now, what I needed, would be to take that bit of data from the order.com website into my own server. (On my own server process the weight data that I took, match it with the shipping cost, pull out invoices, etc). The weight data is in the order page, always on a line like the one I posted on the question. I just read about web scraping. Maybe some PHP that looks into the order page till it finds the line with the weight, and pulls out the weight?
Many, many, many thanks for your help, and I apologize in advance if I sound too uninformed, which I am. I really need a detailed explanation.
Gerald
*TL;DR*Two webpages. One is in my server and one isn't. The one that isn't in my server (order.asp), has this line:
<FONT CLASS="fv">Estimated Weight of Order:</FONT></TD><TD ALIGN="RIGHT"><FONT CLASS="fv">XX.XXoz XX.XXg</FONT>
I need something that I can put in my server, queries the weight from the page that isn't on my server (order.asp page) and matches the weight with a shipping price that I would have on my page (as a table or maybe with ifs).
There will be different order pages (order1.asp order2.asp order3.asp) with different weights. The script or whatever should do that for ea. wpage.
Thanks.
This would be the source code of an example page that I would need to take the weight of. Removed some sensitive info.
<SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript">
function killImage(imgName){
if (document.images){
document.images[imgName].src="/images/noImage.gif"
}
}
function killImageM(imgName){
if (document.images){
document.images[imgName].src="/images/noImageM.gif"
}
}
</SCRIPT>
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<META HTTP-EQUIV="IMAGETOOLBAR" CONTENT="NO">
<LINK REL="STYLESHEET" TYPE="text/css" HREF="/stylesheet.css?13">
<STYLE TYPE="text/css">body { margin: 15 auto; }</STYLE>
<SCRIPT TYPE="text/javascript" LANGUAGE="javascript" SRC="/js/getAjax.js"></SCRIPT>
<SCRIPT TYPE="text/javascript" LANGUAGE="javascript" SRC="/lytebox/lytebox.js?10"></SCRIPT>
<LINK REL="STYLESHEET" HREF="/lytebox/lytebox.css?13" TYPE="text/css" MEDIA="screen" />
</HEAD>
<BODY BGCOLOR="#666666">
<CENTER>
<TABLE WIDTH="680" CELLPADDING="10" CELLSPACING="0"><TR><TD BGCOLOR="#FFFFFF">
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0"><TR>
<TD><IMG SRC="/images/logowhite.gif" WIDTH="200" HEIGHT="60" ALIGN="ABSMIDDLE" BORDER="0"> </TD>
<TD> <FONT SIZE="+3">Order #3953198</FONT></TD></TR></TABLE><P><FONT FACE="Tahoma,Arial" SIZE="2">
<HR NOSHADE SIZE="1" COLOR="#000000"><B>Order Summary</B><HR NOSHADE SIZE="1" COLOR="#000000">
<TABLE WIDTH="100%" CELLPADDING="5" CELLSPACING="0" BORDER="0" BGCOLOR="#EEEEEE"><TR><TD WIDTH="60%" VALIGN="TOP">
<TABLE WIDTH="100%" BORDER="0" CELLPADDING="1" CELLSPACING="0" CLASS="ta">
<TR>
<TD WIDTH="125">Order Date:</TD>
<TD>Nov 20, 2013 17:12</TD>
</TR>
<TR>
<TD>Payment By:</TD>
<TD>PayPal.com</TD>
</TR>
<TR>
<TD>Payment In:</TD>
<TD>Euro</TD>
</TR>
<TR VALIGN="TOP">
<TD>Order Status:</TD>
<TD>Shipped</TD>
</TR>
<TR>
<TD>Changed:</TD>
<TD>Nov 22, 2013 14:15</TD>
</TR>
<TR>
<TD NOWRAP>Total Items:</TD>
<TD>24</TD>
</TR>
<TR>
<TD NOWRAP>Unique Items (Lots):</TD>
<TD>2</TD>
</TR>
<TR>
<TD NOWRAP>Invoiced:</TD>
<TD>Nov 21, 2013 08:56</TD>
</TR>
<TR VALIGN="TOP">
<TD NOWRAP>Shipping Method:</TD>
<TD>Registered<BR><FONT CLASS="fv">By default, with tracking number and insured up to 30 euros only.</FONT></TD>
</TR>
</TABLE>
</TD><TD WIDTH="40%" VALIGN="TOP">
<TABLE WIDTH="100%" BORDER="0" CELLPADDING="1" CELLSPACING="0" CLASS="ta">
<TR>
<TD>Order Total:</TD>
<TD ALIGN="RIGHT">EUR 8.92</TD>
</TR>
<TR>
<TD>Shipping:</TD>
<TD ALIGN="RIGHT">EUR 4.85</TD>
</TR>
<TR>
<TD>Insurance:</TD>
<TD ALIGN="RIGHT">EUR 0.00</TD>
</TR>
<TR>
<TD>Additional Charges 1:</TD>
<TD ALIGN="RIGHT">EUR 0.00</TD>
</TR>
<TR>
<TD>Additional Charges 2:</TD>
<TD ALIGN="RIGHT">EUR 0.00</TD>
</TR>
<TR>
<TD>Credit:</TD>
<TD ALIGN="RIGHT">EUR 0.00</TD>
</TR>
<TR>
<TD>Grand Total:</TD>
<TD ALIGN="RIGHT"><B>EUR 13.77</TD>
</TR>
<TR>
<TD>Orders in this Store:</TD>
<TD ALIGN="RIGHT">1</TD>
</TR>
</TABLE>
</TD></TR>
</TABLE><HR NOSHADE SIZE="1" COLOR="#000000"><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" WIDTH="100%" CLASS="ta"><TR><TD><B>Items in Order</B></TD></TR></TABLE><HR NOSHADE SIZE="1" COLOR="#000000"><TABLE WIDTH="100%" BORDER="0" CELLSPACING="1" CELLPADDING="3" CLASS="ta"><TR BGCOLOR="#C0C0C0"><TD><B>Image</B></TD><TD ALIGN="CENTER"><B>Condition</B></TD><TD><B>Item Description</B></TD><TD ALIGN="RIGHT"><B>Lots</B></TD><TD ALIGN="RIGHT"><B>Qty</B></TD><TD ALIGN="RIGHT"><B>Left</B></TD><TD ALIGN="RIGHT"><B>Price</B></TD><TD ALIGN="RIGHT"><B>Total</B></TD><TD ALIGN="RIGHT"><B>Weight</B></TD></TR><TR><TD COLSPAN="2" BGCOLOR="#C0C0C0"><B>Batch #1</B></TD><TD COLSPAN="7" BGCOLOR="#C0C0C0"><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" WIDTH="100%"><TR><TD><FONT CLASS="fv">Submitted on Nov 20, 2013 17:12</TD><TD ALIGN="RIGHT"><IMG SRC="/images/printer16.png" WIDTH="16" HEIGHT="16" BORDER="0" ALT="Print Batch" TITLE="Print Batch"><IMG SRC="/images/dot.gif" WIDTH="5" HEIGHT="1"><IMG SRC="/images/invoice16YC.gif" WIDTH="16" HEIGHT="16" ALT="Batch Invoiced" TITLE="Batch Invoiced"></TD></TR></TABLE></TD></TR><TR BGCOLOR="FFFFFF"><TD HEIGHT="60"><CENTER><A ID='imgLink0' HREF='/catalogItemPic.asp?P=60208' REL='blcatimg'><IMG ALT="Lot ID: 48295541 Part No: 60208 Name: Wheel 31mm D. x 15mm Technic" TITLE="Lot ID: 48295541 Part No: 60208 Name: Wheel 31mm D. x 15mm Technic" BORDER='0' WIDTH='80' HEIGHT='60' SRC='http://img.bricklink.com/P/86/60208.gif' NAME='img0' ID='img0' onError="killImage('img0');"></A><BR><FONT FACE='Tahoma,Arial' SIZE='1'>*</FONT></TD><TD ALIGN="CENTER"><B>New</B></TD><TD><SPAN CLASS="u"><FONT COLOR="#000000">Light Bluish Gray Wheel 31mm D. x 15mm Technic </FONT></SPAN><BR><FONT CLASS="fv">AB4</FONT></TD><TD ALIGN="RIGHT"> </TD><TD ALIGN="RIGHT">12</TD><TD ALIGN="RIGHT">X</TD><TD ALIGN="RIGHT">EUR 0.11</TD><TD ALIGN="RIGHT">EUR 1.32</TD><TD ALIGN="RIGHT"><FONT CLASS="fv">38.16g</TD></TR><TR BGCOLOR="EEEEEE"><TD HEIGHT="60"><CENTER><A ID='imgLink1' HREF='/catalogItemPic.asp?P=6179' REL='blcatimg'><IMG ALT="Lot ID: 49014568 Part No: 6179 Name: Tile, Modified 4 x 4 with Studs on Edge" TITLE="Lot ID: 49014568 Part No: 6179 Name: Tile, Modified 4 x 4 with Studs on Edge" BORDER='0' WIDTH='80' HEIGHT='60' SRC='http://img.bricklink.com/P/86/6179.gif' NAME='img1' ID='img1' onError="killImage('img1');"></A><BR><FONT FACE='Tahoma,Arial' SIZE='1'>*</FONT></TD><TD ALIGN="CENTER"><B>New</B></TD><TD><SPAN CLASS="u"><FONT COLOR="#000000">Light Bluish Gray Tile, Modified 4 x 4 with Studs on Edge </FONT></SPAN><BR><FONT CLASS="fv">AJ2</FONT></TD><TD ALIGN="RIGHT"> </TD><TD ALIGN="RIGHT">12</TD><TD ALIGN="RIGHT">X</TD><TD ALIGN="RIGHT">EUR 0.633</TD><TD ALIGN="RIGHT">EUR 7.596</TD><TD ALIGN="RIGHT"><FONT CLASS="fv">23.28g</TD></TR><TR BGCOLOR="#DDDDDD"><TD COLSPAN="3"><B>Batch Total:</B></TD><TD ALIGN="RIGHT">2</TD><TD ALIGN="RIGHT">24</TD><TD></TD><TD> </TD><TD ALIGN="RIGHT">EUR 8.92</TD><TD ALIGN="RIGHT"><FONT CLASS="fv">61.44g</TD></TR><TR BGCOLOR="#C0C0C0"><TD COLSPAN="3"><B>Order Total:</B></TD><TD ALIGN="RIGHT">2</TD><TD ALIGN="RIGHT">24</TD><TD></TD><TD> </TD><TD ALIGN="RIGHT">EUR 8.92</TD><TD ALIGN="RIGHT"></TD></TR><TR><TD COLSPAN="10" ALIGN="RIGHT" BGCOLOR="#EEEEEE"><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" WIDTH="100%"><TR><TD><FONT CLASS="fv">Estimated Weight of Order:</FONT></TD><TD ALIGN="RIGHT"><FONT CLASS="fv">2.17oz 61.44g</FONT></TD></TR></TABLE></TD></TR></TABLE><TABLE WIDTH="100%" BORDER="0" CELLPADDING="1" CELLSPACING="0" CLASS="ta"><TR><TD COLSPAN="2" CLASS="fv" ALIGN="RIGHT">Contact your buyer about this order<BR> </TD></TR></TABLE><HR NOSHADE SIZE="1" COLOR="#000000"><FONT CLASS="fv"><CENTER>This order will be purged from the BrickLink website on May 20, 2014.</CENTER></FONT></TABLE><FONT CLASS="fv"><P><CENTER><FONT COLOR="#FFFFFF">Back to Orders</FONT> | <FONT COLOR="#FFFFFF">Show Temporary Checkboxes</FONT> | <FONT COLOR="#FFFFFF">Show Categories</FONT> | <FONT COLOR="#FFFFFF">Consolidate Batches</FONT> | <FONT COLOR="#FFFFFF">My Settings</FONT><P><FONT COLOR="#FFFFFF">Hide Qty Left in My Inventory</FONT> | <FONT COLOR="#FFFFFF">Hide Item Weight</FONT> | <FONT COLOR="#FFFFFF">Show My Cost</FONT> | <FONT COLOR="#FFFFFF">Show Only Items in Order</FONT> | <FONT COLOR="#FFFFFF">Edit Order</FONT>
It's a little tough to write full-blown code without looking at the page you wish to scrape, but you should be able to use the following code to get what you want. The code below reads in a file called "html.txt", finds all orders in that text file, finds the total weight values in ozs and grams, and writes that data to an output file called foundWeights.txt. To run the code, just save your html in a text file called "html.txt", save the code below in a file called "findweights.py", and then put both of those files in the same folder. Then, open a shell or a terminal window, navigate to that folder, and type "python findweights.py" and momentarily a text file will appear in the same folder with your data in it.
html = open("html.txt").read()
out = open("foundWeights.txt", "w")
#split html on order number
legoOrders = html.split("Order #")
for order in legoOrders[1:]:
print order
orderNumber = order.split("<")[0]
weightString = order.split('Estimated Weight of Order:</FONT></TD><TD ALIGN="RIGHT"><FONT CLASS="fv">')[1]
splitWeightString = weightString.split(' ')
splitStringFinal = splitWeightString[1].split("<")
grams = splitStringFinal[0]
ozs = weightString.split('&nbsp')[0]
out.write(str(orderNumber) + "\t" + str(grams) + "\t" + str(ozs) + "\n"
Outfile is tab-separated (Order #, grams, ozs):
3953198 61.44g 2.17oz

jquery datatable sorting not working for run time values

I used jquery data table for sorting. It works fine under normal condition. If i changed the value in run time, the sorting is not working.
This is my table data
<table width="94%" cellpadding="2" cellspacing="1" class="tablehead" id="pls-batting">
<thead>
<tr class="tab_head" align="right" id="pls-play" >
<th width="44" align="center" ># No </th>
</tr>
</thead>
<tbody>
<tr id="116706">
<td align="left" id='1' >test</td>
</tr>
<tr id="116707">
<td align="left" id='2'>bbb</td>
</tr>
<tr id="116708">
<td align="left" id='3' >xxx</td>
</tr>
</tbody>
</table>
Jquery method used for sorting is :
$(document).ready(function() {
$('#pls-batting').dataTable( {
} );
} );
By clicking the '# No' head the corresponding column displayed in asc and desc order respectively. These TD values will be changed onload by using
document.getElementById(3).innerHTML = 'something';
So as a result the 3rd column value is 'something'. So sorting will be done by this values. But it is not working.
It takes the old values. Please help me. Thanks
In DataTables, you should not update content of HTML cell. DT uses internal JavaScript array structure for searching/sorting and this cell is only a display value.
To update some cell you will need to use DT fnUpdate function see http://datatables.net/api#fnUpdate. Example of updating cell in the table is:
var oTable = $('#example').dataTable();
oTable.fnUpdate( 'New content', 10, 3 );
Note that cells are referenced by row/cell positions. If you don't know row/cell position then you can use http://datatables.net/api#fnGetPosition function to find position of TR with id 3 and use this info to update cell data using the fnGetData function (you can find example on the http://datatables.net/api#fnGetPosition)
Jovan

How Write every 7 image inside row by smarty?

I want to draw every 7 images inside row, how make it by Smarty?
<table width="838" cellpadding="0" cellspacing="0" style="border-collapse:collapse">
{section name=index loop=$ArrGallery}
<tr>
<td>
<img src="{$ArrGallery[index].gallery_path}" width="150" height="100" style=" position:relative; z-index:1; padding:7px;"/>
Delete
</td>
</tr>
{/section}
</table>
Instead of a table with a fixed number of cells per row, use css's float property. The objects you float will stack themselves onto the left side of their container until they fill it, then fill the next row, and so on. By adjusting the width of the container, you control the number of items per row. For example:
<div style="width:560px;">
{section name=index loop=$ArrGallery}
<img src="{$ArrGallery[index].gallery_path}" style="float:left;width:150px;height:100px;padding:7px;"/>
{/section}
</div>
Adjust the div's width until 7 images fill each row (except perhaps the last row).

Is there a way to sync column widths in an html table?

If I have these two tables:
<table>
<tr>
<td>Small Length Content</td>
</tr>
</table>
<table>
<tr>
<td>Dynamic Content Goes Here And It's Longer Than The TD Above</td>
</tr>
</table>
How can I make it so that the two columns have the same width?
I can't combine the tables so thats not an option. I also can't use fixed widths since its dynamic content. Any ideas? Perhaps something in javascript to have the top columns match the width of the lower table? I'm no js expert so I have no idea if thats possible or how to do it. Php is an option on the table as well if theres a way to use that to solve it as well.
Are you able to define css for this dynamic content? Suppose these tables were nested inside a div like so:
<div id="content">
<table>
<tr>
<td>Small Length Content</td>
</tr>
</table>
<table>
<tr>
<td>Dynamic Content Goes Here And It's Longer Than The TD Above</td>
</tr>
</table>
</div>
I would write some css like this:
#content table td { width: 80%; }
I would use a percentage-based width on the 'flowing' column, and buffer it with fixed-width columns if necessary. ie.:
<table style="width: 100%;">
<tr>
<td style="width: 80%;">Small Length Content</td>
</tr>
</table>
<table style="width: 100%;">
<tr>
<td style="width: 80%;">Dynamic Content Goes Here And It's Longer Than The TD Above</td>
</tr>
</table>
You can use CSS to accomplish this. You will have to have the longer content wrap.
td{
width:80%;
}
Try
<table>
<tr>
<td style="width:200px">Small Length Content</td>
</tr>
</table>
<table>
<tr>
<td>Dynamic Content Goes Here And It's Longer Than The TD Above</td>
</tr>
</table>
or add a class to name to the td element and define the style somewhere else like an external file or in header style

Categories