Prev | Current Page 415 | Next

Emilian Balanescu and Cristian Darie

"Beginning PHP and MySQL E-Commerce: From Novice to Professional, Second Edition"

..
if (substr($key, 0, 6) == 'submit')
{
CHAPTER 11 ?–  CATALOG ADMINISTRATION: PRODUCTS AND ATTRIBUTES 308
/* Get the position of the last '_' underscore from submit
button name e.g strtpos('submit_edit_attr_1', '_') is 17 */
$last_underscore = strrpos($key, '_');
/* Get the scope of submit button
(e.g 'edit_dep' from 'submit_edit_attr_1') */
$this->_mAction = substr($key, strlen('submit_'),
$last_underscore - strlen('submit_'));
/* Get the attribute id targeted by submit button
(the number at the end of submit button name)
e.g '1' from 'submit_edit_attr_1' */
$this->_mActionedAttributeId = substr($key, $last_underscore + 1);
break;
}
$this->mLinkToAttributesAdmin = Link::ToAttributesAdmin();
}
public function init()
{
// If adding a new attribute ...
if ($this->_mAction == 'add_attr')
{
$attribute_name = $_POST['attribute_name'];
if ($attribute_name == null)
$this->mErrorMessage = 'Attribute name required';
if ($this->mErrorMessage == null)
{
Catalog::AddAttribute($attribute_name);
header('Location: ' . $this->mLinkToAttributesAdmin);
}
}
// If editing an existing attribute ...
if ($this->_mAction == 'edit_attr')
$this->mEditItem = $this->_mActionedAttributeId;
// If updating an attribute ...
if ($this->_mAction == 'update_attr')
{
$attribute_name = $_POST['name'];
CHAPTER 11 ?–  CATALOG ADMINISTRATION: PRODUCTS AND ATTRIBUTES 309
if ($attribute_name == null)
$this->mErrorMessage = 'Attribute name required';
if ($this->mErrorMessage == null)
{
Catalog::UpdateAttribute($this->_mActionedAttributeId,
$attribute_name);
header('Location: ' .


Pages:
403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427
elektroenergetyka24.bieszczady.pl Wczasy nad morzem szafy buchsbaum hotele londyn