PHP curl. Traversing search results - php

I am working on a website that allows people to search for an 'x' product and display the results in a table format for example.
I am planning on scraping the search data from another website using php curl. (the owner of the website being scraped is aware and allows it, so no legal issues there).
I already have a php curl code to go and login to the website, and do a search based on user inputs. I have no idea how to go thru the results of the search and output then in my website one by one.
PHP curl code:
$username = '********';
$password = '********';
$loginUrl = 'http://www.a-website.com/login.asp';
//init curl
$ch = curl_init();
//Set the URL to work with
curl_setopt($ch, CURLOPT_URL, $loginUrl);
// ENABLE HTTP POST
curl_setopt($ch, CURLOPT_POST, 1);
//Set the post parameters
curl_setopt($ch, CURLOPT_POSTFIELDS, 'username=' . $username . '&password=' . $password . '&submit1=' . 'Login');
//Handle cookies for the login
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie stuff hure');
//Setting CURLOPT_RETURNTRANSFER variable to 1 will force cURL
//not to print out the results of its query.
//Instead, it will return the results as a string return value
//from curl_exec() instead of the usual true/false.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//execute the request (the login)
$store = curl_exec($ch);
/* * *****************SEARCH HERE****************** */
curl_setopt($ch, CURLOPT_URL, 'http://www.a-website.com/Index.asp');
//execute the request
$content = curl_exec($ch);
//Set the post parameters
curl_setopt($ch, CURLOPT_POSTFIELDS, 'search_txt_vs=' . '' . '&search_txt_UPC=' . '' . '&search_txt_Name=' . $searchString .
'&search_txt_Manufacturer=' . '' . '&submit=' . 'Search');
//execute the request (the search)
$Search = curl_exec($ch);
print CJSON::encode($Search);
print $Search;
//save the data to disk
print $content;
Here is the html code from the website Im scrapping (which btw is in old school table format)
<td colspan="3" height="100%" valign="top">
<table width="100%" border="0" cellpadding="2" cellspacing="0" bordercolor="#99CCCC" class="text">
<tbody>
<tr bgcolor="#9999CC">
<td align="right" class="calendar">Sort ></td>
<td align="center"> NDC
</td>
<td align="left"> Brand Name
</td>
<td align="center" colspan="2"> Strength
| UD
</td>
<td align="left"> Stock
</td>
<td align="center"> Manufacturer
</td>
<td align="center" bgcolor="cccccc"> AWP
/ Your Price
</td>
</tr>
<tr bgcolor="#9999CC">
<td align="right" class="calendar"> </td>
<td align="center"> UPC
</td>
<td align="left"> Generic Alt/Name
</td>
<td align="center" colspan="2"> Size
| Form
</td>
<td align="left" colspan="3" class="selected">Category</td>
</tr>
<tr bgcolor="eeeeee">
<td align="center" valign="top" rowspan="2">1
<br> <span class="smallNorm_red">[add]</span>
</td>
<td align="center"><span class="smallNorm">00169347718</span>
</td>
<td align="left"><span class="smallNorm_red">NOVOLIN 70/ 30U/ML CRT 5X3 ML</span>
</td>
<td align="center" colspan="2"><span class="smallNorm"> 70-30 U/ML</span>
</td>
<td align="left"><span class="smallNorm">YES</span>
</td>
<td align="center"><span class="smallNorm">NOVO NORDISK PHARM</span>
</td>
<td align="center"><span class="smallNorm">$
0.01
/ $
0.01
</span>
</td>
</tr>
<tr bgcolor="eeeeee">
<td align="center"><span class="smallNorm">000000000000</span>
</td>
<td align="left"><span class="smallNorm">HUM INSULIN NPH/REG INSULIN HM</span>
</td>
<td align="center" colspan="2"><span class="smallNorm"> 5X3ML </span>
</td>
<td align="left" colspan="3"><span class="smallNorm">
<a href="#" onclick="return openreturn(19112,0.01021);"><span class="smallNorm_red">[return]</span>
</a>INSULIN</span>
</td>
</tr>
<tr bgcolor="#99CCCC">
<td align="center" valign="top" rowspan="2">2
<br> <span class="smallNorm_red">[add]</span>
</td>
<td align="center"><span class="smallNorm">00169347418</span>
</td>
<td align="left"><span class="smallNorm_red">NOVOLIN N 100 UN/ML CRT 5X3 ML</span>
</td>
<td align="center" colspan="2"><span class="smallNorm"> 100 U/ML</span>
</td>
<td align="left"><span class="smallNorm">YES</span>
</td>
<td align="center"><span class="smallNorm">NNP</span>
</td>
<td align="center"><span class="smallNorm">$
0.00
/ $
0.01
</span>
</td>
</tr>
<tr bgcolor="#99CCCC">
<td align="center"><span class="smallNorm">000000000000</span>
</td>
<td align="left"><span class="smallNorm">NPH HUMAN INSULIN ISOPHANE</span>
</td>
<td align="center" colspan="2"><span class="smallNorm"> 5X3ML </span>
</td>
<td align="left" colspan="3"><span class="smallNorm">
<a href="#" onclick="return openreturn(19116,0.012);"><span class="smallNorm_red">[return]</span>
</a>INSULIN</span>
</td>
</tr>
<tr bgcolor="eeeeee">
<td align="center" valign="top" rowspan="2">3
<br> <span class="smallNorm_red">[add]</span>
</td>
<td align="center"><span class="smallNorm">00169231721</span>
</td>
<td align="left"><span class="smallNorm_red">NOVOLIN INNO 70/30 PFS 5X3 ML</span>
</td>
<td align="center" colspan="2"><span class="smallNorm"> 70-30 U/ML</span>
</td>
<td align="left"><span class="smallNorm">YES</span>
</td>
<td align="center"><span class="smallNorm">NOVO NORDISK PHARM</span>
</td>
<td align="center"><span class="smallNorm">$
0.00
/ $
0.01
</span>
</td>
</tr>
<tr bgcolor="eeeeee">
<td align="center"><span class="smallNorm">000000000000</span>
</td>
<td align="left"><span class="smallNorm">HUM INSULIN NPH/REG INSULIN HM</span>
</td>
<td align="center" colspan="2"><span class="smallNorm"> 5X3ML </span>
</td>
<td align="left" colspan="3"><span class="smallNorm">
<a href="#" onclick="return openreturn(45211,0.012);"><span class="smallNorm_red">[return]</span>
</a>INSULIN</span>
</td>
</tr>
<tr bgcolor="#99CCCC">
<td align="center" valign="top" rowspan="2">4
<br> <span class="smallNorm_red">[add]</span>
</td>
<td align="center"><span class="smallNorm">00169183311</span>
</td>
<td align="left"><span class="smallNorm_red">NOVOLIN R 100 UN/ML VL 10 ML</span>
</td>
<td align="center" colspan="2"><span class="smallNorm"> 100 U/ML</span>
</td>
<td align="left"><span class="smallNorm">YES</span>
</td>
<td align="center"><span class="smallNorm">NOVO NORDISK PHARM</span>
</td>
<td align="center"><span class="smallNorm">$
99.00
/ $
82.09
</span>
</td>
</tr>
<tr bgcolor="#99CCCC">
<td align="center"><span class="smallNorm">000169183311</span>
</td>
<td align="left"><span class="smallNorm">INSULIN REGULAR HUMAN</span>
</td>
<td align="center" colspan="2"><span class="smallNorm"> 10ML </span>
</td>
<td align="left" colspan="3"><span class="smallNorm">
<a href="#" onclick="return openreturn(19117,82.0884);"><span class="smallNorm_red">[return]</span>
</a>INSULIN</span>
</td>
</tr>
<tr bgcolor="eeeeee">
<td align="center" valign="top" rowspan="2">5
<br> <span class="smallNorm_red">[add]</span>
</td>
<td align="center"><span class="smallNorm">00169183711</span>
</td>
<td align="left"><span class="smallNorm_red">NOVOLIN 70/ 30U/ML VL 10 ML</span>
</td>
<td align="center" colspan="2"><span class="smallNorm"> 70-30 U/ML</span>
</td>
<td align="left"><span class="smallNorm">YES</span>
</td>
<td align="center"><span class="smallNorm">NOVO NORDISK PHARM</span>
</td>
<td align="center"><span class="smallNorm">$
99.00
/ $
82.09
</span>
</td>
</tr>
<tr bgcolor="eeeeee">
<td align="center"><span class="smallNorm">000169183711</span>
</td>
<td align="left"><span class="smallNorm">HUM INSULIN NPH/REG INSULIN HM</span>
</td>
<td align="center" colspan="2"><span class="smallNorm"> 10ML </span>
</td>
<td align="left" colspan="3"><span class="smallNorm">
<a href="#" onclick="return openreturn(19110,82.0884);"><span class="smallNorm_red">[return]</span>
</a>INSULIN</span>
</td>
</tr>
<tr bgcolor="#99CCCC">
<td align="center" valign="top" rowspan="2">6
<br> <span class="smallNorm_red">[add]</span>
</td>
<td align="center"><span class="smallNorm">00169183411</span>
</td>
<td align="left"><span class="smallNorm_red">NOVOLIN N 100 UN/ML VL 10 ML</span>
</td>
<td align="center" colspan="2"><span class="smallNorm"> 100 U/ML</span>
</td>
<td align="left"><span class="smallNorm">YES</span>
</td>
<td align="center"><span class="smallNorm">NOVO NORDISK PHARM</span>
</td>
<td align="center"><span class="smallNorm">$
99.00
/ $
82.09
</span>
</td>
</tr>
<tr bgcolor="#99CCCC">
<td align="center"><span class="smallNorm">000000000000</span>
</td>
<td align="left"><span class="smallNorm">NPH HUMAN INSULIN ISOPHANE</span>
</td>
<td align="center" colspan="2"><span class="smallNorm"> 10ML </span>
</td>
<td align="left" colspan="3"><span class="smallNorm">
<a href="#" onclick="return openreturn(19114,82.0884);"><span class="smallNorm_red">[return]</span>
</a>INSULIN</span>
</td>
</tr>
</tbody>
</table>
</td>

