Hi all,
i need your experties where i now in trouble. How can i avoid data jump to next row if user enter "," even data actually in same field..in CSV the row saperate by ",".. so my CSV file is look not stabil when the data convert to wrong row or column.. Then I need to edit manually..
Here my script. This script work but come out with problem that i mention before.
How can i solve this issue?
<form name="export" action="req_reportCSV.php" method="post">
<p><a href="req_report.php">Back</a> :: <a href="req_allTran.php">MIS Respond</a></p>
<table width="1296" height="54" border="1" align="center">
<tr bgcolor="#66CCCC">
<td width="32" height="24">No</td>
<td width="80">Mis Ref Id</td>
<td width="141">Requestor</td>
<td width="81">Request On </td>
<td width="90">Category</td>
<td width="48">Priority</td>
<td width="122">Detail</td>
<td width="126">Module (*for SAP)</td>
<td width="126">Symptom</td>
<td width="87">Approval</td>
<td width="74">Status</td>
<td width="119">PIC</td>
<td width="88">Closing Date </td>
</tr>
<?php
include 'connection/db_connect.php';
$n=0;
$csv_hdr = "Req ID, Mis Ref Id , Requestor, Request On, Category, Priority, Detail, Module, Symptom, Approval, Status, PIC, Closing Date";
$sql="SELECT r.reqid, r.misRefId, r.date_req, r.request_by, r.category, r.priority, r.detail, r.modSAP, r.req_symptom, r.approval, r.curPIC,
r.status, r.dateclose, c.cat_id, c.cat_name, u.empNo, u.name FROM request r, user u, category c WHERE r.request_by=u.empNo AND
r.category=c.cat_id ORDER BY r.reqid ASC";
$result=mysql_query($sql) or die(mysql_error());
while ($row=mysql_fetch_assoc($result)) {
$n++;
?>
<tr>
<td><br>
<?php echo $n;
$csv_output .= $n.",";?></td>
<td><a href="req_detail.php?reqid=<?php echo $row['reqid']; ?>"><br><?php echo $row['misRefId'];
$csv_output .= $row['misRefId'].", ";?><br /></a></td>
<td><br><?php echo $row['name'];
$csv_output .= $row['name'].", ";?><br /></td>
<td><br><?php echo $row['date_req'];
$csv_output .= $row['date_req'].", ";?><br /></td>
<td><br><?php echo $row['cat_name'];
$csv_output .= $row['cat_name'].", ";?><br /></td>
<td><br><?php echo $row['priority'];
$csv_output .= $row['priority'].", ";?><br /></td>
<td><br><?php echo $row['detail'];
$csv_output .= $row['detail'].", ";?><br /></td>
<td><br><?php echo $row['modSAP'];
$csv_output .= $row['modSAP'].", ";?><br /></td>
<td><br><?php echo $row['req_symptom'];
$csv_output .= $row['req_symptom'].", ";?><br /></td>
<td><br><?php echo $row['approval'];
$csv_output .= $row['approval'].", ";?><br /></td>
<td><br><?php echo $row['status'];
$csv_output .= $row['status'].", ";?><br /></td>
<td><br><?php echo $row['curPIC'];
$csv_output .= $row['curPIC'].", ";?><br /></td>
<td><br><?php echo $row['dateclose'];
$csv_output .= $row['dateclose']. "\n";?><br /></td>
</tr>
<?php } ?>
</table>
<p> </p>
<input type="submit" value="Export to CSV">
<input type="hidden" value="<?php echo $csv_hdr ?>" name="csv_hdr" id="csv_hdr">
<input type="hidden" value="<?php echo $csv_output ?>" name="csv_output" id="csv_output">
<a href="req_report.php">Back</a>
</form>