I thought that would work but I get an error:
Warning</b>
: sizeof(): Parameter must be an array or an object that implements Countable in /nfs/c03/h02/mnt/51355/domains/test.lizmoore.com/html/test.php on line 133
I'm trying to adapt some the code below to create an xml file from a Recordset. I need it to work with MySQLi.
The line $totalColumns = sizeof($rsHoods->Columns); is where my current problem is. The original line was: $totalColumns=mysql_num_fields($rsHoods);
<?php
if (1==1) {
header("Content-type: text/xml");
header("Pragma: public");
header("Cache-control: private");
header("Expires: -1");
$export_rsHoods="";
if($export_rsHoods=="1"){
header("Content-Disposition: attachment; filename=recordset.xml");
header("Content-Type: application/force-download");
}
echo "";
echo "<recordset total=\"".$rsHoods->TotalRows."\">";
if($rsHoods->TotalRows > 0){
$Start_Record = 0;
$Num_Records = $rsHoods->TotalRows;
$Current_Record = 0;
if(isset($_POST['Start_Record']) && $_POST['Start_Record']!="" && isset($_POST['Num_Records']) && $_POST['Num_Records']!=""){
$Start_Record = $_POST['Start_Record'];
$Num_Records = $_POST['Num_Records'];
}
if(isset($_GET['Start_Record']) && $_GET['Start_Record']!="" && isset($_GET['Num_Records']) && $_GET['Num_Records']!=""){
$Start_Record = $_GET['Start_Record'];
$Num_Records = $_GET['Num_Records'];
}
$totalColumns = sizeof($rsHoods->Columns);
do{
if($Current_Record >= $Start_Record){
echo "<record>";
for ($x=0; $x<$totalColumns; $x++) {
$field = mysqli_fetch_field_direct($rsHoods, $x);
echo "<".$field."><"."![CD"."ATA[".$rsHoods->getColumnVal('$field')."]"."]></".$field.">";
}
echo "</record>";
}
$Current_Record=$Current_Record+1;
if($Current_Record-$Start_Record==$Num_Records){break;}
}while (!$rsHoods->atEnd());
}
echo "</recordset>";
die();
}
?>