我更新了代码,但在数据之前获得了一些标签
<br />
<font size='1'><table class='xdebug-error xe-warning' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span>
警告:调用wpdb :: prepare()时缺少参数2 C:\ WAMP \ WWW \ WordPress的\可湿性粉剂内容\插件\ sinetiks,学校\ deped_rpci.php 在第14行并在C:\ wamp \ www \ wordpress \ wp-includes \ wp-db.php中定义 在线 1246
</th></tr>
<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
<tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr>
<tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0000</td><td bgcolor='#eeeeec' align='right'>312032</td><td bgcolor='#eeeeec'>{main}( )</td><td title='C:\wamp\www\wordpress\wp-admin\admin.php' bgcolor='#eeeeec'>..\admin.php<b>:</b>0</td></tr>
<tr><td bgcolor='#eeeeec' align='center'>2</td><td bgcolor='#eeeeec' align='center'>0.0010</td><td bgcolor='#eeeeec' align='right'>331856</td><td bgcolor='#eeeeec'>require_once( <font color='#00bb00'>'C:\wamp\www\wordpress\wp-load.php'</font> )</td><td title='C:\wamp\www\wordpress\wp-admin\admin.php' bgcolor='#eeeeec'>..\admin.php<b>:</b>31</td></tr>
这是代码
<?php if (isset($_POST['exp'])) {
$wpdb->show_errors();
global $wpdb;
// Grab any post values you sent with your submit function
$DownloadReportFrom = "ReportDateFrom";
$DownloadReportTo = "ReportDateFrom";
// Build your query
$MyQuery = $wpdb->get_results($wpdb->prepare('SELECT * FROM wp_rpci_rpci'));
// Process report request
if (! $MyQuery) {
$Error = $wpdb->print_error();
die("The following error was found: $Error");
} else {
// Prepare our csv download
// Set header row values
$csv_fields=array();
$csv_fields[] = 'Field Name 1';
$csv_fields[] = 'Field Name 2';
$csv_fields[] = 'Field Name 1';
$csv_fields[] = 'Field Name 2';
$csv_fields[] = 'Field Name 1';
$csv_fields[] = 'Field Name 2';
$output_filename = 'MyReport_' . $DownloadReportFrom .'-'. $DownloadReportTo . '.csv';
$output_handle = @fopen( 'php://output', 'w' );
header( 'Cache-Control: must-revalidate, post-check=0, pre-check=0' );
header( 'Content-Description: File Transfer' );
header( 'Content-type: text/csv' );
header( 'Content-Disposition: attachment; filename=' . $output_filename );
header( 'Expires: 0' );
header( 'Pragma: public' );
// Insert header row
fputcsv( $output_handle, $csv_fields );
// Parse results to csv format
foreach ($MyQuery as $Result) {
$leadArray = (array) $Result; // Cast the Object to an array
// Add row to file
fputcsv( $output_handle, $leadArray );
}
// Close output file stream
fclose( $output_handle );
die();
exit();
}
}
?>
我得到一些表然后在表标签
之后显示数据库行答案 0 :(得分:0)
您不使用mysqli_query,而是使用wpdb :: query。
当wpdb::query返回受影响/选择的行数时,将整数传递给mysqli_fetch_assoc并且由于显而易见的原因而失败,因为它需要mysqli_result而不是某个数字。
您需要获得真正的mysqli连接,然后您的代码才能正常工作。
答案 1 :(得分:0)
我得到了它的工作:)
我只是消除了多余的论点
继承代码
def getTextData(self, dataframe, getText):
for col in dataframe:
for cellvalue in dataframe[col]:
if getText == cellvalue:
#print dataframe[col]
return cellvalue