Click here to Skip to main content
15,899,313 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
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();
    }


My gettestuser.php

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);
?>
Posted
Comments
EZW 2-Nov-17 14:10pm    
Shouldn't SQL be something like:
SELECT * FROM test_category WHERE $value = 't' AND pin = '?'
?

Also, where is "$value" set?
Member 13490292 3-Nov-17 4:21am    
no... SQL is fine and my question is all about how to set $value( $value will be my column name which i'll be posting using post method(My Column names: a, b, ho, ll, c, d))...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900