PHP link Database mode and return JSON data

Source: Internet
Author: User

Header ("Content-type:text/html;charset=utf-8"); $servername = "localhost";//server address $username = "root";//Account $password = "[email protected]#";//password $dbname = "J OB_QYBK ";//Table name $conn =mysqli_connect ($servername, $username, $password, $dbname);//Connect database if (! $conn) Die ( "Database link Error!    ");    $sql = "SELECT * from Resume_information";//Check the statement $result =mysqli_query ($conn, $sql);    if (Mysqli_num_rows ($result) > 0) {$ar =array (); Output data while ($row = Mysqli_fetch_assoc ($result)) {//Add array $ar []=array ("id" = = $row ["id"] ],//number "Sex" = $row ["Sex"]?             Male ":" female ",//gender 1 for male 0 for female" name "+ = $row [" name "],//name" date "and" $row "[" Date "],//Birth date "Place" = $row ["Place"],//native Place "phone" + $row ["Phone"],//mobile number "Emergency" + $row ["Em             Ergency "],//emergency contact" mail "=" + $row ["Mail"],//Mailbox "Present" + + $row ["Present"],//current place of residence "SchoOl "+ $row [" School "],//graduated institutions" education "and" education "],//the highest education" Major "and $row ["             Major "],//Professional" certufucate "= $row [" certufucate "],//Professional Certificate" Grade "+ = $row [" Grade "],//English level "Life" = $row ["Life"],//work experience "Resume" and "],//" ("Resume") "Post" and "$row" ["POST"],//apply for position "Position" = "Position"],//to the Post time "Photoshop" and "" Photoshop "and" The $row ["]?" √ ":" ",//1 for Skilled 0 delegates will not" indesign "= $row [" InDesign "]?" √ ":" ",//1 for Skilled 0 delegates will not" iiiustrator "and" = "$row [" Iiiustrator "]?" √ ":" ",//1 for Skilled 0 delegates will not" premiere "and" $row ["premiere"]? √ ":" ",//1 for Skilled 0 delegates will not" dreamweaver "= $row [" Dreamweaver "]?" √ ":" ",//1 for Skilled 0 delegates will not" flash "= $row [" Flash "]?"         √ ":",//1 for Skilled 0 delegates will not "other" and "=" and $row ["Other"],//others "fraction" and "+" = "fraction"]//score    ); }//Return JSON format echo Json_encode ($ar);    } else {echo "0"; }?>

  

PHP link Database mode and return JSON data

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.