How can we combine a single and a pair?

Source: Internet
Author: User
How can we combine a single and a pair?
$ New ['name'] = strval ($ _ POST ['name']); $ tags = strval ($ _ POST ['tag']); $ new ['status'] = intval ($ _ POST ['status']); $ new ['displayorder'] = intval ($ _ POST ['order']); if (! $ New ['status'] = 1 |! $ New ['status'] = 2) {self: output (['title' => 'invalid parameter ', 'type' => 'error']);} $ mid = intval ($ _ POST ['mid ']); if (strstr ($ tags,', ') {$ tagstr = []; $ pdo_r = Bridge :: pdo (Bridge: DB_TAG_R); $ tagsDB = explode (',', $ tags); foreach ($ tagsDB as $ k => $ v) {$ v = trim ($ v); $ query = $ pdo_r-> prepare ("SELECT TagNameId FROM 'tagname' WHERE TagName =: channelName "); $ query-> execute ([': channelname' => $ v]); $ rs = $ query-> fetch (); if (! $ Rs) {$ error_msgs = 'This ''. $ v. '",'. 'tag does not exist'; self: output (['title' => "$ error_msgs", 'type' => 'error']);} $ tagstr [] = $ rs ['tagnameid'] ;}} else {$ v = trim ($ tags); $ pdo_r = Bridge: pdo (Bridge: DB_TAG_R ); $ query = $ pdo_r-> prepare ("SELECT TagNameId FROM 'tagname' WHERE TagName =: channelName"); $ query-> execute ([': channelname' => $ v]); $ rs = $ query-> fetch (); if (! $ Rs) {$ error_msgs = 'This ''. $ v. '",'. 'tag does not exist'; self: output (['title' => "$ error_msgs", 'type' => 'error']);} $ tagstr [] = array_unique ($ rs ['tagnameid']);} $ new ['tags'] = serialize ($ tagstr); $ pdo_w = Bridge :: pdo (Bridge: DB_HEALTH_W); $ re = $ pdo_w-> update ('articlechannel', $ new, ['channelid' => $ mid]); $ this-> adminLog ('tagmodifie', $ mid, 'update', serialize ($ new); if ($ re> 0) {self :: output (['title' => 'Operation succeeded ', 'type' => 'success']);} self :: output (['title' => 'Operation failed', 'type' => 'error']);}


Reply to discussion (solution)

Remove the else branches of if (strstr ($ tags, ',') and if (strstr ($ tags, ',')
That is, only the true branch of if (strstr ($ tags, ',') is retained.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.