如何通过在PHP mysql中发布列名来查找常量值? [英] How to look for a constant value by posting the column name in PHP mysql?

查看:51
本文介绍了如何通过在PHP mysql中发布列名来查找常量值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已创建此代码以检索多个用户数据,其中pincode =我通过post方法发布的pin代码和$ value ='t'($ value =列名称(我想使用发送列名称) post方法(列名= a,b,ho,ll,c,d))我想让它寻找't')。我的代码不完整,我不知道如何做到这一点,任何人都可以帮我这个吗?后来我希望它连接Android应用程序和列表查看检索到的数据。



我尝试过:



我在DbOperations.php中的功能

I have created this code to retrieve multiple user data where the pincode = the pin-code i am posting through post method and $value = 't'($value = a column name(i want to send the column name using post method(column name= a, b, ho, ll, c, d)) where i want it to look for 't'). my code is not complete and i don't know how to do it can anyone help me with this? Later i want it to connect with android app and list view the retrieved data.

What I have tried:

My function in DbOperations.php

public function gettestuser($pin){
        $stmt = $this->con->prepare("SELECT * FROM test_category WHERE $value = 't' pin = ?");
        $stmt->bind_param("s",$pin);
        $stmt->execute();
        return $stmt->get_result()->fetch_assoc();
    }





我的gettestuser.php





My gettestuser.php

<?php
require_once '../include/DbOperations.php';
 
$response = array();
 
if($_SERVER['REQUEST_METHOD']=='POST'){
if(isset($_POST['reg_pin'])){
 
    $db = new DbOperations();
 
    $test_category = $db->gettestuser($_POST['reg_pin']);
 
    var_dump($test_category);
 
        $response['error'] = false;
        $response['pid'] = $test_category['pid'];
        $response['name'] = $test_category['name'];
        $response['pin'] = $test_category['pin'];
        $response['a'] = $test_category['a'];
        $response['b'] = $test_category['b'];
        $response['ho'] = $test_category['ho'];
        $response['ll'] = $test_category['ll'];
        $response['c'] = $test_category['c'];
        $response['d'] = $test_category['d'];
 

 
}else{
    $response['error'] = true;
    $response['message'] = "Required fields are missing";
}
}
 
echo json_encode($response);
?>

推荐答案

value ='t' (
value = 't'(


value =一个列名(我想使用post方法发送列名(列名= a,b,ho,ll,c,d))我希望它在哪里寻找't')。我的代码不完整,我不知道如何做到这一点,任何人都可以帮我这个吗?后来我希望它连接Android应用程序和列表查看检索到的数据。



我尝试过:



我在DbOperations.php中的功能

value = a column name(i want to send the column name using post method(column name= a, b, ho, ll, c, d)) where i want it to look for 't'). my code is not complete and i don't know how to do it can anyone help me with this? Later i want it to connect with android app and list view the retrieved data.

What I have tried:

My function in DbOperations.php
public function gettestuser(


pin){
pin){


这篇关于如何通过在PHP mysql中发布列名来查找常量值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