What is the method for js to call php files?

coldplay.xixi
Release: 2023-03-04 18:50:02
Original
2945 people have browsed it

The method for js to call php files: first create a new php file; then use [$cid_data] to process it at the top of the file php code, the code is [$cid_data .= "'".$item['name' ]."'";】.

What is the method for js to call php files?

The method of js calling php file:

Implement the function

There is a button and a The input box input box input button is clicked to execute the php code

Baidu has found for a long time that form submission is the most reasonable

批量获取数据

根据cid 获取所有商品名称

Copy after login

$cid_datacan be processed at the top of the file php code

function getCidAllNamme($con, $name) { $sql = "select `name` from `la_goods` where `cid`='{$name}'"; if (!$obj = mysqli_query($con, $sql)) { die(mysqli_error($con) . $sql); } $nameList = array(); while ($res = mysqli_fetch_assoc($obj)) { $nameList[] = $res; } $cid_data = ''; if (count($nameList) > 0) { $cid_data .= "['"; //python 中数组的表示方法 ['',''] foreach ($nameList as $item) { $cid_data .= "'".$item['name']."'"; } $cid_data .= "']"; } return $cid_data; } $cid_all_name = $_POST['cid_all_name']; if (!empty($cid_all_name)) { $cid_data = getCidAllNamme($con, $cid_all_name); }
Copy after login

Related learning recommendations:php programming(video)

The above is the detailed content of What is the method for js to call php files?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!