对于每个语句只返回单词'Array'

时间:2015-12-03 17:14:37

标签: php mysql

我正在我的数据库中创建一个包含3个顾问的个人顾问页面,我正在尝试创建一个下拉框,有人可以选择他们喜欢的顾问。目前我的下拉列表只显示“阵列”一词三次。这是我到目前为止所拥有的。

<?php class Swetin_Mygateway_PaymentController extends Mage_Core_Controller_Front_Action {
    // The redirect action is triggered when someone places an order
    public function redirectAction() {
        $this->loadLayout();
        $block = $this->getLayout()->createBlock('Mage_Core_Block_Template','swetin',array('template' => 'swetin/redirect.phtml'));
        $this->getLayout()->getBlock('content')->append($block);
        $this->renderLayout();
    }


    public function responseAction() {

        if($this->getRequest()->isPost()) {


            $validated = false;

            // Generally sent by gateway
            $status_codes = $this->getRequest()->getPost('gtpay_tranx_status_code');
            $orderId = $this->getRequest()->getPost('gtpay_tranx_id');
            //$orderId = "";
            $orderStatMsg = $this->getRequest()->getPost('gtpay_tranx_status_msg');

            //echo $status_codes;

            if($status_codes == "00" ){ $validated = true; }

            //$orderId = $requesting['gtpay_tranx_id']; 

            if($validated) {
                // Payment was successful, so update the order's state, send order email and move to the success page
                $order = Mage::getModel('sales/order');
                $order->loadByIncrementId($orderId);
                $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, 'Payment authorized!');

                $order->sendNewOrderEmail();
                $order->setEmailSent(true);

                $order->save();

                Mage::getSingleton('checkout/session')->unsQuoteId();

                Mage_Core_Controller_Varien_Action::_redirect('checkout/onepage/success', array('_secure'=>true));
            }
            else {
                // There is a problem in the response we got
                $this->cancelAction($orderStatMsg);
                Mage_Core_Controller_Varien_Action::_redirect('checkout/onepage/failure', array('_secure'=>true));
            }
        }
        else
            Mage_Core_Controller_Varien_Action::_redirect('');
    }

    // The cancel action is triggered when an order is to be cancelled
    public function cancelAction($orderStatMsg) {
        if (Mage::getSingleton('checkout/session')->getLastRealOrderId()) {
            $order = Mage::getModel('sales/order')->loadByIncrementId(Mage::getSingleton('checkout/session')->getLastRealOrderId());
            if($order->getId()) {

                        Mage::getSingleton('checkout/session')->addError($orderStatMsg);
                session_write_close();

                // Flag the order as 'cancelled' and save it  'Card has declined the payment.'
                $order->cancel()->setState(Mage_Sales_Model_Order::STATE_CANCELED, true, $orderStatMsg)->save();
            }
        }
    }
}

2 个答案:

答案 0 :(得分:0)

// give the result of concat() an alias so you can easily access it in the result set
$sqlQ = "SELECT concat(firstName,' ',lastName) as name FROM adv WHERE advisor IS NULL";
[...]
while ( $row = $result->fetch(PDO::FETCH_ASSOC) ) {
  // $row is an array, its members correspond with the fields/aliases you've selected
  // apply htmlspecialchars() so that the contents of $row['name'] can't break your html structure
  echo '<option>', htmlspecialchars($row['name']), '</option>';
}

答案 1 :(得分:0)

您的ImageView已经是一个数组,因此无需将$行插入新数组。只需像这样循环结果

$row