PHP with DOMXPath - How to select and count from this html tree - php

I need to count how many of these items are open, and there are four types of them: Easy, Medium, Difficult and Not-Wanted. All of these types are values inside the div's. I need to exclude the 'Not-Wanted' types from the count. Notice the 'Open' and 'Close' values have different number of spaces around them. This is the html structure:
<table>
<tbody>
<tr>
<td>
<div>Difficult</div>
</td>
<td>Name</td>
<td> Open </td>
</tr>
<tr>
<td>
<div>Easy</div>
</td>
<td>Name</td>
<td> Closed </td>
</tr>
<tr>
<td>
<div>Easy</div>
</td>
<td>Name</td>
<td> Open </td>
</tr>
<tr>
<td>
<div>Medium</div>
</td>
<td>Name</td>
<td>Open </td>
</tr>
<tr>
<td>
<div>Easy</div>
</td>
<td>Name</td>
<td> Open </td>
</tr>
<tr>
<td>
<div>Medium</div>
</td>
<td>Name</td>
<td> Closed</td>
</tr>
<tr>
<td>
<div>Easy</div>
</td>
<td>Name</td>
<td>Closed </td>
</tr>
<tr>
<td>
<div>Not-wanted</div>
</td>
<td>Name</td>
<td> Open </td>
</tr>
<tr>
<td>
<div>Difficult</div>
</td>
<td>Name</td>
<td>Open</td>
</tr>
............
This is one of my attempts to solve the problem. It is obviously wrong, but I don't know how to get it right.
$doc = new DOMDocument();
$doc->loadHtmlFile('http://www.nameofsite.com');
$doc->preserveWhiteSpace = false;
$xpath = new DOMXPath($doc);
$elements = $xpath->query("/html/body/div[1]/div/section/div/section/article/div/div[1]/div/div/div[2]/div[1]/div[2]/div/section/div/div/table/tbody/tr");
$count = 0;
foreach ($elements as $element) {
if ($element->childNodes->nodeValue != 'Not-wanted') {
if ($element->childNodes->nodeValue === 'open') {
$count++;
}
}
}
echo $count;
I have a very rudimental knowledge of DOMXPath, so it is too complex for me, since I'm only able to create simple queries.
Can anybody help?
Thanks in advance.

Based on the data in your example, I think you can adjust the xpath expression to this to get all the <tr>'s that match your conditions:
//table/tbody/tr[normalize-space(td[3]/text()) = 'Open' and
td[1]/div/text() != 'Not-wanted']
$elements is then of type DOMNodeList and you can then get the length property to get the number of nodes in the list.
For example:
$source = <<<SOURCE
<table>
<tbody>
<tr>
<td>
<div>Difficult</div>
</td>
<td>Name</td>
<td> Open </td>
</tr>
<tr>
<td>
<div>Easy</div>
</td>
<td>Name</td>
<td> Closed </td>
</tr>
<tr>
<td>
<div>Easy</div>
</td>
<td>Name</td>
<td> Open </td>
</tr>
<tr>
<td>
<div>Medium</div>
</td>
<td>Name</td>
<td>Open </td>
</tr>
<tr>
<td>
<div>Easy</div>
</td>
<td>Name</td>
<td> Open </td>
</tr>
<tr>
<td>
<div>Medium</div>
</td>
<td>Name</td>
<td> Closed</td>
</tr>
<tr>
<td>
<div>Easy</div>
</td>
<td>Name</td>
<td>Closed </td>
</tr>
<tr>
<td>
<div>Not-wanted</div>
</td>
<td>Name</td>
<td> Open </td>
</tr>
<tr>
<td>
<div>Difficult</div>
</td>
<td>Name</td>
<td>Open</td>
</tr>
</tbody>
</table>
SOURCE;
$doc = new DOMDocument();
$doc->loadHTML($source);
$doc->preserveWhiteSpace = false;
$xpath = new DOMXPath($doc);
$elements = $xpath->query("//table/tbody/tr[normalize-space(td[3]/text()) = 'Open' and td[1]/div/text() != 'Not-wanted']");
echo $elements->length;
Which will result in:
5
Demo

Related

Is there a way for WordPress to read the TCPDF file inside the theme directory?