You could try adding the string to a DOMDocument and use the getElementsByTagName and then write them into an array or something you can use. More information here: http://php.net/manual/en/domdocument.getelementsbytagname.php
Also, similar question was answered here, considering you're returning HTML:PHP parse HTML tags

Related

Adding next row fields to previous row in mySQL using PHP

I have a table with unix timestamp, userID, Long and lat. I would like to copy the value of Long and Lat from the following row and add them to that row. Please see below.
<table style="width: 645px;" border="0" cellspacing="0" cellpadding="0">
<colgroup>
<col width="140" />
<col width="57" />
<col span="7" width="64" />
</colgroup>
<tbody>
<tr>
<td class="xl66" width="140" height="21">Unix Time Stamp</td>
<td class="xl66" width="57"> </td>
<td class="xl66" width="64">Long</td>
<td class="xl66" width="64"> </td>
<td class="xl66" width="64">Lat</td>
<td class="xl66" width="64"> </td>
<td class="xl66" width="64"> </td>
<td class="xl66" width="64"> </td>
<td class="xl66" width="64"> </td>
</tr>
<tr>
<td class="xl67" align="right" width="140" height="20">1458119939</td>
<td class="xl77" width="57"> </td>
<td class="xl70" align="right">-26.2004</td>
<td class="xl70"> </td>
<td class="xl70" align="right">28.01277</td>
<td class="xl70"> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td class="xl68" align="right" width="140" height="21">1458119940</td>
<td class="xl77" width="57"> </td>
<td class="xl70" align="right">26.20654</td>
<td class="xl70"> </td>
<td class="xl70" align="right">28.04565</td>
<td class="xl70"> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td class="xl68" align="right" width="140" height="20">1458128756</td>
<td class="xl71" width="57"> </td>
<td class="xl71" align="right" width="64">-29.0065</td>
<td class="xl77" width="64"> </td>
<td class="xl72" align="right" width="64">29.88437</td>
<td class="xl77" width="64"> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td class="xl68" align="right" width="140" height="20">1458128757</td>
<td class="xl71" width="57"> </td>
<td class="xl71" align="right" width="64">-29.0067</td>
<td class="xl77" width="64"> </td>
<td class="xl72" align="right" width="64">29.88465</td>
<td class="xl77" width="64"> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td class="xl68" align="right" width="140" height="20">1442829381</td>
<td class="xl71" width="57"> </td>
<td class="xl71" align="right" width="64">-29.0064</td>
<td class="xl77" width="64"> </td>
<td class="xl72" align="right" width="64">29.88458</td>
<td class="xl77" width="64"> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td class="xl68" align="right" width="140" height="21">1442829397</td>
<td class="xl71" width="57"> </td>
<td class="xl73" align="right" width="64">-29.0062</td>
<td class="xl78" width="64"> </td>
<td class="xl74" align="right" width="64">29.88436</td>
<td class="xl77" width="64"> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td class="xl69" align="right" width="140" height="21">1442830988</td>
<td class="xl73" width="57"> </td>
<td class="xl75" align="right" width="64">-26.2065</td>
<td class="xl79" width="64"> </td>
<td class="xl76" align="right" width="64">28.04565</td>
<td class="xl77" width="64"> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="20"> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="20"> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td class="xl65" colspan="3" height="20">Query Result needs to look like</td>
<td class="xl65"> </td>
<td class="xl65"> </td>
<td class="xl65"> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td class="xl66" height="21">Unix Time Stamp</td>
<td class="xl66"> </td>
<td class="xl66">Long</td>
<td class="xl66"> </td>
<td class="xl66">Lat</td>
<td class="xl66"> </td>
<td class="xl66">LongB</td>
<td class="xl66"> </td>
<td class="xl66">LatB</td>
</tr>
<tr>
<td class="xl67" align="right" width="140" height="20">1458119939</td>
<td class="xl77" width="57"> </td>
<td class="xl70" align="right">-26.2004</td>
<td class="xl70"> </td>
<td class="xl70" align="right">28.01277</td>
<td class="xl70"> </td>
<td class="xl70" align="right">26.20654</td>
<td class="xl70"> </td>
<td class="xl70" align="right">28.04565</td>
</tr>
<tr>
<td class="xl68" align="right" width="140" height="20">1458119940</td>
<td class="xl77" width="57"> </td>
<td class="xl70" align="right">26.20654</td>
<td class="xl70"> </td>
<td class="xl70" align="right">28.04565</td>
<td class="xl70"> </td>
<td class="xl71" align="right" width="64">-29.0065</td>
<td class="xl77" width="64"> </td>
<td class="xl72" align="right" width="64">29.88437</td>
</tr>
<tr>
<td class="xl68" align="right" width="140" height="20">1458128756</td>
<td class="xl71" width="57"> </td>
<td class="xl71" align="right" width="64">-29.0065</td>
<td class="xl77" width="64"> </td>
<td class="xl72" align="right" width="64">29.88437</td>
<td class="xl77" width="64"> </td>
<td class="xl71" align="right" width="64">-29.0067</td>
<td class="xl77" width="64"> </td>
<td class="xl72" align="right" width="64">29.88465</td>
</tr>
<tr>
<td class="xl68" align="right" width="140" height="20">1458128757</td>
<td class="xl71" width="57"> </td>
<td class="xl71" align="right" width="64">-29.0067</td>
<td class="xl77" width="64"> </td>
<td class="xl72" align="right" width="64">29.88465</td>
<td class="xl77" width="64"> </td>
<td class="xl71" align="right" width="64">-29.0064</td>
<td class="xl77" width="64"> </td>
<td class="xl72" align="right" width="64">29.88458</td>
</tr>
<tr>
<td class="xl68" align="right" width="140" height="21">1442829381</td>
<td class="xl71" width="57"> </td>
<td class="xl71" align="right" width="64">-29.0064</td>
<td class="xl77" width="64"> </td>
<td class="xl72" align="right" width="64">29.88458</td>
<td class="xl77" width="64"> </td>
<td class="xl73" align="right" width="64">-29.0062</td>
<td class="xl78" width="64"> </td>
<td class="xl74" align="right" width="64">29.88436</td>
</tr>
<tr>
<td class="xl68" align="right" width="140" height="21">1442829397</td>
<td class="xl71" width="57"> </td>
<td class="xl73" align="right" width="64">-29.0062</td>
<td class="xl78" width="64"> </td>
<td class="xl74" align="right" width="64">29.88436</td>
<td class="xl78" width="64"> </td>
<td class="xl75" align="right" width="64">-26.2065</td>
<td class="xl79" width="64"> </td>
<td class="xl76" align="right" width="64">28.04565</td>
</tr>
</tbody>
</table>
Your help would be very much appreciated.
SELECT timestamp, userID, Long, Lat, Long as LongB, Lat as LatB FROM table
I think you meant column instead of row

