Prev | Current Page 418 | Next

Emilian Balanescu and Cristian Darie

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

..
if (substr($key, 0, 6) == 'submit')
{
/* Get the position of the last '_' underscore from submit
button name e.g strtpos('submit_edit_val_1', '_') is 16 */
$last_underscore = strrpos($key, '_');
/* Get the scope of submit button
(e.g 'edit_cat' from 'submit_edit_val_1') */
$this->_mAction = substr($key, strlen('submit_'),
$last_underscore - strlen('submit_'));
CHAPTER 11 ?–  CATALOG ADMINISTRATION: PRODUCTS AND ATTRIBUTES 312
/* Get the attribute value id targeted by submit button
(the number at the end of submit button name)
e.g '1' from 'submit_edit_val_1' */
$this->_mActionedAttributeValueId =
(int)substr($key, $last_underscore + 1);
break;
}
$this->mLinkToAttributesAdmin = Link::ToAttributesAdmin();
$this->mLinkToAttributeValuesAdmin =
Link::ToAttributeValuesAdmin($this->mAttributeId);
}
public function init()
{
// If adding a new attribute value ...
if ($this->_mAction == 'add_val')
{
$attribute_value = $_POST['attribute_value'];
if ($attribute_value == null)
$this->mErrorMessage = 'Attribute value is empty';
if ($this->mErrorMessage == null)
{
Catalog::AddAttributeValue($this->mAttributeId, $attribute_value);
header('Location: ' .
htmlspecialchars_decode(
$this->mLinkToAttributeValuesAdmin));
}
}
// If editing an existing attribute value ...
if ($this->_mAction == 'edit_val')
{
$this->mEditItem = $this->_mActionedAttributeValueId;
}
// If updating an attribute value .


Pages:
406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430
Anteny satelitarne apartamenty przy plaży online loan for bad credit rekuperatory skarpetki narciarskie męskie