下面的代码是一个导出工具,我本质上是在查询 SobiPro 的数据库,提取条目(公司)列表以及相关的自定义字段。
我在这里偶然发现了一个无限循环。有些部分仅用于记录 ID,因此请忽略公司/电子邮件/电话/等部分。
以下信息将导出为 CSV,因此将它们配对至关重要。
下面是我的代码。有任何想法吗?
$ideas = mysql_query("SELECT itemid FROM jos_sobi2_item") or die(mysql_error());
while ($row = mysql_fetch_array($ideas)) {
$info[] = $row['itemid'];
}
foreach($info as $item) {
$entryID = $item['itemid'];
$queryfields = mysql_query("SELECT fieldid, data_txt, itemid FROM jos_sobi2_fields_data WHERE itemid = '". $entryID ."'");
//$queryfields = mysql_query("SELECT fieldid, data_txt, itemid FROM `jos_sobi2_fields_data` WHERE `itemid` = '$entryID'");
while ($rowqueryfields = mysql_fetch_array($queryfields)) {
$rowfields[] = $rowqueryfields;
}
foreach($rowfields as $item) {
// Primarily what I need is name, company and contact info such as phone, email fax web!
$contactPerson = '9'; // Name
$city = '3'; // City
$state = '5'; // State
$phone = '10'; // Phone
$email = '7'; // Email
$fax = '11';
$website = '8';
if($item['fieldid'] == 9) {
echo '<strong>Name: </strong>' .$item['data_txt'] . '</br>';
}
if($item['fieldid'] == 3) {
//echo '<strong>City: </strong>' .$item['data_txt'] . '</br>';
}
if($item['fieldid'] == 5) {
//echo '<strong>State: </strong>' .$item['data_txt'] . '</br>';
}
if($item['fieldid'] == 10) {
//echo '<strong>Phone: </strong>' .$item['data_txt'] . '</br>';
}
if($item['fieldid'] == 7) {
//echo '<strong>Email: </strong>' .$item['data_txt'] . '</br>';
}
if($item['fieldid'] == 8) {
//echo '<strong>Website: </strong>' .$item['data_txt'] . '</br>';
}
}
}