xpath got wrong html attribute

So, I have this PHP scraper code and HTML below that I want to scrape using Xpath.
When I try to scrape every #href, it shows outerHTML 14, when it is supposes to be 14
The #href is cut in half where the space are. What causes this?
$content = $xpath->query('//a');
foreach($content as $c){
var_dump(htmlspecialchars($c->C14N())); echo '<br>';
}
The one above is the CURL code.
Here is the HTML.
<div class="outercalendar" id="maincalendar821"><table class="calendarHeader">
<tbody><tr>
<td><input type="button" onclick="AjxGetMainCalendarMonth('2', '2015', '821')" value="<"></td>
<td class="calendarHeader" colspan="5">March 2015</td>
<td><input type="button" onclick="AjxGetMainCalendarMonth('4', '2015', '821')" value=">"></td>
</tr>
</tbody></table>
<table class="calendar">
<tbody><tr>
<td class="calendarDay">S</td>
<td class="calendarDay">M</td>
<td class="calendarDay">T</td>
<td class="calendarDay">W</td>
<td class="calendarDay">T</td>
<td class="calendarDay">F</td>
<td class="calendarDay">S</td>
</tr>
<tr>
<td class="calendar">1</td>
<td class="calendar"> </td>
<td class="calendar"> </td>
<td class="calendar"> </td>
<td class="calendar"> </td>
<td class="calendar"> </td>
<td class="calendar">7</td>
</tr>
<tr>
<td class="calendar">8</td>
<td class="calendar"> </td>
<td class="calendar"> </td>
<td class="calendar"> </td>
<td class="calendar"> </td>
<td class="calendar"> </td>
<td class="calendar">14</td>
</tr>
<tr>
<td class="calendar">15</td>
<td class="calendar"> </td>
<td class="calendar"> </td>
<td class="calendar"> </td>
<td class="calendar"> </td>
<td class="calendar"> </td>
<td class="calendar">21</td>
</tr>
<tr>
<td class="calendar">22</td>
<td class="calendar"> </td>
<td class="calendar"> </td>
<td class="calendar"> </td>
<td class="calendar"> </td>
<td class="calendar"> </td>
<td class="calendar">28</td>
</tr>
<tr>
<td class="calendar">29</td>
<td class="calendar"> </td>
<td class="calendar"> </td>
<td class="calendar"> </td>
<td class="calendar"> </td>
<td class="calendar"> </td>
<td class="calendar"> </td>
</tr>
</tbody></table>
</div>
The issue could be in the structure of the info stored in the tag.
I would suggest starting with a more detailed xpath:
//a/#href
so your initial code would be:
$content = $xpath->query('//a/#href');