I have finish parsing json to html table, and now I am going to get my html table generate to pdf using TCPDF. Everything is working on the local but when I apply it on WordPress, it seems that the WordPress didn't read the TCPDF file inside the theme directory.
How do I make my file to be read by WordPress?
Here's my complete code:
<?php
ob_start();
if (!isset($_POST['generate_pdf']))
{
$askPriceBeds = '{"status":"success","postcode":"W14 9JH","postcode_type":"full","url":"https://propertydata.co.uk/draw?input=W14+9JH","bedrooms":2,"data":{"points_analysed":20,"radius":"0.09","average":657495,"70pc_range":[ 575000, 725000 ],"80pc_range":[ 550000, 875000 ],"90pc_range":[ 550000, 925000 ],"100pc_range":[ 525000, 950000 ],"raw_data":[ {"price":650000,"lat":"51.48887000","lng":"-0.20776000","bedrooms":2,"type":"flat","distance":"0.00" }, {"price":575000,"lat":"51.48884800","lng":"-0.20701200","bedrooms":2,"type":"flat","distance":"0.03" }, {"price":615000,"lat":"51.48851000","lng":"-0.20742000","bedrooms":2,"type":"flat","distance":"0.03" }, {"price":640000,"lat":"51.48932000","lng":"-0.20804000","bedrooms":2,"type":"flat","distance":"0.03" }, {"price":725000,"lat":"51.48843100","lng":"-0.20775400","bedrooms":2,"type":"flat","distance":"0.03" }, {"price":699950,"lat":"51.48928000","lng":"-0.20793700","bedrooms":2,"type":"flat","distance":"0.03" }, {"price":550000,"lat":"51.48941000","lng":"-0.20832000","bedrooms":2,"type":"flat","distance":"0.04" }, {"price":600000,"lat":"51.48813700","lng":"-0.20781600","bedrooms":2,"type":"flat","distance":"0.05" }, {"price":925000,"lat":"51.48948300","lng":"-0.20827400","bedrooms":2,"type":"flat","distance":"0.05" }, {"price":650000,"lat":"51.48824900","lng":"-0.20669000","bedrooms":2,"type":"flat","distance":"0.06" }, {"price":700000,"lat":"51.48941200","lng":"-0.20666900","bedrooms":2,"type":"flat","distance":"0.06" }, {"price":625000,"lat":"51.48817000","lng":"-0.20689500","bedrooms":2,"type":"flat","distance":"0.06" }, {"price":645000,"lat":"51.48822500","lng":"-0.20872100","bedrooms":2,"type":"flat","distance":"0.06" }, {"price":675000,"lat":"51.48877800","lng":"-0.20643200","bedrooms":2,"type":"flat","distance":"0.06" }, {"price":525000,"lat":"51.48978800","lng":"-0.20864000","bedrooms":2,"type":"flat","distance":"0.07" }, {"price":700000,"lat":"51.48785100","lng":"-0.20757600","bedrooms":2,"type":"flat","distance":"0.07" }, {"price":675000,"lat":"51.48819900","lng":"-0.20637900","bedrooms":2,"type":"flat","distance":"0.08" }, {"price":875000,"lat":"51.48818700","lng":"-0.20931800","bedrooms":2,"type":"flat","distance":"0.08" }, {"price":550000,"lat":"51.48891000","lng":"-0.20955000","bedrooms":2,"type":"flat","distance":"0.08" }, {"price":950000,"lat":"51.48808300","lng":"-0.20628500","bedrooms":2,"type":"flat","distance":"0.09" } ] },"process_time":"2.08"}';
$data = json_decode($askPriceBeds, true);
$raw_data = $data['data']['raw_data'];
?>
<body>
<table>
<thead>
<tr>
<td>Price</td>
<td>Lat</td>
<td>Lng</td>
<td>Bedrooms</td>
<td>Type</td>
<td>Distance</td>
</tr>
</thead>
<tbody>
<?php
foreach($raw_data as $raw){
echo "<tr>
<td>".$raw['price']."</td>
<td>".$raw['lat']."</td>
<td>".$raw['lng']."</td>
<td>".$raw['bedrooms']."</td>
<td>".$raw['type']."</td>
<td>".$raw['distance']."</td>
</tr>";
}
?>
</tbody>
</table>
<form method="POST">
<input type="submit" name="generate_pdf" value="Generate PDF">
</form>
</body>
<?php
}
else
{
require_once($_SERVER['DOCUMENT_ROOT'].'/wp-content/themes/property-investment-vault/tcpdf/config/tcpdf_config.php');
require_once($_SERVER['DOCUMENT_ROOT'].'/wp-content/themes/property-investment-vault/tcpdf/tcpdf.php');
$tcpdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$tcpdf->SetCreator(PDF_CREATOR);
$tcpdf->SetTitle('');
$tcpdf->SetHeaderData('', '', PDF_HEADER_TITLE, PDF_HEADER_STRING);
$tcpdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$tcpdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
$tcpdf->SetDefaultMonospacedFont('helvetica');
$tcpdf->SetFooterMargin(PDF_MARGIN_FOOTER);
$tcpdf->SetMargins(PDF_MARGIN_LEFT, '5', PDF_MARGIN_RIGHT);
$tcpdf->setPrintHeader(false);
$tcpdf->setPrintFooter(false);
$tcpdf->SetAutoPageBreak(true, 10);
$tcpdf->SetFont('helvetica', '', 12);
$tcpdf->AddPage('P', 'A4');
$html = '<html>
<head></head>
<body>
<table border="1">
<tr>
<th> Price</th>
<th> Lat</th>
<th> Lng</th>
<th> Bedrooms</th>
<th> Type</th>
<th> Distance</th>
</tr>
<tr>
<td> 650000</td>
<td> 51.48887000</td>
<td> -0.20776000</td>
<td> 2</td>
<td> flat</td>
<td> 0.00</td>
</tr>
<tr>
<td> 575000</td>
<td> 51.48884800</td>
<td> -0.20701200</td>
<td> 2</td>
<td> flat</td>
<td> 0.03</td>
</tr>
<tr>
<td> 615000</td>
<td> 51.48851000</td>
<td> -0.20742000</td>
<td> 2</td>
<td> flat</td>
<td> 0.03</td>
</tr>
<tr>
<td> 640000</td>
<td> 51.48932000</td>
<td> -0.20804000</td>
<td> 2</td>
<td> flat</td>
<td> 0.03</td>
</tr>
<tr>
<td> 725000</td>
<td> 51.48843100</td>
<td> -0.20775400</td>
<td> 2</td>
<td> flat</td>
<td> 0.03</td>
</tr>
<tr>
<td> 699950</td>
<td> 51.48928000</td>
<td> -0.20793700</td>
<td> 2</td>
<td> flat</td>
<td> 0.03</td>
</tr>
<tr>
<td> 550000</td>
<td> 51.48941000</td>
<td> -0.20832000</td>
<td> 2</td>
<td> flat</td>
<td> 0.04</td>
</tr>
<tr>
<td> 600000</td>
<td> 51.48813700</td>
<td> -0.20781600</td>
<td> 2</td>
<td> flat</td>
<td> 0.05</td>
</tr>
<tr>
<td> 925000</td>
<td> 51.48948300</td>
<td> -0.20827400</td>
<td> 2</td>
<td> flat</td>
<td> 0.05</td>
</tr>
<tr>
<td> 650000</td>
<td> 51.48824900</td>
<td> -0.20669000</td>
<td> 2</td>
<td> flat</td>
<td> 0.06</td>
</tr>
<tr>
<td> 700000</td>
<td> 51.48941200</td>
<td> -0.20666900</td>
<td> 2</td>
<td> flat</td>
<td> 0.06</td>
</tr>
<tr>
<td> 625000</td>
<td> 51.48817000</td>
<td> -0.20689500</td>
<td> 2</td>
<td> flat</td>
<td> 0.06</td>
</tr>
<tr>
<td> 645000</td>
<td> 51.48822500</td>
<td> -0.20872100</td>
<td> 2</td>
<td> flat</td>
<td> 0.06</td>
</tr>
<tr>
<td> 675000</td>
<td> 51.48877800</td>
<td> -0.20643200</td>
<td> 2</td>
<td> flat</td>
<td> 0.06</td>
</tr>
<tr>
<td> 525000</td>
<td> 51.48978800</td>
<td> -0.20864000</td>
<td> 2</td>
<td> flat</td>
<td> 0.07</td>
</tr>
<tr>
<td> 700000</td>
<td> 51.48785100</td>
<td> -0.20757600</td>
<td> 2</td>
<td> flat</td>
<td> 0.07</td>
</tr>
<tr>
<td> 675000</td>
<td> 51.48819900</td>
<td> -0.20637900</td>
<td> 2</td>
<td> flat</td>
<td> 0.08</td>
</tr>
<tr>
<td> 875000</td>
<td> 51.48818700</td>
<td> -0.20931800</td>
<td> 2</td>
<td> flat</td>
<td> 0.08</td>
</tr>
<tr>
<td> 550000</td>
<td> 51.48891000</td>
<td> -0.20955000</td>
<td> 2</td>
<td> flat</td>
<td> 0.08</td>
</tr>
<tr>
<td> 950000</td>
<td> 51.48808300</td>
<td> -0.20628500</td>
<td> 2</td>
<td> flat</td>
<td> 0.09</td>
</tr>
</table>
</body>
</html>';
$tcpdf->writeHTML($html, true, 0, true, 0);
$tcpdf->lastPage();
ob_end_clean();
$tcpdf->Output("datareport.pdf", 'FD');
}
?>

