Because of all products have different price of its different package, I have separated its table for each products.
<table width="70%" border="0" cellspacing="0" cellpadding="0">
<tr c>
<td colspan="4"><div align="center">Product One</div></td>
</tr>
<tr>
<td>Id</td>
<td>package</td>
<td>price</td>
<td>image</td>
</tr>
<tr>
<td>1</td>
<td>2kg</td>
<td>$10</td>
<td>p2.jpg</td>
</tr>
<tr>
<td>2</td>
<td>4kg</td>
<td>$20</td>
<td>p4.jpg</td>
</tr>
<tr>
<td>3</td>
<td>6kg</td>
<td>$30</td>
<td>p6.jpg</td>
</tr>
<tr>
<td>4</td>
<td>8kg</td>
<td>$40</td>
<td>p8.jpg</td>
</tr>
</table></br></br>
<table width="70%" border="0" cellspacing="0" cellpadding="0">
<tr c>
<td colspan="4"><div align="center">Product Two</div></td>
</tr>
<tr>
<td>Id</td>
<td>package</td>
<td>price</td>
<td>image</td>
</tr>
<tr>
<td>1</td>
<td>2kg</td>
<td>$12</td>
<td>p2.jpg</td>
</tr>
<tr>
<td>2</td>
<td>4kg</td>
<td>$14</td>
<td>p4.jpg</td>
</tr>
<tr>
<td>3</td>
<td>6kg</td>
<td>$16</td>
<td>p6.jpg</td>
</tr>
<tr>
<td>4</td>
<td>8kg</td>
<td>$18</td>
<td>p8.jpg</td>
</tr>
</table>
Now what I want is to create a new table to collect the all products name: product one, product two, product three and product four.
<table width="70%" border="0" cellspacing="0" cellpadding="0">
<tr c>
<td colspan="4"><div align="center">Product One</div></td>
</tr>
<tr>
<td>Id</td>
<td>Name</td>
</tr>
<tr>
<td>1</td>
<td>Product One</td>
</tr>
<tr>
<td>2</td>
<td>Product Two</td>
</tr>
<tr>
<td>3</td>
<td>Product 3</td>
</tr>
<tr>
<td>4</td>
<td>Product Four</td>
</tr>
</table></br></br>
My question now is how to get all information of all product by connecting the name of products.
I am going to create a drop-down selection for its package. when they select the package, the price will be changed.
i know this is in coldfusion but i am sure there must be something similar in php
<cfquery name="gtmyinfo" datasource="mydb">
SELECT *
FROM mytable
</cfquery>
<table>
<tr>
<td colspan="4"><div align="center">Product ID</div></td>
<td colspan="4"><div align="center">Product Name</div></td>
<td colspan="4"><div align="center">Product Image</div></td>
</tr>
<tr>
<cfoutput query="gtmyinfo">
<td colspan="4"><div align="center">#ProductID#</div></td>
<td colspan="4"><div align="center">#ProductName#</div></td>
<td colspan="4"><div align="center">#ProductImage#</div></td>
</tr>
</cfoutput>
the table will keep looping as long with as many rows of data their are in the query.
you can limit which data is called with the "where" tag in the query or with an if/else tag in the table.
Related
This is code is using to generate pdf file. I using $html to do the table and will display in pdf file. But now if insert the while loop in the $html, the output is the php code and got some error. I confusing the single quotes to closing the code.
$html='<br><br><br>
<table border="1">
<tr>
<td bgcolor="#D0D0FF">Product Name</td>
<td bgcolor="#D0D0FF">Product Price</td>
<td bgcolor="#D0D0FF">Product Quantity</td>
<td bgcolor="#D0D0FF">Total Price</td>
</tr>
//Here
</table>`
<br>
<table border="1">
<tr>
<td bgcolor="#D0D0FF">Order Date</td>
<td width="600">'.$row['Order_Date'].'</td>
</tr>
<tr>
<td bgcolor="#D0D0FF">Tracking ID</td>
<td width="600">'.$row['Tracking_ID'].'</td>
</tr>
<tr>
<td bgcolor="#D0D0FF">Recipient</td>
<td width="600">'.$row['Tracking_Recipient'].'</td>
</tr>
<tr>
<td bgcolor="#D0D0FF">Phone Number</td>
<td width="600">'.$row['Tracking_PhoneNumber'].'</td>
</tr>
<tr>
<td bgcolor="#D0D0FF">Address</td>
<td width="600">'.$row['Tracking_Address'].'</td>
</tr>
<tr>
<td bgcolor="#D0D0FF">Bank</td>
<td width="600">'.$row['Bank'].'</td>
</tr>
</table>';
//While loop
I want to update tutor table and tutor course table, i have multiple checkbox for tutor course and if a teacher update his course or other info both table should also update.... tutor can increase or decrease course. I'm using following query but its not working for me
$update_content = mysql_query("UPDATE wp_tutor
JOIN wp_tutor_courses
ON wp_tutor.tutor_id=wp_tutor_courses.tutor_id
SET wp_tutor.tutor_name='$tNameVar',
wp_tutor.tutor_qualification='$tQualVar',
wp_tutor.tutor_skype='$tSkyVar',
wp_tutor.tutor_specialization='$tuSAreaVar',
wp_tutor.tutor_gender='$tuGenderVar',
wp_tutor_courses.course_id='$tuCourseVar'
WHERE tutor_id='$tid'");
<table cellpadding="5" cellspacing="0" border="1">
<caption>Tutor Table</caption>
<thead>
<tr>
<th>Tutor ID</th>
<th>Tutor Name</th>
<th>Tutor Skype ID</th>
<th>Tutor Specialization</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">1</td>
<td align="center">Kashif</td>
<td align="center">kashiflatif</td>
<td align="center">Financial Accounting</td>
</tr>
<tr>
<td align="center">2</td>
<td align="center">Ammar</td>
<td align="center">ammar.90</td>
<td align="center">Research Methods</td>
</tr>
<tr>
<td align="center">3</td>
<td align="center">Bilal</td>
<td align="center">bilalhaider95</td>
<td align="center">Islamic Bond & Practices</td>
</tr>
</tbody>
</table>
<br />
<br />
<table cellpadding="5" cellspacing="0" border="1" style="float:left">
<caption>Tutor Course Table</caption>
<thead>
<tr>
<th>Tutor Course ID</th>
<th>Tutor ID</th>
<th>Course ID</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">1</td>
<td align="center">1</td>
<td align="center">1</td>
</tr>
<tr>
<td align="center">2</td>
<td align="center">1</td>
<td align="center">2</td>
</tr>
<tr>
<td align="center">3</td>
<td align="center">1</td>
<td align="center">3</td>
</tr>
<tr>
<td align="center">4</td>
<td align="center">2</td>
<td align="center">1</td>
</tr>
<tr>
<td align="center">5</td>
<td align="center">2</td>
<td align="center">3</td>
</tr>
<tr>
<td align="center">6</td>
<td align="center">3</td>
<td align="center">1</td>
</tr>
</tbody>
</table>
<table cellpadding="5" cellspacing="0" border="1" style="float:left; margin-left:20px;">
<caption>Course Table</caption>
<thead>
<tr>
<th>Course ID</th>
<th>Course Name</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">1</td>
<td align="center">Certificate</td>
</tr>
<tr>
<td align="center">2</td>
<td align="center">Diploma</td>
</tr>
<tr>
<td align="center">3</td>
<td align="center">PGD</td>
</tr>
</tbody>
</table>
Try this:
$update_content = mysql_query("UPDATE wp_tutor a
INNER JOIN wp_tutor_courses b
ON a.tutor_id=b.tutor_id
SET a.tutor_name='$tNameVar',
a.tutor_qualification='$tQualVar',
a.tutor_skype='$tSkyVar',
a.tutor_specialization='$tuSAreaVar',
a.tutor_gender='$tuGenderVar',
b.course_id='$tuCourseVar'
WHERE a.tutor_id='$tid'");
I have a Table, see Code. Its a table that has a table in it, so its nested. Now i want to get all vales of the parent table only and then all values of the child table.
To get the childs data i can do this:
$query = '//*[#id="WordClass"]/table[2]/tr/td[2]/table/tr';
$nodes = $xpath->query($query);
foreach ($nodes as $node) { //do more querys to get the td data and save it..
My problem is how to only get the data of the parent table without getting the child data/tr/td also.
<table cellpadding="0" cellspacing="0" border="0">
<tbody>
<tr valign="top">
<td>
<table cellpadding="1" cellspacing="2" border="0">
<tr>
<td class="colTitle" align="center" colspan="4">
Da Titel
</td>
</tr>
<tr>
<td class="colTitle" align="center" colspan="2">One
</td>
<td class="colTitle" align="center" colspan="2">Two
I
</td>
</tr>
<tr>
<td class="colSubTitle">Pe</td>
<td class="colSubTitle">Ve</td>
<td class="colSubTitle">Pe</td>
<td class="colSubTitle">Ve</td>
</tr>
<tr>
<td class="rowTitle">x</td>
<td class="colVerbDef">y</td>
<td class="rowTitle">z</td>
<td class="colVerbDef">c</td>
</tr>
<tr>
<td class="rowTitle">r</td>
<td class="colVerbDef">t</td>
<td class="rowTitle">z</td>
<td class="colVerbDef">z</td>
</tr>
</table>
</td>
<td>
<table cellpadding="1" cellspacing="2" border="0">
<tr>
<td class="colTitle" align="center" colspan="4">
Da Titel2
</td>
</tr>
<tr>
<td class="colTitle" align="center" colspan="2">One
</td>
<td class="colTitle" align="center" colspan="2">Two
I
</td>
</tr>
<tr>
<td class="colSubTitle">Pe2</td>
<td class="colSubTitle">Ve2</td>
<td class="colSubTitle">Pe2</td>
<td class="colSubTitle">Ve2</td>
</tr>
<tr>
<td class="rowTitle">x2</td>
<td class="colVerbDef">y2</td>
<td class="rowTitle">z2</td>
<td class="colVerbDef">c2</td>
</tr>
<tr>
<td class="rowTitle">r2</td>
<td class="colVerbDef">t2</td>
<td class="rowTitle">z2</td>
<td class="colVerbDef">z2</td>
</tr>
</table>
</td>
</tr>
</tbody>
You can get the contents of the parent table's td elements using a direct path from the root:
/table/tbody/tr/td
The contents of those cells happen to be another table element, but you can strip those out with DOMDocument.
To get the inner tables' td elements only excluding the parents, you can look for tables that have a td parent, then select its tds:
//td/table//td
If I've misunderstood your question, please feel free to explain further and I will update.
I have a report to be exported in xls format. The report was exported successfully in xls format but gridlines never show up even I have adjusted some options in the ms excel by checking the view gridline checkbox but gridlines still show nothing. I have suspected if maybe there is something wrong with my php export code. can you please help me with this? Here is my code.
xls export code
<?php
$file="report.xls";
$export ='<center><h1 class="lead">CITY Chamber</h1><img src= "base_url(images/agri_logo.jpg)" width="130px" height="130px"></center>
<div id="page-wrapper">
<table class="table table-bordered table-hover table-striped tablesorter">
<tr>
<td>First Name: </td>
<td>'.$report_rows[0]->fname.'</td>
</tr>
<tr>
<td>Last Name: </td>
<td>'. $report_rows[0]->lname.'</td>
</tr>
<tr>
<td>Gender: </td>
<td>'.$report_rows[0]->gender.'</td>
</tr>
<tr>
<td>Contact Number: </td>
<td>'.$report_rows[0]->contact.'</td>
</tr>
</table>
<table class="table table-bordered table-hover table-striped tablesorter">
<div class="table-responsive">
<table class="table table-bordered table-hover table-striped tablesorter">
<thead>
<tr>
<td colspan="2"><strong>Key Result Areas (KRA) / Program / Projects / Activities</strong></td>
<td><strong>Target</strong></td>
<td colspan="2" style="text-align:center;"><center> '.$report_rows[0]->prev_month_year.'</center></td>
<td colspan="2" ><center> '.$report_rows[0]->pres_month_year.' </center></td>
<td><strong>Total</strong></td>
</tr>
</thead>
<form id="at_report_form" method="post">
<tbody>
<tr>
<td></td>
<td></td>
<td></td>
<td> '.$dropdown_brgy1[$data_reports['prev_brgy1']].' </td>
<td> '.$dropdown_brgy1[$data_reports['prev_brgy2']].' </td>
<td> '.$dropdown_brgy1[$data_reports['pres_brgy1']].' </td>
<td> '.$dropdown_brgy1[$data_reports['pres_brgy2']].' </td>
<td></td>
</tr>
<tr>
<td>1. KRA No. 1: Production Enhancement & Environment </td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td> Protection Agenda (PEEPA)</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>1.1 Support to Crop Production Enhancement </td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>1.1.1 Rice Production Self Sufficiency Program</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><span style="margin-left:30px;">a. Provision of certified seeds</span></td>
<td>no. of bags</td>
<td>per AT</td>
<td><center> '.$data_reports['a'].'</center></td>
<td> <center>'.$data_reports['b'].'</center></td>
<td><center> '.$data_reports['c'].'</center></td>
<td> <center>'.$data_reports['d'].'</center></td>
<td><center> '.$data_reports['total_1'].'</center></td>
</tr>
<tr>
<td></td>
<td>no. of farmers</td>
<td></td>
<td><center>'.$data_reports['e'].'</center></td>
<td><center>'.$data_reports['f'].'</center></td>
<td><center>'.$data_reports['g'].'</center></td>
<td><center>'.$data_reports['h'].'</center></td>
<td><center>'.$data_reports['total_2'].'</center></td>
</tr>
<tr>
<td style="text-align:center;">Rehab Seeds</td>
<td>no. of bags</td>
<td>per AT</td>
<td><center>'.$data_reports['i'].'</center></td>
<td><center>'.$data_reports['j'].'</center></td>
<td><center>'.$data_reports['k'].'</center></td>
<td><center>'.$data_reports['l'].'</center></td>
<td><center>'.$data_reports['total_3'].'</center></td>
</tr>
<tr>
<td></td>
<td>no. of farmers</td>
<td></td>
<td><center>'.$data_reports['m'].'</center></td>
<td><center>'.$data_reports['n'].'</center></td>
<td><center>'.$data_reports['o'].'</center></td>
<td><center>'.$data_reports['p'].'</center></td>
<td><center>'.$data_reports['total_4'].'</center></td>
</tr>
<tr>
<td><span style="margin-left:30px;">b. Provision of pest control assistance</span></td>
<td>no. of kgs (ratoxin)</td>
<td>per AT</td>
<td><center>'.$data_reports['q'].'</center></td>
<td><center>'.$data_reports['r'].'</center></td>
<td><center>'.$data_reports['s'].'</center></td>
<td><center>'.$data_reports['t'].'</center></td>
<td><center>'.$data_reports['total_5'].'</center></td>
</tr>
</tbody>
</form>
</table></div></div>';
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=$file");
echo $export; ?>
Output (Gridlines never show up even I have checked the gridlines view checkbox):
optput ur html using table tags
use
<table border=1>
I have a table like
<table width="60%" border="0">
<tr>
<td>intId</td>
<td>tagname</td>
<td>cid</td>
<td>lid</td>
</tr>
<tr>
<td>1</td>
<td>chemis</td>
<td>5</td>
<td>0</td>
</tr>
<tr>
<td>2</td>
<td>hist</td>
<td>4</td>
<td>0</td>
</tr>
<tr>
<td>3</td>
<td>canada</td>
<td>0</td>
<td>9</td>
</tr>
<tr>
<td>4</td>
<td>chemis</td>
<td>6</td>
<td>0</td>
</tr>
<tr>
<td>5</td>
<td>chemis</td>
<td>9</td>
<td>2</td>
</tr>
<tr>
<td>6</td>
<td>hist</td>
<td>3</td>
<td>1</td>
</tr>
</table>
$srarchkey_arr = array('chemis','tes','loyal','hist','canada');
My output should be
<table width="60%" border="0">
<tr>
<td>Tag Name </td>
<td>cid</td>
<td>lid</td>
</tr>
<tr>
<td>Chemis</td>
<td>5,6,9</td>
<td>0,0,2</td>
</tr>
<tr>
<td>hist</td>
<td>4,3,</td>
<td>0,1</td>
</tr>
<tr>
<td>canada</td>
<td>0</td>
<td>9</td>
</tr>
</table>
Please refer the fiddle
i.e In my tags table i have lots of tags with cid and lid
I want to search the words which are in array $srarchkey_arr. I want to search these tags and give the output as specified. I used the like query but it gives the out put as individual record. So i again use loops to concat the cid and lids.
Is this possible to do this with single query and loop. Is there any possibility to pass this like array or like in() for strings.
Please help me. thanks
use this sql
SELECT tagname, group_concat(cid), group_concat(lid) from test.check group by tagname;