Getting tags in DOMDocument

I'm trying to get the HTML markup of a table in a page:
$new_dom = new DOMDocument();
$table = '';
$nodesTable = $this->dom->getElementsbyTagName("table");
foreach($nodesTable as $nodeTable){
$color = $nodeTable->getAttribute('bordercolordark');
if ($color == '#73BAFF') {
$table = $nodeTable;
}
}
$new_dom->appendChild($table);
echo $new_dom->saveHTML();
Here is somepage.html:
<html>
<table>
<tr> <td> 10 </td> </tr>
<tr> <td> 10 </td> </tr>
<tr> <td> 10 </td> </tr>
<tr> <td> 10 </td> </tr>
</table>
<table border="1" cellpadding="0" width="500" bordercolorlight="#ACD6FF" bordercolordark="#73BAFF" align="center">
<tr>
<td rowspan="2" colspan="2" bgcolor="#73BAFF"> </td>
<td colspan="3" align="center" bgcolor="#ACD6FF"> Element 1 </td>
<td colspan="3" align="center" bgcolor="#ACD6FF"> Element 2 </td>
</tr>
<tr>
<td width="50" align="center" bgcolor="#ACD6FF"> 50 </td>
<td width="50" align="center" bgcolor="#ACD6FF"> 50 </td>
<td width="50" align="center" bgcolor="#ACD6FF"> 50 </td>
<td width="50" align="center" bgcolor="#ACD6FF"> 50 </td>
<td width="50" align="center" bgcolor="#ACD6FF"> 50 </td>
<td width="50" align="center" bgcolor="#ACD6FF"> 50 </td>
</tr>
<tr>
<td bgcolor="#ACD6FF" width="155" align="center"> Row 1</td>
<td bgcolor="#ACD6FF" width="45" align="center"> 30 </td>
<td align="center"> 50 </td>
<td align="center"> 50 </td>
<td align="center"> 50 </td>
<td align="center"> 50 </td>
<td align="center"> 50 </td>
<td align="center"> 50 </td>
</tr>
<tr>
<td bgcolor="#ACD6FF" width="155" align="center"> Row 2</td>
<td bgcolor="#ACD6FF" width="45" align="center"> 30 </td>
<td align="center"> 60 </td>
<td align="center"> 60 </td>
<td align="center"> 60 </td>
<td align="center"> 60 </td>
<td align="center"> 60 </td>
<td align="center"> 60 </td>
</tr>
<tr>
<td bgcolor="#ACD6FF" width="155" align="center"> Row 3</td>
<td bgcolor="#ACD6FF" width="45" align="center"> 30 </td>
<td align="center"> 70 </td>
<td align="center"> 70 </td>
<td align="center"> 70 </td>
<td align="center"> 70 </td>
<td align="center"> 70 </td>
<td align="center"> 70 </td>
</tr>
</table>
<table>
<tr> <td> 10 </td> </tr>
<tr> <td> 10 </td> </tr>
<tr> <td> 10 </td> </tr>
<tr> <td> 10 </td> </tr>
</table>
<table>
<tr> <td> 10 </td> </tr>
<tr> <td> 10 </td> </tr>
<tr> <td> 10 </td> </tr>
<tr> <td> 10 </td> </tr>
</table>
</html>
$new_dom just outputs \n instead of HTML markup. I tried looking at this answer: PHP DOMDocument stripping HTML tags, but appending the table this way didn't work either.
Fatal error: Uncaught exception 'DOMException' with message 'Wrong Document Error'
So you cannot move nodes from one document to another... If you want to do that, you have to use importNode() with the deep flag.
$dom = new DOMDocument();
$dom->loadHTMLFile('x.html');
$new_dom = new DOMDocument();
$table = '';
$nodesTable = $dom->getElementsbyTagName("table");
foreach($nodesTable as $nodeTable){
$color = $nodeTable->getAttribute('bordercolordark');
if ($color == '#73BAFF') {
$table = $new_dom->importNode($nodeTable, true);
}
}
$new_dom->appendChild($table);
echo $new_dom->saveHTML();
This imports only the table element, but not the children...
note: I'd disable the entity loader in your case libxml_disable_entity_loader(true);. I am not sure whether XEE attacks work with loadHTML() too, but just for the sake of security.

Cannot Modify Header Iformation

