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'");
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
How to get data and set in to php var when use file_get_contents PHP ?
this is code for http://www.example.com/test.php
<table align="center">
<thead style="background-color: #F0F0F0; color: #333333; text-align: center;">
<tr>
<th class="countryHeader">Country</th>
<th class="intHeader"> </th>
<th colspan="2" class="intHeader">Desktop CPM</th>
<th colspan="2" class="bannerHeader">Mobile CPM</th>
</tr>
</thead>
<tbody>
<tr class="breaker">
<td> </td>
<td>Highest</td>
<td>Unique</td>
<td>Raw</td>
<td>Unique</td>
<td>Raw</td>
</tr>
<tr class="odd rateVals">
<td class="countryName">United States</td>
<td class="cpmRaw">$2.00</td>
<td class="cpm">$3.44</td>
<td class="cpmRaw">$2.00</td>
<td class="cpmMobile">$1.63</td>
<td class="cpmMobileRaw">$0.97</td>
</tr>
<tr class="even rateVals">
<td class="countryName">Canada</td>
<td class="cpmRaw">$1.20</td>
<td class="cpm">$2.52</td>
<td class="cpmRaw">$1.20</td>
<td class="cpmMobile">$1.88</td>
<td class="cpmMobileRaw">$1.06</td>
</tr>
<tr class="odd rateVals">
<td class="countryName">United Kingdom</td>
<td class="cpmRaw">$1.60</td>
<td class="cpm">$2.10</td>
<td class="cpmRaw">$1.08</td>
<td class="cpmMobile">$1.71</td>
<td class="cpmMobileRaw">$0.94</td>
</tr>
<tr class="even rateVals">
<td class="countryName">Australia</td>
<td class="cpmRaw">$1.50</td>
<td class="cpm">$2.62</td>
<td class="cpmRaw">$1.20</td>
<td class="cpmMobile">$2.73</td>
<td class="cpmMobileRaw">$1.49</td>
</tr>
<tr class="breaker">
<td colspan="6"> </td>
</tr>
<tr class="odd rateVals">
<td class="countryName">United Arab Emirates</td>
<td class="cpmRaw">$1.48</td>
<td class="cpm">$2.49</td>
<td class="cpmRaw">$1.45</td>
<td class="cpmMobile">$2.11</td>
<td class="cpmMobileRaw">$1.42</td>
</tr>
<tr class="odd rateVals">
<td>All other countries</td>
<td>-</td>
<td colspan="2">$0.25 - $2.00</td>
<td colspan="2">$0.06 - $0.22</td>
</tr>
</tbody>
</table>
And this is code for my_code.php
<?php
$test = file_get_contents('http://www.example.com/test.php');
//echo $test;
?>
And i want to get php var from column Mobile CPM raw value like this
$United_States = "0.97";
$Canada = "1.07";
$United_Kingdom = "0.94";
$Australia = "1.49";
$United_Arab_Emirates = "1.42";
How can i do ?
If you want to parse a HTML document you should use PHP's DOMDocument. Instead of file_get_contents() you should use loadHTMLFile(). Because you are using CSS-classes you should view this post on how to find elements via class.
I have following do while loop be it keep on repeating the table for each record how to fix it? full table repeat for each record.
Also for every row fetch can I add
<table width="1510" border="1" align="center" cellpadding="2" cellspacing="2" class="table table-bordered" >
<tbody>
<form name="f1">
<? $counter = 1;
$total_marks = 0;
$total_obtain = 0;
while($row_rsDept = mysql_fetch_array($rsDept))
{
if($counter === 1)
{
?>
<tr>
<th width="71" rowspan="3" align="center" valign="middle" scope="col"><h4>Sr. No</h4></th>
<th width="229" align="right" valign="top" scope="col"> </th>
<th colspan="8" align="center" valign="middle" scope="col"><h3>Detail of Marks</h3></th>
</tr>
<tr>
<th rowspan="2" align="left" scope="row"><h4>Subject</h4></th>
<td colspan="2" align="center"><h4>Thoery</h4></td>
<td colspan="2" align="center"><h4>Practical</h4></td>
<td width="134" rowspan="2" align="center" valign="middle"><h4>Marks Obtain</h4></td>
<td width="144" rowspan="2" align="center" valign="middle"><h4>Max Marks</h4></td>
<td width="137" rowspan="2" align="center" valign="middle"><h4>Remarks</h4></td>
<td width="137" rowspan="2" align="center" valign="middle"><h4>Grace Marks</h4></td>
</tr>
<tr>
<td width="134">Obtained Marks</td>
<td width="144">Total Marks</td>
<td width="143">Obtained Marks</td>
<td width="153">Total Marks</td>
</tr>
<? } ?>
<tr>
<th align="left" scope="row"> </th>
<th align="left" scope="row"><?php echo $row_rsDept['SUBJECTS']; ?></th>
<td><?php echo $row_rsDept['THEORYOBTAINEDMARKS']; ?></td>
<td><?php echo $row_rsDept['THEORYTOTALMARKS']; ?></td>
<td><?php echo $row_rsDept['PRACTICALOBATINEDMARKS']; ?></td>
<td><?php echo $row_rsDept['PRACTICALTOTALMARKS']; ?></td>
<td align="center" valign="middle"><?php echo $row_rsDept['MARKSOBTAINED']; ?></td>
<td align="center" valign="middle"><?php echo $row_rsDept['MAXMARKS']; ?></td>
<td align="center" valign="middle"><span class="style8"><?php echo $row_rsDept['REMARKS']; ?></span></td>
<td align="center" valign="middle"><?php echo $row_rsDept['GRACEMARKS']; ?></td>
</tr>
<tr>
<th colspan="6" align="right" valign="middle" scope="row"><h4>Total</h4></th>
<td align="center" valign="middle"><span class="style8"><?php echo $row_rsDept['TOTALMARKS']; ?></span></td>
<td align="center" valign="middle">=total of above ( )</td>
<td align="center" valign="middle"> </td>
<td align="center" valign="middle"> </td>
</tr>
<?php
} ?>
<tr>
<th colspan="10" align="left" valign="middle" scope="row"> </th>
</tr>
<tr>
<th colspan="8" align="left" valign="middle" scope="row"> </th>
<th align="left" valign="middle" scope="row"> </th>
<th align="left" valign="middle" scope="row"> </th>
</tr>
<tr>
<th colspan="8" align="left" valign="middle" scope="row"><br></th>
<th align="left" valign="middle" scope="row"> </th>
<th align="left" valign="middle" scope="row"> </th>
</tr>
</form>
</table>
I tried to fix but not working for me
Inside loop you need to increment counter variable
Inside loop add this line
$counter++;
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.
<table width="100%" cellspacing="0" cellpadding="0" border="0" id="Table4">
<tbody>
<tr>
<td valign="top" class="tx-strong-dgrey">
<a class="anc-noul" href="http://www.example.com/catalog/proddetail.asp?logon=&langid=EN&sku_id=0665000FS10129471&catid=25653">
Apple 8GB 3rd Generation iPod Touch</a></td>
</tr>
<tr>
<td valign="top" class="element-spacer"/>
</tr>
<tr>
<td valign="top" class="tx-normal-grey">
Product detail
<a href="http://www.example.com/catalog/proddetail.asp?logon=&langid=EN&sku_id=0665000FS10129471&catid=25653">
More Info</a></td>
</tr>
<tr>
<td valign="top" class="element-spacer"/>
</tr>
<tr>
<td valign="top" class="tx-normal-red">
<span class="tx-strong-dgrey">Price:</span>
$189.99</td>
</tr>
<tr>
<td valign="top">You save: $9.00 after instant savings</td>
</tr>
<tr>
<td valign="top" class="element-spacer"/>
</tr>
<tr>
<td valign="top" class="tx-normal-grey">
<a href="http://www.example.com/catalog/subclass.asp?catid=25653&logon=&langid=EN">
View similar products</a>
<a href="http://www.example.com/catalog/mfr.asp?man=Apple&catid=19&logon=&langid=EN">
View similar products with same brand</a>
</td></tr>
<tr>
<td valign="top" class="element-spacer"/>
</tr>
</tbody>
</table>
I want to be able to get the $189.99.
echo $ret[0]->find('tr', 4)->plaintext;
This outputs: 'Price: $189.99'
I just need $189.99, not 'Price:'
$exp = explode(":", $ret[0]->find('tr', 4)->plaintext);
$price =$exp[1];