0
へ(エクスポート)を印刷する方法。ここで私は<strong>MS Wordの</strong><strong>PHP</strong>を使用して、検索結果に<strong>輸出</strong>にしようとしているが、私のコードは動作しないMS-Wordの検索結果(PHP)
は私のコードです:ここでの問題は、それが代わりにのみ、検索結果のすべてのテーブルのリストをエクスポートしている
<?php
error_reporting(0);
include("configsample.php");
?>
<?php
HEADER("Content-Type: application/msword");
HEADER("Content-Disposition: attachment; filename=database_dump.doc");
HEADER("Pragma: no-cache");
HEADER("Expires: 0");
if ($_REQUEST["course"]<>'') {
$search_course = " AND restu_course='".mysql_real_escape_string($_REQUEST["course"])."'";
}
if ($_REQUEST["from"]<>'' and $_REQUEST["to"]<>'') {
$sql = "SELECT * FROM ".$SETTINGS["data_table"]." WHERE restu_year BETWEEN '".mysql_real_escape_string($_REQUEST["from"])."' AND '".mysql_real_escape_string($_REQUEST["to"])."'".$search_course;
} else if ($_REQUEST["from"]<>'') {
$sql = "SELECT * FROM ".$SETTINGS["data_table"]." WHERE restu_year >= '".mysql_real_escape_string($_REQUEST["from"])."'".$search_course;
} else if ($_REQUEST["to"]<>'') {
$sql = "SELECT * FROM ".$SETTINGS["data_table"]." WHERE restu_year = '".mysql_real_escape_string($_REQUEST["to"])."'".$search_course;
} else {
$sql = "SELECT * FROM ".$SETTINGS["data_table"]." WHERE restu_id>0".$search_course;
}
echo"<table border='1' width='100%' style='border: 1px solid #999999; border-collapse: collapse; margin:0 auto; background:#ffffff; border-radius:20px;'>
<tr style='background:#3366cc; color:#ffffff; font:normal 15px Tahoma; height:40px;'>
<th>Research No.</th>
<th>Course</th>
<th>Year</th>
</tr>";
$sql_result = mysql_query ($sql, $connection) or die ('request "Could not execute SQL query" '.$sql);
if (mysql_num_rows($sql_result)>0) {
while ($row = mysql_fetch_assoc($sql_result)) {
echo'<tr style="font:normal 12px Tahoma; color:#333333;">
<td style="padding:10px;">'.$row['restu_id'].'</td>
<td style="padding:10px;">'.$row['restu_course'].'</td>
<td style="padding:10px;">'.$row['restu_year'].'</td>
</tr>';
}
echo"</table>";
}
?>
:ここ
<?php
error_reporting(0);
include("configsample.php");
?>
<html>
<title>Home</title>
<head>
<meta charset="UTF-8">
<title>Flat Login Form</title>
</head>
<body>
<form class="login-form" method="post" action="viewstucon.php">
<select class="s" id="course" name="course">
<option value="">Select Course</option>
<option value="Bachelor of Secondary Education"<?php if (!(strcmp("Bachelor of Secondary Education", $_POST["course"]))) {echo "selected=\"selected\"";} ?>>Bachelor of Secondary Education</option>
<option value="Bachelor of Science in Automotive Technology"<?php if (!(strcmp("Bachelor of Science in Automotive Technology", $_POST["course"]))) {echo "selected=\"selected\"";} ?>>Bachelor of Science in Automotive Technology</option>
<option value="Bachelor of Science in Electrical Technology"<?php if (!(strcmp("Bachelor of Science in Electrical Technology", $_POST["course"]))) {echo "selected=\"selected\"";} ?>>Bachelor of Science in Electrical Technology</option>
</select>
<input class="sy" name="from" type="text" id="from" size="10" width="100%" value="<?php echo $_REQUEST["from"]; ?>" placeholder="From"/>
<input class="sy" name="to" type="text" id="to" size="10" width="100%" value="<?php echo $_REQUEST["to"]; ?>" placeholder="To"/>
<button type="submit" name="submit" >Filter</button>
</form>
<table width="100%" border="1" style="border: 1px solid #999999; border-collapse: collapse; margin:0 auto; background:#ffffff; border-radius:20px;">
<tr style="background:#3366cc; color:#ffffff; font:normal 15px Tahoma; height:40px;">
<th>Research Title</th>
<th>Year</th>
<th>Proponent(s)</th>
</tr>
<?php
if ($_REQUEST["course"]<>'') {
$search_course = " AND restu_course='".mysql_real_escape_string($_REQUEST["course"])."'";
}
if ($_REQUEST["from"]<>'' and $_REQUEST["to"]<>'') {
$sql = "SELECT * FROM ".$SETTINGS["data_table"]." WHERE restu_year BETWEEN '".mysql_real_escape_string($_REQUEST["from"])."' AND '".mysql_real_escape_string($_REQUEST["to"])."'".$search_course;
} else if ($_REQUEST["from"]<>'') {
$sql = "SELECT * FROM ".$SETTINGS["data_table"]." WHERE restu_year = '".mysql_real_escape_string($_REQUEST["from"])."'".$search_course;
} else if ($_REQUEST["to"]<>'') {
$sql = "SELECT * FROM ".$SETTINGS["data_table"]." WHERE restu_year = '".mysql_real_escape_string($_REQUEST["to"])."'".$search_course;
} else {
$sql = "SELECT * FROM ".$SETTINGS["data_table"]." WHERE restu_id>0".$search_course;
}
$sql_result = mysql_query ($sql, $connection) or die ('request "Could not execute SQL query" '.$sql);
if (mysql_num_rows($sql_result)>0) {
while ($row = mysql_fetch_assoc($sql_result))
{
echo'<tr style="font:normal 12px Tahoma; color:#333333;">
<td style="padding:10px;">'.$row['restu_title'].'</a></td>
<td style="padding:10px;">'.$row['restu_year'].'</td>
<td style="padding:10px;">'.$row['restu_by'].'</td>
</tr>';
}
}else
{
echo'<tr><td colspan="5">No results found.</td>';
}
?>
</table>
<a href="print.php">Export to Word</a>
</body>
</html>
はprint.phpコードです。
ありがとうございました。それは今働いている... –