# MySql column value by searching of another value in particular record

**URL:** <https://forum.ionicframework.com/t/mysql-column-value-by-searching-of-another-value-in-particular-record/126330>\
**Category:** ionic-v3\
**Created:** [March 29, 2018, 2:34pm UTC](https://forum.ionicframework.com/t/mysql-column-value-by-searching-of-another-value-in-particular-record/126330 "2018-03-29T14:34:29Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![lucasbasquerotto](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/lucasbasquerotto/32/101719_2.png) [@lucasbasquerotto](https://forum.ionicframework.com/u/lucasbasquerotto)\
**Post date:** [March 29, 2018, 6:08pm UTC](https://forum.ionicframework.com/t/mysql-column-value-by-searching-of-another-value-in-particular-record/126330/6 "2018-03-29T18:08:03Z")

</div>

@lado No. Your backend should be like:

```auto
<?php
require 'connection.php';

$name = $_POST['name'];
echo 'Name: ' . $name; // add this line so you can see what you receive as name on your back-end

$sql = "SELECT * from nameTab where name='$name'";

$result = mysqli_query($con, $sql);

while($row = $result->fetch_assoc()) {
    echo "username: " . $row["username"] . "with id: " . $row["ID"];
}
?>

```

Instead of `$_POST['name']` you could try:

```auto
// (remove it) $name = $_POST['name'];
$request = json_decode(file_get_contents("php://input"));
echo 'JSON: ' . $request;

$name = $request->name;
echo 'Name: ' . $name;

```

(Because you are sending a JSON)

Your front-end should be like:

```auto
  check() {
    var headers = new Headers();
    headers.append('Content-Type', 'application/x-www-form-urlencoded');
    let options = new RequestOptions({ headers: headers });

   let postParams = { name: this.name };

    this.http.post("http://site.info/php/check.php", JSON.stringify(postParams), options)
      .subscribe(data => {
        console.log('data', data); // first see what you receive as data
      }, error => {
        console.log(error);
      });
  }

```

If you don’t receive the name (`echo 'Name: ' . $name;` outputs nothing as the name), try without the stringify:

`this.http.post("http://site.info/php/check.php", postParams, options)`

Or try with `FormData`:

```auto
let body = new FormData();
body.append('name', this.name);
this.http.post("http://site.info/php/check.php", body , options)

```

I’m not a http expert though, but you can search examples in the web, like:

> [@Http.post not sending data](https://forum.ionicframework.com/t/http-post-not-sending-data/47452):
>
> Hi, I’m trying to do a http post using the http module in Angular 2. The POST request hits the server OK (CORS is all taken care of) but no post data is received. Any idea what I might be doing wrong? This is my code: import {Injectable} from 'angular2/core'; import {Http, Headers, RequestOptions} from 'angular2/http'; import 'rxjs/Rx'; const SERVER\_URL = 'http://MY-SERVER.COM'; @Injectable() export class UserData { constructor(private http: Http) { } login(email, password) { let he…

---

_[View the full topic](https://forum.ionicframework.com/t/mysql-column-value-by-searching-of-another-value-in-particular-record/126330)._
