I have been trying to output the result via .$result['name']. but of no use.
Below is my code:
<?php
mysql_connect("localhost", "root", "") or die("Error connecting to database: ".mysql_error());
mysql_select_db("amityada_admission") or die(mysql_error());
?>
<!DOCTYPE html>
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<title>Search Inquiry</title>
</head>
<body>
<div class="container">
<h3>Search Result</h3>
<p>
<?php
$query = $_POST['query'];
$min_length = 5;
if(strlen($query) >= $min_length){
$query = htmlspecialchars($query);
$query = mysql_real_escape_string($query);
$raw_results = mysql_query("SELECT * FROM student_admission
WHERE (`mobile` LIKE '%".$query."%') OR (`name` LIKE '%".$query."%') OR (`university` LIKE '%".$query."%')") or die(mysql_error());
if(mysql_num_rows($raw_results) > 0){
echo "<table>";
while ($results = mysql_fetch_assoc($raw_results)) {
echo <<<EOD
<h2 style="background-color:#009; color:#FFF; padding: 10px; alignment-adjust:baseline">Student Admission Form</h2>
<div align="center">
<table width="90%" border="1">
<tr>
<th colspan="4" scope="row"><h3 align="left" style="background-color:#F39; color:#FFF; padding: 10px">Admission Form for | $name | Session 2015-2016</h3></th>
<td colspan="2" rowspan="7">$file</td>
</tr>
<tr>
<th colspan="4" scope="row" style="background-color:#009; color:#FFF; padding:4px; font-family:Georgia, 'Times New Roman', Times, serif" ><div align="left"><strong>Personal Details</strong></div></th>
</tr>
<tr>
<th width="29%" scope="row"><div align="left">Student Name</div></th>
<td width="9%"><div align="left">$name</div></td>
<td width="25%"><div align="left"><strong>Fathers Name</strong></div></td>
<td width="13%"><div align="left">$fname</div></td>
</tr>
<tr>
<th scope="row"><div align="left">Mothers Name</div></th>
<td><div align="left">$mname</div></td>
<td><div align="left"><strong>Date of Birth</strong></div></td>
<td><div align="left">$dob</div></td>
</tr>
<tr>
<th scope="row"><div align="left">Mobile Number</div></th>
<td><div align="left">$mobile</div></td>
<td><div align="left"><strong>Email ID</strong></div></td>
<td><div align="left">$email</div></td>
</tr>
<tr>
<th scope="row"><div align="left">Gender</div></th>
<td><div align="left">$gender</div></td>
<td><div align="left"><strong>Marital Status</strong></div></td>
<td><div align="left">$maritalstatus</div></td>
</tr>
<tr>
<th scope="row"><div align="left">Employed</div></th>
<td><div align="left">$employed</div></td>
<td><div align="left"><strong>Course Type</strong></div></td>
<td><div align="left">$coursetype</div></td>
</tr>
<tr>
<th colspan="6" scope="row" style="background-color:#009; color:#FFF; padding:4px; font-family:Georgia, 'Times New Roman', Times, serif"><div align="left">Educational Details</div></th>
</tr>
<tr>
<th scope="row"><div align="left"><strong>Current Education</strong></div></th>
<td><div align="left">$current_educational_details</div></td>
<td><div align="left"><strong>Course Applied For</strong></div></td>
<td><div align="left">$course</div></td>
<td width="11%"><div align="left"><strong>Specialization</strong></div></td>
<td width="13%"><div align="left">$specialization</div></td>
</tr>
<tr>
<th scope="row"><div align="left">Lateral Entry</div></th>
<td><div align="left">$lateralentry</div></td>
<td><div align="left"><strong>Lateral Entry In</strong></div></td>
<td><div align="left">$lateral_entry_in</div></td>
<td><div align="left"></div></td>
<td><div align="left"></div></td>
</tr>
<tr>
<th colspan="6" scope="row" style="background-color:#009; color:#FFF; padding:4px; font-family:Georgia, 'Times New Roman', Times, serif"><div align="left">Correspondence Address</div> <div align="left"></div> <div align="left"></div> <div align="left"></div> <div align="left"></div> <div align="left"></div></th>
</tr>
<tr>
<th scope="row"><div align="left">Address</div></th>
<td colspan="5"><div align="left">$corr_add</div> <div align="left"></div> <div align="left"></div> <div align="left"></div> <div align="left"></div></td>
</tr>
<tr>
<th scope="row"><div align="left">Country</div></th>
<td><div align="left">$countryId</div></td>
<td><div align="left"><strong>State</strong></div></td>
<td><div align="left">$stateId</div></td>
<td><div align="left"><strong>City</strong></div></td>
<td><div align="left">$cityId</div></td>
</tr>
<tr>
<th colspan="6" scope="row" style="background-color:#009; color:#FFF; padding:4px; font-family:Georgia, 'Times New Roman', Times, serif"><div align="left">Payment Option</div> <div align="left"></div> <div align="left"></div> <div align="left"></div> <div align="left"></div> <div align="left"></div></th>
</tr>
<tr>
<th scope="row"><div align="left">Payment Mode</div></th>
<td><div align="left">$payment_method</div></td>
<td><div align="left"><strong>Payment Option</strong></div></td>
<td><div align="left">$feesinfull</div></td>
<td><div align="left"></div></td>
<td><div align="left"></div></td>
</tr>
<tr>
<th scope="row"><div align="left">Complete Fees</div></th>
<td><div align="left">$coursefees</div></td>
<td><div align="left"><strong>Full Fees Paid</strong></div></td>
<td><div align="left">$fullfees</div></td>
<td><div align="left"><strong>Discount</strong></div></td>
<td><div align="left">$discount</div></td>
</tr>
<tr>
<th colspan="6" scope="row" style="background-color:#009; color:#FFF; padding:4px; font-family:Georgia, 'Times New Roman', Times, serif"><div align="left">Installment Options</div> <div align="left"></div> <div align="left"></div> <div align="left"></div> <div align="left"></div> <div align="left"></div></th>
</tr>
<tr>
<th scope="row"><div align="left">Installment 1</div></th>
<td><div align="left">$installment1</div></td>
<td><div align="left"><strong>Paid On</strong></div></td>
<td><div align="left">$ins1</div></td>
<td><div align="left"></div></td>
<td><div align="left"></div></td>
</tr>
<tr>
<th scope="row"><div align="left">Installment 2</div></th>
<td><div align="left">$installment2</div></td>
<td><div align="left"><strong>Paid On</strong></div></td>
<td><div align="left">$ins2</div></td>
<td><div align="left"></div></td>
<td><div align="left"></div></td>
</tr>
<tr>
<th scope="row"><div align="left">Installment 3</div></th>
<td><div align="left">$installment3</div></td>
<td><div align="left"><strong>Paid On</strong></div></td>
<td><div align="left">$ins3</div></td>
<td><div align="left"></div></td>
<td><div align="left"></div></td>
</tr>
<tr>
<th scope="row"><div align="left">Installment 4</div></th>
<td><div align="left">$installment4</div></td>
<td><div align="left"><strong>Paid On</strong></div></td>
<td><div align="left">$ins4</div></td>
<td><div align="left"></div></td>
<td><div align="left"></div></td>
</tr>
<tr>
<th scope="row"><div align="left">Installment 5</div></th>
<th scope="row"><div align="left">$installment5</div></th>
<th scope="row"><div align="left"><strong>Paid On</strong></div></th>
<th scope="row"><div align="left">$ins5</div></th>
<th scope="row"><div align="left"></div></th>
<th scope="row"><div align="left"></div></th>
</tr>
<tr>
<th scope="row"><div align="left">Installment 6</div></th>
<th scope="row"><div align="left">$installment6</div></th>
<th scope="row"><div align="left"><strong>Paid On</strong></div></th>
<th scope="row"><div align="left">$ins6</div></th>
<th scope="row"><div align="left"></div></th>
<th scope="row"><div align="left"></div></th>
</tr>
<tr>
<th scope="row"><div align="left">Installment 7</div></th>
<th scope="row"><div align="left">$installment7</div></th>
<th scope="row"><div align="left"><strong>Paid On</strong></div></th>
<th scope="row"><div align="left">$ins7</div></th>
<th scope="row"><div align="left"></div></th>
<th scope="row"><div align="left"></div></th>
</tr>
<tr>
<th scope="row"><div align="left">Installment 8</div></th>
<th scope="row"><div align="left">$installment8</div></th>
<th scope="row"><div align="left"><strong>Paid On</strong></div></th>
<th scope="row"><div align="left">$ins8</div></th>
<th scope="row"><div align="left"></div></th>
<th scope="row"><div align="left"></div></th>
</tr>
<tr>
<th scope="row"><div align="left">Installment 9</div></th>
<th scope="row"><div align="left">$installment9</div></th>
<th scope="row"><div align="left"><strong>Paid On</strong></div></th>
<th scope="row"><div align="left">$ins9</div></th>
<th scope="row"><div align="left"></div></th>
<th scope="row"><div align="left"></div></th>
</tr>
<tr>
<th scope="row"><div align="left">Installment 10</div></th>
<th scope="row"><div align="left">$installment10</div></th>
<th scope="row"><div align="left"><strong>Paid On</strong></div></th>
<th scope="row"><div align="left">$installment10</div></th>
<th scope="row"><div align="left"></div></th>
<th scope="row"><div align="left"></div></th>
</tr>
<tr>
<th colspan="6" scope="row"><div align="left">
<p>This is Just an Admission Form filled for the purpose of Applying for the University. This is not an University Admission Form and Should only be traeted for Pune Institute Admission Purpose. Any Changes or Request for Updation of Student Details of Change of University has to be Submitted to the IT Admin through mail on <strong>info#puneinstitute.org</strong></p>
</div></th>
</tr>
<tr>
<th colspan="6" scope="row" style="background-color:grey; color:white; padding: 7px">© Ankit 2003-2015 | Powered By © Diaphram 2011-2015 </th>
</tr>
</table>
</div>
EOD;
}
echo "</table>";
}
else{
echo "No Results Found";
}
}
else{
echo "Oops !! You Pressed Refresh Button or Minimum Input Value is $min_length";
}
?>
</table>
</body>
</html>
You're setting row data to $results, but never using it.
(In here: while ($results = mysql_fetch_assoc($raw_results)) { )
Either use extract($results) after the above code to use column names as variables like in your code or use variables as $results['name'].
Try mysql_fetch_array() instead of mysql_fetch_assoc() then print the result with the index no of column like the following
$result[0]
For Example if the name column is the 1st column in your table then use $result[0] similarly if it is 2nd, then use $result[1]
Try this and let me know
You should have:
$name here should be $results['name']
$file here should be $results['file']
$fname here should be $results['fname']
$mname here should be $results['mname']
$mobile here should be $results['mobile']
and so on with the other data on your table.
And also delete one of your </table> cause in your code you have 2 of it.
Related
I am trying to test out having multiple tables with various types of rows displayed on the webpage.
I am then using CSS Columns property to break the content in 4 columns.
My problem when the column finish; it continues the content on the next column. The tables I have can have multiple rows some have 10, some have 5 etc...
What I wanted to do is get page look a bit neater. If you see the picture I have attached below - I have some tables going to the next column.
What is the best practice or how to make this webpage look like a nice grid?
Here is how it looks
Here is the code:
<div class="row test">
<div class="panel panel-success">
<div class="panel-heading">Customer Test</div>
<div class="panel-body">
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">First</th>
<th scope="col">Last</th>
<th scope="col">Handle</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td>Mark</td>
<td>Otto</td>
<td>#mdo</td>
</tr>
<tr>
<th scope="row">2</th>
<td>Jacob</td>
<td>Thornton</td>
<td>#fat</td>
</tr>
<tr>
<th scope="row">3</th>
<td>Larry</td>
<td>the Bird</td>
<td>#twitter</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="panel panel-success">
<div class="panel-heading">Customer Test</div>
<div class="panel-body">
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">First</th>
<th scope="col">Last</th>
<th scope="col">Handle</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td>Mark</td>
<td>Otto</td>
<td>#mdo</td>
</tr>
<tr>
<th scope="row">2</th>
<td>Jacob</td>
<td>Thornton</td>
<td>#fat</td>
</tr>
<tr>
<th scope="row">3</th>
<td>Larry</td>
<td>the Bird</td>
<td>#twitter</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="panel panel-success">
<div class="panel-heading">Customer Test</div>
<div class="panel-body">
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">First</th>
<th scope="col">Last</th>
<th scope="col">Handle</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td>Mark</td>
<td>Otto</td>
<td>#mdo</td>
</tr>
<tr>
<th scope="row">2</th>
<td>Jacob</td>
<td>Thornton</td>
<td>#fat</td>
</tr>
<tr>
<th scope="row">3</th>
<td>Larry</td>
<td>the Bird</td>
<td>#twitter</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="panel panel-success">
<div class="panel-heading">Customer Test</div>
<div class="panel-body">
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">First</th>
<th scope="col">Last</th>
<th scope="col">Handle</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td>Mark</td>
<td>Otto</td>
<td>#mdo</td>
</tr>
<tr>
<th scope="row">2</th>
<td>Jacob</td>
<td>Thornton</td>
<td>#fat</td>
</tr>
<tr>
<th scope="row">3</th>
<td>Larry</td>
<td>the Bird</td>
<td>#twitter</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="panel panel-success">
<div class="panel-heading">Customer Test</div>
<div class="panel-body">
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">First</th>
<th scope="col">Last</th>
<th scope="col">Handle</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td>Mark</td>
<td>Otto</td>
<td>#mdo</td>
</tr>
<tr>
<th scope="row">2</th>
<td>Jacob</td>
<td>Thornton</td>
<td>#fat</td>
</tr>
<tr>
<th scope="row">3</th>
<td>Larry</td>
<td>the Bird</td>
<td>#twitter</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="panel panel-success">
<div class="panel-heading">Customer Test</div>
<div class="panel-body">
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">First</th>
<th scope="col">Last</th>
<th scope="col">Handle</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td>Mark</td>
<td>Otto</td>
<td>#mdo</td>
</tr>
<tr>
<th scope="row">2</th>
<td>Jacob</td>
<td>Thornton</td>
<td>#fat</td>
</tr>
<tr>
<th scope="row">3</th>
<td>Larry</td>
<td>the Bird</td>
<td>#twitter</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="panel panel-success">
<div class="panel-heading">Customer Test</div>
<div class="panel-body">
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">First</th>
<th scope="col">Last</th>
<th scope="col">Handle</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td>Mark</td>
<td>Otto</td>
<td>#mdo</td>
</tr>
<tr>
<th scope="row">2</th>
<td>Jacob</td>
<td>Thornton</td>
<td>#fat</td>
</tr>
<tr>
<th scope="row">2</th>
<td>Jacob</td>
<td>Thornton</td>
<td>#fat</td>
</tr>
<tr>
<th scope="row">2</th>
<td>Jacob</td>
<td>Thornton</td>
<td>#fat</td>
</tr>
<tr>
<th scope="row">3</th>
<td>Larry</td>
<td>the Bird</td>
<td>#twitter</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="panel panel-success">
<div class="panel-heading">Customer Test</div>
<div class="panel-body">
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">First</th>
<th scope="col">Last</th>
<th scope="col">Handle</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td>Mark</td>
<td>Otto</td>
<td>#mdo</td>
</tr>
<tr>
<th scope="row">2</th>
<td>Jacob</td>
<td>Thornton</td>
<td>#fat</td>
</tr>
<tr>
<th scope="row">3</th>
<td>Larry</td>
<td>the Bird</td>
<td>#twitter</td>
</tr>
<tr>
<th scope="row">3</th>
<td>Larry</td>
<td>the Bird</td>
<td>#twitter</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</body>
</html>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<!-- Bootstrap Stles -->
<script src="bootstrap-3.4.1/js/bootstrap.js"></script>
<script src="bootstrap-3.4.1/js/bootstrap.min.js"></script>
<style>
.navbar{
background-color: #EB4646;
border-radius: 0px;
color: white;
padding: 0.2%;
}
.test {
-webkit-column-count: 5;
-moz-column-count: 5;
column-count: 5;
</style>
Edit Answer
How it looks again
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++;
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'm having some issues getting all the data I need from two specific html tables. Tables at the bottom of this post.
The code above states html table id "table1". I also need to grab values from a table called "table2" in the exact same format. I have tried this code and can extract the td values but not the few values that are within the span specifiers within the td. I've tried multiple ways to do this but I'm just not getting it. My code looks something like:
$dom = file_get_html("internets.html);
//not sure how to specify the table exactly!? because this code didn't work.
//$tds = $dom->find('table[id=table1]',0)->find('tr');
foreach($dom->find('tr') as $key => $tr)
{
$td = $tr->find('td');
echo $td[0]->innertext . "</br>";
}
Any assistance much appreciated. I have done some searching here and also used the simple php dom manual.
Here is the format of a table:
<table id="table1">
<tbody>
<tr>
<th width="48%" scope="row">
Prev Close:
</th>
<td class="yfnc_tabledata1">
0.02
</td>
</tr>
<tr>
<th width="48%" scope="row">
Open:
</th>
<td class="yfnc_tabledata1">
0.02
</td>
</tr>
<tr>
<th width="48%" scope="row">
Bid:
</th>
<td class="yfnc_tabledata1">
<span id="yfs_b00_pgo.ax">
0.0180
</span>
</td>
</tr>
<tr>
<th width="48%" scope="row"></th>
<td class="yfnc_tabledata1"></td>
</tr>
<tr>
<th width="48%" scope="row">
1y Target Est:
</th>
<td class="yfnc_tabledata1">
N/A
</td>
</tr>
<tr>
<th width="48%" scope="row">
Beta:
</th>
<td class="yfnc_tabledata1">
N/A
</td>
</tr>
<tr>
<th width="54%" scope="row">
Next Earnings Date:
</th>
<td class="yfnc_tabledata1">
N/A
</td>
</tr>
</tbody>
</table>
<?php
$html=<<<XHTML
<table id="table1">
<tbody>
<tr>
<th width="48%" scope="row">
Prev Close:
</th>
<td class="yfnc_tabledata1">
0.02
</td>
</tr>
<tr>
<th width="48%" scope="row">
Open:
</th>
<td class="yfnc_tabledata1">
0.02
</td>
</tr>
<tr>
<th width="48%" scope="row">
Bid:
</th>
<td class="yfnc_tabledata1">
<span id="yfs_b00_pgo.ax">
0.0180
</span>
</td>
</tr>
<tr>
<th width="48%" scope="row"></th>
<td class="yfnc_tabledata1"></td>
</tr>
<tr>
<th width="48%" scope="row">
1y Target Est:
</th>
<td class="yfnc_tabledata1">
N/A
</td>
</tr>
<tr>
<th width="48%" scope="row">
Beta:
</th>
<td class="yfnc_tabledata1">
N/A
</td>
</tr>
<tr>
<th width="54%" scope="row">
Next Earnings Date:
</th>
<td class="yfnc_tabledata1">
N/A
</td>
</tr>
</tbody>
</table>
XHTML;
$dom = new DOMDocument;
$dom->loadHTML($html);
$xp = new DOMXPath($dom);
foreach ($xp->query("/*//table[#id='table1'//*/td") as $i=>$node) {
echo $node->nodeValue;
}
?>