What's new

Closed Html alternative tag for php

Status
Not open for further replies.

daredavil07

Addict
Joined
Aug 24, 2018
Posts
63
Reaction
17
Points
83
Hello po mga bossing, sinusubukan ko po mag export ng excel from db at gumagana naman po pero may kulit na warning lang na lumalabas pag nagbubukas ng excel file:

The file format and extension of 'export.xls' dont match. The file could be corrupted or unsafe. Unless you trust its source, don't open it.

Sabi po sa na research ko, tatanggalin daw dapat yung mga naka-tag na html sa export.php ko. Pano ko po yan magagawa? Ano pong pwede kung pamamalit sa HTML na di po masisira yung table?

PHP:
$output .= '
  <table>
  <tr>
  <th>ID</th>
  <th>FIRSTNAME</th>
  <th>LASTNAME</th>
  <th>STATUS</th>
  </tr>
  ';

  while($row = mysqli_fetch_array($result))
  {
  $output .= '
  <th>'.$row["id"].'</th>
  <th>'.$row["fname"].'</th>
  <th>'.$row["lname"].'</th>
  <th>'.$row["status"].'</th>
  </tr>
  ';
  }
}

Salamat po sa tulong mga bossing!
 
sir naka start ka na ba? gamitan mo po ng datatables mas madali at mas maganda.

Opo sir, natapos kona sir. Ito nalang yung inaayos ko sir. :)

May nakita po ako sa isang site na ito yung ginawa nya sa header, pero yung lumabas sakin is pinasok sila lahat sang i-isang column header, instead na each column.

PHP:
 $header ='';
  $header = "ID"."\t"."FIRSTNAME"."\t"."LASTNAME"."\t"."STATUS"."\t";

$Data='';

  while($row = mysqli_fetch_array($result))
  {

//papano ang tamang pag pull-out ng laman ng column? $id, $fname, $lname, $status
  $rowData = '';
  foreach($rec as $value)
  {
    $value = '"' . $id. '"' . "\t".'"' . $fname. '"' . "\t".'"' . $lname. '"' . "\t".'"' . $status. '"' . "\t";
    $rowData .= $value;
  }
  $Data .= trim($rowData)."\n";
}

header("Content-Type: application/xls");   
header("Content-Disposition: attachment; filename=export.xls"); 
header("Pragma: no-cache");
header("Expires: 0");
echo ucwords($header)."\n".$Data."\n";
 
Last edited by a moderator:
suggestion ko sir datatables ka nlg, mag dadagdag ka lng ng parameters sa table na ginawa mo then ok ka na, pwede ka ng mag export sa excel, pdf at csv, may print view pa.

You do not have permission to view the full content of this post. Log in or register now.

P.S: aralin mo na din ung ibang functions nya sir, sigurado madami kang ma gagamitan sa future projects mo.
 
Status
Not open for further replies.

Similar threads

Back
Top