I am getting this error:
Warning: Cannot modify header information - headers already sent by (output started at /home/renta142/public_html/includes/connection_prop.php:14) in /home/renta142/public_html/login.php on line 31
My PHP Code is:
<?php
session_start();
if($_SESSION['user']['id']!=""){
header("location:index.php");
exit();
}
$login_email=$_POST[email];
$username=$_POST[username1];
$name=$_POST[name];
$er=$_POST[er];
if(trim($_POST["SignIn"])=="Sign In"){
include("includes/connection_user.php");
$user_=$_POST["username"];
$pass=$_POST["pass"];
$query=mysql_query("select * from user_registration where UserID='".$user_."' and Password='".$pass."' and Display='1'");
$result=mysql_fetch_array($query);
if(!strcmp($result[Password],$pass)){
$_SESSION['user']['id'] = $result[AID];
$_SESSION['user']['password'] = $result[Password];
$_SESSION['user']['username'] = $result[UserID];
$_SESSION['user']['name']=$result[Name];
$ref=$_SESSION["refer_url"];
if($_REQUEST['ref']=="sell"){
header("Location:postproperty_sell.php");
exit();
}
else if($ref==""){
header("Location:postproperty.php");
exit();
}
else{
header("Location:$ref");
exit();
}
}else{
$errsg="Invalid Username and Password !";
}
mysql_close();
}
include("config.php");
$sitename=ucfirst($thirdsite)." - Property in ".ucfirst($addresscity);
$keys="property in ".ucfirst($addresscity);
$desc="Real estate agents offers - property in ".ucfirst($addresscity);
include("includes/header.php");
include("includes/left.php");
?>
<script language='javascript' src="images/script.js"></script>
<script type="text/javascript">
function popUp_file(URL){
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=1,statusbar=0,menubar=0,resizable=0,width=900,height=600');");
}
<?php if($_REQUEST[fcode]=='wrong'){?>
window.onload=function(){document.getElementById('fpass').style.display='block';}
<?php }?>
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
//-->
</script>
<td valign="top" align="center" colspan="2">
<table width="794" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="1%" align="right" valign="bottom"><img src="images/11.jpg" width="10" height="10" alt="" /></td>
<td width="97%" style="background:url(images/12.jpg) repeat-x bottom;"> </td>
<td width="2%" align="left" valign="bottom"><img src="images/13.jpg" width="10" height="10" alt="" /></td>
</tr>
<tr>
<td style="background:url(images/21.jpg) repeat-y right;"> </td>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="left" class="green"> </td>
<td> </td>
</tr>
<tr>
<td align="left" valign="middle" class="green"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="5%"><img src="images/customer_login.gif" alt="CUSTOMER LOGIN" width="24" height="23" /></td>
<td width="92%">PROPERTY OWNER LOGIN </td>
</tr>
</table></td>
<td align="left" class="green"><table width="100%" border="0" cellpadding="00" cellspacing="0">
<tr>
<td width="5%"><img src="images/mbenifites.gif" alt="MEMBERSHIP BENEFITS" width="16" height="17" /></td>
<td width="92%"> FREE MEMBERSHIP BENEFITS</td>
</tr>
</table></td>
</tr>
<tr>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
<tr>
<td width="50%" valign="top"><?php if($errsg){ echo "<br /><div class='alert' align='center'>".$errsg."</div><br />"; } ?>
<table width="100%" cellpadding="4" cellspacing="1" class="heading" valign="top">
<form action="login.php?ref=<?php echo $_REQUEST['ref']; ?>" method="post" name="signin" id="signin" onsubmit="return loginform();">
<tr>
<td class="txt">Username<font color="red">*</font></td>
<td width="1" align="left"><strong>:</strong></td>
<td align="left"><input name="username" type="text" id="username" onfocus="if(this.value=='Username') this.value='';" onblur="if(this.value=='') this.value='Username';" value="Username" /></td>
</tr>
<tr>
<td class="txt">Password<font color="red">*</font></td>
<td align="left"><strong>:</strong></td>
<td align="left"><input type="password" name="pass" onfocus="if(this.value=='**********') this.value='';" onblur="if(this.value=='') this.value='**********'" value="**********" /></td>
</tr>
<tr>
<td> </td>
<td align="left"> </td>
<td align="left"><input type="submit" name="SignIn" value="Sign In" class="button" /></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td align="left"><font color="#333333" size="2" face="Arial, Helvetica, sans-serif"> <img src="images/nuser.gif" alt="New User registration" width="19" height="21" alt="" /> New User ?</font><a href="login.php#reg"><font color="#0000FF" size="2" face="Arial, Helvetica, sans-serif">Register First</font><br />
</a> <font color="#0000FF" size="2" face="Arial, Helvetica, sans-serif">Forgot Password </font></td>
</tr>
</form>
</table></td>
<td width="50%" valign="top" style="background:url(images/login_page.jpg) no-repeat right; height:200px;"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="left" valign="top"><table width="100%" border="0" cellspacing="2" cellpadding="2">
<tr>
<td width="11%" align="center" valign="top" style="padding-top:8px;"><img src="images/bullet-cir1.jpg" width="8" height="8" alt="" /></td>
<td width="89%" valign="top"><font size="2" face="Arial, Helvetica, sans-serif">Advertise your properties for Sale/Rent/PG </font></td>
</tr>
<tr>
<td align="center" valign="top" style="padding-top:8px;"><img src="images/bullet-cir1.jpg" width="8" height="8" alt="" /></td>
<td valign="top"><font size="2" face="Arial, Helvetica, sans-serif">Get Special offers and freebies</font></td>
</tr>
<tr>
<td align="center" valign="top" style="padding-top:8px;"><img src="images/bullet-cir1.jpg" width="8" height="8" alt="" /></td>
<td valign="top"><font size="2" face="Arial, Helvetica, sans-serif">Get updates on our new products</font></td>
</tr>
<tr>
<td align="center" valign="top" style="padding-top:8px;"><img src="images/bullet-cir1.jpg" width="8" height="8" alt="" /></td>
<td valign="top"><font size="2" face="Arial, Helvetica, sans-serif">Response through mail, phone</font></td>
</tr>
</table> </td>
</tr>
</table></td></tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td colspan="2" ><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" style="border:#3399FF 1px solid;">
<tr>
<td align="left" bgcolor="#E1F1F4" style="padding-left:3px; padding-right:3px;"> <strong><font size="2" face="Arial, Helvetica, sans-serif"><img src="images/note.gif" alt="<?php echo $thirdsite ?>is commited your information is strictly confidential, unless you want to expose it." width="19" height="18" /> Note:</font></strong></td>
</tr>
<tr>
<td align="center" bgcolor="#E1F1F4" style="padding-left:3px; padding-right:3px;"><div align="justify" style="padding-left:3px; padding-right:3px;"><font color="#666666" size="2" face="Arial, Helvetica, sans-serif"> <?php echo ucfirst($thirdsite); ?> is commited your information is strictly confidential, unless you want to expose it.</font></div></td>
</tr>
<tr>
<td align="center" bgcolor="#E1F1F4"> </td>
</tr>
</table></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
</table></td>
<td style="background:url(images/22.jpg) repeat-y left;"> </td>
</tr>
<tr>
<td align="right" valign="top"><img src="images/31.jpg" width="10" height="10" alt="" /></td>
<td style="background:url(images/32.jpg) repeat-x top;"> </td>
<td align="left" valign="top"><img src="images/33.jpg" width="10" height="10" alt="" /></td>
</tr>
</table></td>
</tr>
<tr>
<td></td>
</tr>
</table>
<a name="fp"></a>
<div id="fpass" style="display:none;">
<table width="794" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="1%" align="right" valign="bottom"><img src="images/11.jpg" width="10" height="10" alt="" /></td>
<td width="97%" style="background:url(images/12.jpg) repeat-x bottom;"> </td>
<td width="2%" align="left" valign="bottom"><img src="images/13.jpg" width="10" height="10" alt="" /></td>
</tr>
<tr>
<td style="background:url(images/21.jpg) repeat-y right;"> </td>
<td align="left"> </td>
<td style="background:url(images/22.jpg) repeat-y left;"> </td>
</tr>
<tr>
<td style="background:url(images/21.jpg) repeat-y right;"> </td>
<td align="left"><table width="100%" border="0" cellpadding="00" cellspacing="0">
<tr>
<td width="3%"><span class="green"><img src="images/forget_pass.gif" alt="FORGOT PASSWORD" width="20" height="19" /></span></td>
<td width="97%"><span class="green"> FORGOT PASSWORD</span></td>
</tr>
</table></td>
<td style="background:url(images/22.jpg) repeat-y left;"> </td>
</tr>
<tr>
<td style="background:url(images/21.jpg) repeat-y right;"> </td>
<td><table width="100%" border="0" align="right" cellpadding="2" cellspacing="0">
<form action="forget_password_submit.php" method="post" name="forget_password" id="forget_password">
<input type="hidden" name="chk" value="2" />
<?php if($_GET[fcode]) echo ' <tr>
<td class="alert" align="center" colspan="3">Your EmailID or UserName Is Not Found In Our Database, Please Try Again!!!</td></tr>';?>
<tr >
<td width="20%" align="right" valign="top" class="txt"> Username</td>
<td width="2%" valign="top"><b>:</b></td>
<td width="78%" align="left" valign="top"><input type="text" name="username1" /></td>
</tr>
<tr>
<td colspan="2" align="right" class="heading"> OR</td>
<td class="heading" align="left"> </td>
</tr>
<tr>
<td align="right" valign="top" class="txt"> Email-ID</td>
<td valign="top"><b>:</b></td>
<td align="left" valign="top"><input type="text" name="email1" /></td>
</tr>
<tr>
<td colspan="3" align="right" height="8"></td>
</tr>
<tr>
<td align="right"> </td>
<td align="center"> </td>
<td align="left"><input name="submit" type="submit" onclick="return ForgetpassForm();" value="Submit" class="button" /></td>
</tr>
<tr>
<td align="right"> </td>
<td align="right"> </td>
<td align="left"><font color="#333333" size="2" face="Arial, Helvetica, sans-serif"><img src="images/login.gif" alt="Existin user login" width="19" height="21" /></font> <font color="#0000FF" size="2" face="Arial, Helvetica, sans-serif"><strong>Login</strong></font></td>
</tr>
<tr>
<td align="right" colspan="4" height="8"></td>
</tr>
<tr>
<td colspan="3" align="right"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" style="border:#3399FF 1px solid;">
<tr>
<td align="left" bgcolor="#E1F1F4" style="padding-left:3px; padding-right:3px;"> <strong><font size="2" face="Arial, Helvetica, sans-serif"><img src="images/note.gif" alt="Enter Your UserName or Email-ID which you had entered in registration form and get your password through eMail." width="19" height="18" /></font></strong><strong><font size="2" face="Arial, Helvetica, sans-serif"> Note:</font></strong></td>
</tr>
<tr>
<td align="center" bgcolor="#E1F1F4" style="padding-left:3px; padding-right:3px;"><div align="justify" style="padding-left:3px; padding-right:3px;"><span class="text"> Enter Your UserName or Email-ID which you had entered in registration form and get your password through eMail. </span></div></td>
</tr>
<tr>
<td align="center" bgcolor="#E1F1F4"> </td>
</tr>
</table></td>
</tr>
<tr>
<td colspan="3" align="center" height="7"></td>
</tr>
</form>
</table></td>
<td style="background:url(images/22.jpg) repeat-y left;"> </td>
</tr>
<tr>
<td align="right" valign="top"><img src="images/31.jpg" width="10" height="10" alt="" /></td>
<td style="background:url(images/32.jpg) repeat-x top;"> </td>
<td align="left" valign="top"><img src="images/33.jpg" width="10" height="10" alt="" /></td>
</tr>
</table></td>
</tr>
</table>
</div>
<?php //if($errsg=="Invalid Username and Password !"){?>
<a name="reg"></a>
<table width="794" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="1%" align="right" valign="bottom"><img src="images/11.jpg" width="10" height="10" alt="" /></td>
<td width="97%" style="background:url(images/12.jpg) repeat-x bottom;"> </td>
<td width="2%" align="left" valign="bottom"><img src="images/13.jpg" width="10" height="10" alt="" /></td>
</tr>
<tr>
<td style="background:url(images/21.jpg) repeat-y right;"> </td>
<td align="left"> </td>
<td style="background:url(images/22.jpg) repeat-y left;"> </td>
</tr>
<tr>
<td style="background:url(images/21.jpg) repeat-y right;"> </td>
<td align="left" class="heading"><table width="100%" border="0" cellpadding="00" cellspacing="0">
<tr>
<td width="3%"><img src="images/if_you_do.gif" alt="If you do not have an existing Customer Account with us fill in the form below" width="19" height="19" /></td>
<td width="97%"> If you do not have an existing User Account with us fill in the form below. </td>
</tr>
</table></td>
<td style="background:url(images/22.jpg) repeat-y left;"> </td>
</tr>
<tr>
<td style="background:url(images/21.jpg) repeat-y right;"> </td>
<td align="left"> </td>
<td style="background:url(images/22.jpg) repeat-y left;"> </td>
</tr>
<tr>
<td align="right" valign="top"><img src="images/31.jpg" width="10" height="10" alt="" /></td>
<td style="background:url(images/32.jpg) repeat-x top;"> </td>
<td align="left" valign="top"><img src="images/33.jpg" width="10" height="10" alt="" /></td>
</tr>
</table></td>
</tr>
</table>
<table width="794" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="1%" align="right" valign="bottom"><img src="images/11.jpg" width="10" height="10" alt="" /></td>
<td width="97%" style="background:url(images/12.jpg) repeat-x bottom;"> </td>
<td width="2%" align="left" valign="bottom"><img src="images/13.jpg" width="10" height="10" alt="" /></td>
</tr>
<tr>
<td style="background:url(images/21.jpg) repeat-y right;"> </td>
<td align="left" class="green"><table width="100%" border="0" cellpadding="00" cellspacing="0">
<tr>
<td width="5%"><img src="images/NEW-USER-REGISTER-FORM.gif" alt="NEW USER REGISTER FORM " width="26" height="27" /></td>
<td width="97%"> NEW USER REGISTER FORM </td>
</tr>
</table></td>
<td style="background:url(images/22.jpg) repeat-y left;"> </td>
</tr>
<tr>
<td style="background:url(images/21.jpg) repeat-y right;"> </td>
<td align="left"> </td>
<td style="background:url(images/22.jpg) repeat-y left;"> </td>
</tr>
<tr>
<td style="background:url(images/21.jpg) repeat-y right;"> </td>
<td align="left"><form name="register" method="POST" action="registration_submit.php?ref=<?php echo $_REQUEST['ref']; ?>" onsubmit="return registerForm();">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="50%" valign="top" style="border:#CCCCCC 1px solid;">
<table width="100%" cellpadding="4" cellspacing="0">
<tr>
<td bgcolor="#EEEEEE"><font size="2" face="Arial, Helvetica, sans-serif">User Login Information</font></td>
<td bgcolor="#EEEEEE"> </td>
<td align="right" bgcolor="#EEEEEE"><span class="alert">* Mandatory Fields</span></td>
</tr>
<tr>
<td width="39%" class="tdspace txt"><font color="red">*</font>Username</td>
<td width="3%">:</td>
<td width="58%"><input name="username" type="text" id="username" size="25" /></td>
</tr>
<tr>
<td class="tdspace txt"><font color="red">*</font>Password</td>
<td>:</td>
<td><input type="password" name="password" size="25" /></td>
</tr>
<tr>
<td class="tdspace txt"><font color="red">*</font>Confirm Password</td>
<td>:</td>
<td><input type="password" name="rpassword" size="25" /></td>
</tr>
<tr>
<td class="tdspace txt"><font color="red">*</font>Email-ID</td>
<td>:</td>
<td><input type="text" name="email" size="25" /></td>
</tr>
<tr>
<td colspan="3" bgcolor="#EEEEEE"><font size="2" face="Arial, Helvetica, sans-serif">Contact Information</font></td>
</tr>
<tr>
<td class="tdspace txt"><font color="red">*</font>Name</td>
<td>:</td>
<td><input type="text" name="name" size="25" /></td>
</tr>
<tr>
<td class="tdspace txt"><font color="red">*</font>Verification Code</td>
<td>:</td>
<td><input name="verify_code" type="text" size="15" />
<img src="verificationimage.php" alt="verification image, type it in the box" width="60" height="30" align="absbottom"/></td>
</tr>
<tr>
<td colspan="3" class="text"><input type="checkbox" name="term" />
I have read <font color="red">Terms and Conditions</font> and I accept these conditions.</td>
</tr>
<tr>
<td align="center"> </td>
<td align="center"> </td>
<td align="left"><input name="submit2" type="submit" value="Submit" class="button" />
<input name="reset" type="reset" value="Reset" class="button" />
<input name="flg" type="hidden" id="flg" value="1" /></td>
</tr>
</table></td>
<td width="1%" > </td>
<td width="49%" valign="top"><img src="images/register.jpg" alt="For Free registration on <?php echo ucfirst($thirdsite); ?>, Advertise your properties for Sale/Rent/PG, Get Special offers and freebies, Get updates on our new products, Response through mail, phone" width="380" height="380" /></td>
</tr>
</table>
</form></td>
<td style="background:url(images/22.jpg) repeat-y left;"> </td>
</tr>
<tr>
<td align="right" valign="top"><img src="images/31.jpg" width="10" height="10" alt="" /></td>
<td style="background:url(images/32.jpg) repeat-x top;"> </td>
<td align="left" valign="top"><img src="images/33.jpg" width="10" height="10" alt="" /></td>
</tr>
</table></td>
</tr>
</table>
<?php //}?>
</td>
<script language='javascript'>signin.username.focus();</script>
<?php
//include("includes/right.php");
include("includes/footer.php");
?>
public_html/includes/connection_prop.php:14 is probably outputting some blank spaces. Check that file and other includes for whitespace around tags.
You cannot send headers if any text has already been output

