你好,这是我的代码。我试图在Joomla 3文章中更新我的数据库,但所有我得到的是一个空白页面,我使用了很多页面,但这是我的主要参考/帮助
(http://docs.joomla.org/Inserting,_Updating_and_Removing_data_using_JDatabase)
我不确定我做错了什么可以有人帮助我?顺便说一句,我是joomla的新手,但我还可以使用php。
<?php
// You can place PHP like this
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$fields = array(
$db->quoteName('stars'). ' = ' . $db->quote($_POST['Stars']),
$db->quoteName('price'). ' = ' . $db->quote($_POST['Price']),
$db->quoteName('cityName'). ' = ' . $db->quote($_POST['City']),
$db->quoteName('stateName'). ' = ' . $db->quote($_POST['State']),
$db->quoteName('countryCode'). ' = ' . $db->quote($_POST['CountryC']),
$db->quoteName('countryName'). ' = ' . $db->quote($_POST['CountryN']),
$db->quoteName('address'). ' = ' . $db->quote($_POST['Address']),
$db->quoteName('location'). ' = ' . $db->quote($_POST['Location']),
$db->quoteName('url'). ' = ' . $db->quote($_POST['URL']),
$db->quoteName('chainID'). ' = ' . $db->quote($_POST['Chain']),
$db->quoteName('rooms'). ' = ' . $db->quote($_POST['Rooms']),
$db->quoteName('rating'). ' = ' . $db->quote($_POST['Rating'])
);//close fields
$conditions = array($db->quoteName('hotelName'). ' = ' . $db->quote($_POST['HotelName']));
//close conditions
$query->update($quoteName('HotelList'))->set($fields)->where($conditions);
$db->setQuery($query);
$result = $db->$query();
if($result)
{
echo " The record containing " . $_POST['HotelName'] . " was sucessfully updated";
}
else
{
echo " The record containing " . $_POST['HotelName'] . " cannot be updated";
}
到目前为止,我看到很多例子,但他们是硬编码的,我不知道如何做到相反。