PHP RAND and fuzzy logic rules

Well, let's say I have variable a, b and c:
a = R R R
b = S S S
c = T T T
number = 1 to 3;
In my case I need to display the 27 row of total (var * var * var), but the result need to be like this and generate random number between 1 to 3:
<table>
<tr>
<td> R </td>
<td> R </td>
<td> R </td>
<td> number </td>
</tr>
<tr>
<td> R </td>
<td> R </td>
<td> S </td>
<td> number </td>
</tr>
<tr>
<td> R </td>
<td> S </td>
<td> T </td>
<td> number </td>
</tr>
<tr>
<td> S </td>
<td> S </td>
<td> R </td>
<td> number </td>
</tr>
<tr>
<td> S </td>
<td> T </td>
<td> S </td>
<td> number </td>
</tr>
<tr>
<td> S </td>
<td> T </td>
<td> T </td>
<td> number </td>
</tr>
<tr>
<td> T </td>
<td> R </td>
<td> R </td>
<td> number </td>
</tr>
<tr>
<td> T </td>
<td> R </td>
<td> S </td>
<td> number </td>
</tr>
<tr>
<td> T </td>
<td> S </td>
<td> T </td>
<td> number </td>
</tr>
<tr>
<td> R </td>
<td> S </td>
<td> R </td>
<td> number </td>
</tr>
<tr>
<td> R </td>
<td> T </td>
<td> S </td>
<td> number </td>
</tr>
<tr>
<td> R </td>
<td> T </td>
<td> T </td>
<td> number </td>
</tr>
<tr>
<td> S </td>
<td> R </td>
<td> R </td>
<td> number </td>
</tr>
<tr>
<td> S </td>
<td> R </td>
<td> S </td>
<td> number </td>
</tr>
<tr>
<td> S </td>
<td> S </td>
<td> T </td>
<td> number </td>
</tr>
<tr>
<td> T </td>
<td> S </td>
<td> R </td>
<td> number </td>
</tr>
<tr>
<td> T </td>
<td> T </td>
<td> S </td>
<td> number </td>
</tr>
<tr>
<td> T </td>
<td> T </td>
<td> T </td>
<td> number </td>
</tr>
<tr>
<td> R </td>
<td> R </td>
<td> R </td>
<td> number </td>
</tr>
<tr>
<td> R </td>
<td> R </td>
<td> S </td>
<td> number </td>
</tr>
<tr>
<td> R </td>
<td> S </td>
<td> T </td>
<td> number </td>
</tr>
<tr>
<td> S </td>
<td> S </td>
<td> R </td>
<td> number </td>
</tr>
<tr>
<td> S </td>
<td> T </td>
<td> S </td>
<td> number </td>
</tr>
<tr>
<td> S </td>
<td> T </td>
<td> T </td>
<td> number </td>
</tr>
<tr>
<td> T </td>
<td> R </td>
<td> R </td>
<td> number </td>
</tr>
<tr>
<td> T </td>
<td> R </td>
<td> S </td>
<td> number </td>
</tr>
<tr>
<td> T </td>
<td> S </td>
<td> T </td>
<td> number </td>
</tr>
</table>
How can I achieve this result in php?
Any help will be very much appreciated.
Thanks.
Here you go:
$a = ['R','R','R'];
$b = ['S','S','S'];
$c = ['T','T','T'];
$array = [$a, $b, $c];
<table>
for($i=0 ; i<27; i++) {
<tr>
<td> echo $array[rand(0,2)][rand(0,2)] ; </td>
<td> echo $array[rand(0,2)][rand(0,2)] ; </td>
<td> echo $array[rand(0,2)][rand(0,2)] ; </td>
<td> echo rand(0,2)</td>
</tr>
}
</table>
// !! you need to concat php with HTML !!