display column data in each table data

---------------------------------------------------------------------
Quantity | Unit | Detials of Items | ISSUED DATE | RETURNED |
| | | | |
---------------------------------------------------------------------
tbl col 1 |tbl col2 | tbl col2 | tbl col 3 | tbl col4 |
---------------------------------------------------------------------
say I have a table in the database that has 4 columns
and that is the table in my website
how would i display my table column data in each table data?
any suggestion please
I only have this codes so far as I am new to php i just use macromedia for the interface
$myServer = "server";
$myUser = "user";
$myPass = "password";
$myDB = "mssqldb";
//connection to the database
$dbhandle = mssql_connect($myServer, $myUser, $myPass)
or die("Couldn't connect to SQL Server on $myServer");
//select a database to work with
$selected = mssql_select_db($myDB, $dbhandle)
or die("Couldn't open database $myDB");
//declare the SQL statement that will query the database
$query = "SELECT eidnumber ";
$query .= "FROM tablename ";
<table width="935" height="102" border="1">
<tr>
<th width="89" rowspan="2" scope="col">Quantity</th>
<th width="87" rowspan="2" scope="col">Unit</th>
<th width="137" rowspan="2" scope="col">Details of Item(s) Accounted </th>
<th width="221" rowspan="2" scope="col">ISSUED DATE </th>
<th height="51" colspan="3" scope="col">RETURNED</th>
<th width="254" rowspan="2" scope="col">
<p>REMARKS</p> </th>
</tr>
<tr>
<th width="24" height="39" scope="col">C</th>
<th width="18" scope="col">X</th>
<th width="53" scope="col">DATE</th>
</tr>
</table>
<table width="935" border="1">
<tr>
<td width="90"> </td>
<td width="86"> </td>
<td width="137"> </td>
<td width="221"> </td>
<td width="24"> </td>
<td width="17"> </td>
<td width="55"> </td>
<td width="253"> </td>
</tr>
<tr>
<td width="90"> </td>
<td width="86"> </td>
<td width="137"> </td>
<td width="221"> </td>
<td width="24"> </td>
<td width="17"> </td>
<td width="55"> </td>
<td width="253"> </td>
</tr>
<tr>
<td width="90"> </td>
<td width="86"> </td>
<td width="137"> </td>
<td width="221"> </td>
<td width="24"> </td>
<td width="17"> </td>
<td width="55"> </td>
<td width="253"> </td>
</tr>
<tr>
<td width="90"> </td>
<td width="86"> </td>
<td width="137"> </td>
<td width="221"> </td>
<td width="24"> </td>
<td width="17"> </td>
<td width="55"> </td>
<td width="253"> </td>
</tr>
<tr>
<td width="90"> </td>
<td width="86"> </td>
<td width="137"> </td>
<td width="221"> </td>
<td width="24"> </td>
<td width="17"> </td>
<td width="55"> </td>
<td width="253"> </td>
</tr>
<tr>
<td width="90"> </td>
<td width="86"> </td>
<td width="137"> </td>
<td width="221"> </td>
<td width="24"> </td>
<td width="17"> </td>
<td width="55"> </td>
<td width="253"> </td>
</tr>
<tr>
<td width="90"> </td>
<td width="86"> </td>
<td width="137"> </td>
<td width="221"> </td>
<td width="24"> </td>
<td width="17"> </td>
<td width="55"> </td>
<td width="253"> </td>
</tr>
<tr>
<td width="90"> </td>
<td width="86"> </td>
<td width="137"> </td>
<td width="221"> </td>
<td width="24"> </td>
<td width="17"> </td>
<td width="55"> </td>
<td width="253"> </td>
</tr>
<tr>
<td width="90"> </td>
<td width="86"> </td>
<td width="137"> </td>
<td width="221"> </td>
<td width="24"> </td>
<td width="17"> </td>
<td width="55"> </td>
<td width="253"> </td>
</tr>
<tr>
<td width="90"> </td>
<td width="86"> </td>
<td width="137"> </td>
<td width="221"> </td>
<td width="24"> </td>
<td width="17"> </td>
<td width="55"> </td>
<td width="253"> </td>
</tr>
<tr>
<td width="90"> </td>
<td width="86"> </td>
<td width="137"> </td>
<td width="221"> </td>
<td width="24"> </td>
<td width="17"> </td>
<td width="55"> </td>
<td width="253"> </td>
</tr>
<tr>
<td width="90"> </td>
<td width="86"> </td>
<td width="137"> </td>
<td width="221"> </td>
<td width="24"> </td>
<td width="17"> </td>
<td width="55"> </td>
<td width="253"> </td>
</tr>
<tr>
<td width="90"> </td>
<td width="86"> </td>
<td width="137"> </td>
<td width="221"> </td>
<td width="24"> </td>
<td width="17"> </td>
<td width="55"> </td>
<td width="253"> </td>
</tr>
<tr>
<td width="90"> </td>
<td width="86"> </td>
<td width="137"> </td>
<td width="221"> </td>
<td width="24"> </td>
<td width="17"> </td>
<td width="55"> </td>
<td width="253"> </td>
</tr>
<tr>
<td width="90"> </td>
<td width="86"> </td>
<td width="137"> </td>
<td width="221"> </td>
<td width="24"> </td>
<td width="17"> </td>
<td width="55"> </td>
<td width="253"> </td>
</tr>
</table>
If you're using PDO, which is a better approach:
echo "<table>";
$sql = $this->db->query("SELECT * FROM YOUR_TABLE");
while($row = $sql->fetch(PDO::FETCH_ASSOC))
{
echo "
<tr>
<td>". $row['quantity'] ."</td>
<td>". $row['unit'] ."</td>
<td>". $row['details'] ."</td>
<td>". $row['issued_date'] ."</td>
<td>". $row['returned'] ."</td>
</tr>
";
}
echo "</table>";
Or if you're mysql_ functions, which are deprecated:
echo "<table>";
$sql = mysql_query("SELECT * FROM YOUR_TABLE");
while($row = mysql_fetch_assoc($sql))
{
echo "
<tr>
<td>". $row['quantity'] ."</td>
<td>". $row['unit'] ."</td>
<td>". $row['details'] ."</td>
<td>". $row['issued_date'] ."</td>
<td>". $row['returned'] ."</td>
</tr>
";
}
echo "/<table>";
In addition to the above answer, you can also use mysqli. Here's an example:
$result = $mysqli->query($query);
while ($row = $result->fetch_object()){
echo "<tr>";
echo "<td>" . $row->quantity . "</td>"
...etc...
}

Categories