我目前正在嘗試將xml標題的值發佈到數組中,而該數組又將用於保存假期。我仍然沒有收到錯誤消息,並使用var_dump來收集以下信息。 (打勾與閱讀RSS提要幾個複選框的)未存儲所需參數的數組
array(7) { [0]=> string(21) "{$currentItem->title}" [1]=> string(21)"{$currentItem->title}" [2]=> string(21) "{$currentItem->title}" [3]=> string(21) "{$currentItem->title}" [4]=> string(21) "{$currentItem->title}" [5]=> string(21) "{$currentItem->title}" [6]=> string(21) "{$currentItem->title}" } :S
這對我表明陣列側是工作,但它不是拿着值參數範圍內的複選框,設置爲所有字符串信息21? 21是saveBox的值之間的字符數量!從index.php文件
$index = 1;
foreach ($allHolidays as $currentItem)
{
echo '<tr>';
if (isset($_SESSION['login']))
{
echo '<td valign="top">';
//echo '<input type="hidden" name="guid$index" value="{$currentItem->guid}">';name="saveBox$index[]"
echo '<input type="checkbox" name="saveBox[]" value="{$currentItem->title}">';
echo '</td>';
}
echo '<td>';
echo "<p><a href=\"{$currentItem->link}\">{$currentItem->title}</a><br/>";
echo "{$currentItem->description}<br/>";
echo "{$currentItem->pubDate}<br/></p>";
echo '</td>';
echo '</tr>';
$index++;
}
saveProcess.php
<?php
header("refresh:555; url='index.php'");
session_start();
echo "Thank you for saving a holiday";
echo '<input type="checkbox" name="saveBox[]" value="'.
htmlspecialchars($currentItem->title).'">';
include "top.php";
var_dump($_POST['saveBox']);
try
{
foreach ($_POST['saveBox'] as $savedHoliday)
{
$user = $_SESSION['login'];
$currentSave = $savedHoliday;
$save = "channel/item[title=\"$currentSave\"]";
$holidaysXML = simplexml_load_file('holidays.xml');
$savePath = $holidaysXML->xpath($save);
foreach($savePath as $currentSavePath)
{
echo "<p><a href='{$currentSavePath->link}'>{$currentSavePath->title}</a>"."<br\>".
"{$currentSavePath->description}"."<br\>".
"{$currentSavePath->pubDate}"."<br\></p>";
$insertSave = $db->prepare("INSERT INTO `saved_holidays` (`subscriberID`, `link`, `pubDate`, `title`, `description`)
VALUES ('$user', '$currentSavePath->link', '$currentSavePath->pubDate', '$currentSavePath->title', '$currentSavePath->description')");
$insertSave->execute();
}
}
}
catch(PDOException $e)
{
echo $e->getMessage();
}
我已經讀了你的'問題'三次,不能讓它的東西... – stUrb
我試圖檢查我的數組,以確保正確的信息被複選框,因爲我不能得到它存儲在數據庫中。原來,複選框是持有正確的信息,但仍然不能將這些信息存儲到我的數據庫,我不知道哪裏出了錯誤謝謝 –