Clickable row with link

How can I make each row clickable without repeating
This one is an example that shows the problem, parameter could be the code:
<table>
<thead>
<tr>
<th>Code</th>
<th>User</th>
...
</tr>
</thead>
<tbody>
<tr>
<td> 123 </td>
<td> User A </td>
...
</tr>
<tr>
<td> 456 </td>
<td> User B </td>
...
</tr>
</tbody>
Thanks
Excuse me for my English, I hope that you understand the problem.
There are a few different ways to achieve this. Here are a couple using plain javascript and one using jQuery.
Plain JS
With plain javascript with just use the onclick parameter. Pretty straight forward.
<table>
<thead>
<tr>
<th>Code</th>
<th>User</th>
...
</tr>
</thead>
<tbody>
<tr onclick="window.location='page/parameter1';">
<td> 123 </td>
<td> User A </td>
...
</tr>
<tr onclick="window.location='page/parameter2';">
<td> 456 </td>
<td> User B </td>
...
</tr>
</tbody>
</table>
jQuery
With jQuery you add a class so you can use that as the selector. There is also a data-href parameter that will hold the URL you want the user to go to when they click the row.
<table>
<thead>
<tr>
<th>Code</th>
<th>User</th>
...
</tr>
</thead>
<tbody>
<tr class="clickable" data-href="page/parameter1">
<td> 123 </td>
<td> User A </td>
...
</tr>
<tr class="clickable" data-href="page/parameter2">
<td> 456 </td>
<td> User B </td>
...
</tr>
</tbody>
</table>
<script>
jQuery(document).ready(function($) {
$("tr.clickable").click(function() {
window.location = $(this).data("href");
});
});
</script>
Your code should look like :
<table>
<thead>
<tr>
<th>Code</th>
<th>User</th>
...
</tr>
</thead>
<tbody>
<tr>
<td> 123 </td>
<td> User A </td>
...
</tr>
<tr>
<td> 456 </td>
<td> User B </td>
...
</tr>
</tbody>
Added end tag </a>

