PHP Replacement string Implementation Picture Adaptive screen Instance code

Source: Internet
Author: User

Today I am reading from the database in the Product Details field is not a string, with the Echo input page directly parsed into HTML format, so can not go to the Android side to manipulate the string, and then think of the service side hands, the following code, respectively do three things, the first read to the field content, The second replaces the useless string and sets the width of the picture, and the third modifies the target field as a picture.

<?php$cnn=mysqli_connect ("localhost", "root", "Kz5ddksqye", "rooot");//Connection Database $bm= "set names UTF8";//Commodity Id$id=$_get ["id"]; $sql = "select * from ' vi_items ' WHERE ' id ' = $id"; $ccc =mysqli_query ($CNN, $sql);//execute code        //Traverse database contents        while ($arr = MYSQLI_FETCH_ASSOC ($CCC)) {                    //Get the required fields in the database            $urmes =  $arr ["desc"];                        Replace the useless string and set the width of the picture            $diyic = Str_replace ("Src=/data/upload/site/58fd01e4a1f22.png", "width=100%", $urmes);                        Modify the Target field for the picture            Echo str_replace ("src", "src", $diyic);;        }? >

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.