Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70746

Help me, I'm new to ionic and I'm making an app to get information in my php system, I'd like to know how I could do this

$
0
0

@ojosejefferson wrote:

my provider

import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import 'rxjs/add/operator/map';

/*
  Generated class for the BuscarProvider provider.

  See https://angular.io/guide/dependency-injection for more info on providers
  and Angular DI.
*/
@Injectable()
export class BuscarProvider {

  constructor(public http: Http) {
    console.log('Hello BuscarProvider Provider');
  }
  getLatesBuscar() {
    return this.http.get("http://localhost/projetoagenda/AppSearch.php");
  }
}

page to display the search

<ion-header>
  <ion-navbar>
    <button ion-button menuToggle>
      <ion-icon name="menu"></ion-icon>
    </button>
    <ion-title>
      Agenda
    </ion-title>
  </ion-navbar>
</ion-header>
<ion-content padding id="page10">

  <form>

  <ion-list>

      <ion-item>
        <ion-input type="text" placeholder="Digite seu CPF"></ion-input>
      </ion-item>
    </ion-list>

    <div>
      <button ion-button type="submit">Pesquisar</button>
    </div>

  </form>
</ion-content>

JSON

<?php
include("conexao.php");

if(isset($_POST['pesquisar'])){
$nome_pesquisado = $_POST['pesquisar'];
if($_POST['pesquisar'] == ''){
	echo "Você digitou nada no campo de pesquisa.";
}else{

$select = $pdo->query("SELECT * FROM agenda WHERE nome LIKE '%$nome_pesquisado%' OR cpf LIKE '%$nome_pesquisado%'");
$rowCount = $select->rowCount();
if($rowCount == 0){
	echo json_encode(array('erro' => 'Nenhum usuario cadastrado com esse CPF. Ligue para agendar sua consulta (11)2204-2118'));
}else{
	$dadosBusca = $select->fetch(PDO::FETCH_OBJ);

	echo json_encode(array('sucess' => $dadosBusca));

}
}
}
	?>

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70746

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>