Arranging array results from a MySQL query

I'm making a brochure generator based on inventory in a database. Due to the way the on-paper brochure looks, the order of items display will not match the way mysql_fetch_array works. Each user chosen category holds four items in a 2X2 grid.
Category 1 ---------Category 2
[1] [2] ---------[5] [6]
[3] [4] ---------[7] [8]
Category 3 ---------Category 4
[9] [10] ---------[13] [14]
[11] [12] ---------[15] [16]
I've already created a basic table as a placeholder for the items in this pattern. This is my query to retrive the items.
$query = "SELECT t1.*, image_path FROM flyer_item AS t1
LEFT JOIN product_images AS t2 ON t1.product_id = t2.product_id WHERE id_page = '".$id_page."'";
echo $query."<br>";
$result = mysql_query($query);
echo '<h3 class = "splitter">Items</h3>';
//-create while loop and loop through result set
//Due to the unique item arrangement patter, we fill
//an array with the fetched array results.
$iArray = array();
while($row=mysql_fetch_array($result))
{
$iArray[] = $row;
$square = $row['square'];
$item_name = $row['item_name'];
$sales_info = $row['sales_info'];
$link = $row['image_path'];
$sku_item_number = $row['sku_item_number'];
if (empty($link))
{
$link = '../imagen/no_imagen.gif';
}
}
One page can hold up to a maximum of 24 items, all following the pattern mentioned above to make sure items are in their respective categories. I'm contemplating making another database table called Categories that will store its four items, but is there a way I can use the second array, iArray, to store the number indicating where the items should go?
The actual table looks like this, to match the original document.
<table width="100%" border="1" bordercolordark="#000000" bordercolorlight="#000000">
<tr>
<td> </td>
<td colspan="2" align="center"><?php echo $category1; ?></td>
<td> </td>
<td colspan="2" align="center"><?php echo $category2; ?></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>Item 1</td>
<td>Item 2</td>
<td> </td>
<td>Item 5</td>
<td>Item 6</td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>Item 3</td>
<td>Item 4</td>
<td> </td>
<td>Item 7</td>
<td>Item 8</td>
<td> </td>
</tr>
<tr>
<td> </td>
<td colspan="2" align="center"><?php echo $category3; ?></td>
<td> </td>
<td colspan="2" align="center"><?php echo $category4; ?></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>Item 9</td>
<td>Item 10</td>
<td> </td>
<td>Item 13</td>
<td>Item 14</td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>Item 11</td>
<td>Item 12</td>
<td> </td>
<td>Item 15</td>
<td>Item 16</td>
<td> </td>
</tr>
<tr>
<td> </td>
<td colspan="2" align="center"><?php echo $category5; ?></td>
<td> </td>
<td colspan="2" align="center"><?php echo $category6; ?></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>Item 17</td>
<td>Item 18</td>
<td> </td>
<td>Item 21</td>
<td>Item 22</td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>Item 19</td>
<td>Item 20</td>
<td> </td>
<td>Item 23</td>
<td>Item 24</td>
<td> </td>
</tr>
</table>

Display multiple database fields into a PHP table loop

I've been struggling with this for around 4 hours now...
What I'm trying to establish is pretty simple, I have a news table, I want to display the title of the news, the content, and a read more link, I know how to loop through a table and force , but this won't work in my case, the table should look like this in the end:
<table>
<tr>
<td>header one</td>
<td>header 2</td>
<td>header 3</td>
</tr>
<tr>
<td colspan="3"> </td>
</tr>
<tr>
<td>text one</td>
<td>text two</td>
<td>text 3</td>
</tr>
<tr>
<td>read more</td>
<td>read more </td>
<td>read more</td>
</tr>
</table>
What I have so far in my php is a code that will generate the rows and columns, but I want them to be distributed just like the sample table above in order not to mess the alignment of the text and the read more link ...
Here's my php code :
<table width="100%" cellspacing="0" cellpadding="0">
<tr>
<?php while ($record = mysql_fetch_assoc($result)): ?>
<?php $style++ ?>
<td width="33%" valign="top">
<h6><?php echo $record['title'] ?></h6>
<div class="service-sum"><?php echo $record['content'] ?></div>
<div class="findout">> find out more</div>
</td>
<?php if ($style == 3): ?>
</tr>
<?php $style = 0; ?>
<tr>
<td>
<div style="height:30px;"></div>
</td>
</tr>
<tr>
<?php endif ?>
<?php endwhile ?>
This one is working fine, but i'm displaying the title and the content and the read more link in one column, these should be distributed into 3 for design purposes...
Any help would be much appreciated, I looked all over the net and I can't find a solution for that!
try using this alignment. The design is almost same as yours.
<table>
<tr>
<td>
<table>
<tr>
<td>header one</td>
</tr>
<tr>
<td>text one</td>
</tr>
<tr>
<td>read more</td>
</tr>
</table>
</td>
<td>
<table>
<tr>
<td>header 2</td>
</tr>
<tr>
<td>text 2</td>
</tr>
<tr>
<td>read more</td>
</tr>
</table>
</td>
<td>
<table>
<tr>
<td>header 3</td>
</tr>
<tr>
<td>text 3</td>
</tr>
<tr>
<td>read more</td>
</tr>
</table>
</td>
</tr>
</table>
if there are only 3 records, the following should be fine. if there are more, some changes should be made. Please check your php code.
<table>
<tr>
<?php while ($record = mysql_fetch_assoc($result)) { ?>
<td>
<table>
<tr>
<td><?php echo $record['title'] ?></td>
</tr>
<tr><td height = "30px;"></td></tr>
<tr>
<td><?php echo $record['content'] ?></td>
</tr>
<tr>
<td>> find out more</td>
</tr>
</table>
</td>
<?php } ?>
</tr>
</table>

Categories