UrbanPro

Learn Java Training from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

How do I fetch data from MySQL in React Native and PHP using a search engine?

Asked by Last Modified  

Follow 2
Answer

Please enter your answer

bored of old-schooled teaching? let me show you the millenial way..

this.is my php file: $con = mysqli_connect($HostName,$HostUser,$password,$db); // Getting the received JSON into $json variable. $json = file_get_contents('php://input'); // decoding the received JSON and store into $obj variable. $obj = json_decode($json,true); // Populate ID from JSON $obj...
read more

this.is my php file:

$con = mysqli_connect($HostName,$HostUser,$password,$db);

 // Getting the received JSON into $json variable.
 $json = file_get_contents('php://input');

 // decoding the received JSON and store into $obj variable.
 $obj = json_decode($json,true);

 // Populate ID from JSON $obj array and store into $ID.
$ID = $obj['numero'];

//Fetching the selected record.
$CheckSQL = "SELECT origine FROM envoi WHERE numero='$ID'";

$result = $con->query($CheckSQL);

if ($result->num_rows >0) {
 while($row[] = $result->fetch_assoc()) {
 $Item = $row;
 $json = json_encode($Item);
 echo $json;
 }
}
else {  
 $EmailExistMSG= "No Results Found.";
 $EmailExistJson = json_encode($EmailExistMSG);
 echo $EmailExistJson ; 

}

And this is my react native script where i should enter number and fetch his data if it's exist in my database:

search= () =>{
     //alert('ok');
     const {numero}=this.state;

     fetch('http://192.168.1.4:80/search.php',{
     method:'post',
     header:{
     'Accept':'application/json',
     'Content-type' :'application/json'
     },
     body:JSON.stringify({numero:numero})}).then((responseData)=>responseData.json()).then((responseJson)=>{alert(responseJson)}).catch((error)=>{console.error(error);})}

  render(){
    return(

          <View style={styles.pass}>
          <TextInput placeholder="Saisir le numéro de suivi de l'envoi"   onChangeText= {numero=>this.setState({numero})}/>
          <TouchableOpacity onPress={this.search} style={{marginTop:20,marginLeft:70}}>
          <Icon name="search"  size={20}/>
          </TouchableOpacity>
          </View>

    )
  }
read less
Comments

Related Questions

Which book is good for groovy and grails
Beginning Groovy and Grails: From Novice to Professional by Jim Shingler (Author), Joseph Faisal Nusairat (Author), Christopher M Judd (Author)....
Sumit S.
Is it really needed to do Java training before graduation, to get a job?
Yes, It's must to get better opportunities and to standard alone in IT field. Not only core Java but also learn Spring,Hinernat ,Struts. ANGULARJS add an advantage to get job easily.
Udaybhan
What are the booming technologies in US from Job point of view
All the terminologies are good. First of all decide your self you want go as functional consultant or technical. If you have java background Learn Hadoop. Billing rate is very high.
Chandra
What is the use of deployment descriptor?
A deployment descriptor describes how a component, module or application should be deployed. A web application’s deployment descriptor describes the classes, resources and configuration of the application...
Monisha

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Related Lessons

Inheritance In Java
Inheritance: The process of getting properties and behaviors from one class to another class is called inheritance. Properties: Variables Behaviors: Methods The main purpose of the inheritance...
D

Deleted U.

1 0
0

Class and Objects in Java
Class is a template or a blueprint which is used to describe an object. On other hand Object is a reference of a class which follows all the stuff written inside the class. How about taking the whole tour in the following video

Object Oriented Programming Concepts :
Class : Class is user defined data type. Class is a logical representation of an Object. That means Class is used to define an object, how you want to create your software object. For Example...

Java Interview Questions & Answers
Java Interview Questions have been designed especially to get you acquainted with the nature of questions you may encounter during your interview for the subject of Java Programming Language. As per my...

Java : Compile-time Versus Runtime optimization
While designing and development, one should think in terms of compile-time and run-time.It helps in understanding language basics in a better way.Let's understand this with a question below : What...
S

Recommended Articles

Designed in a flexible and user-friendly demeanor, Java is the most commonly used programming language for the creation of web applications and platform. It allows developers to “write once, run anywhere” (WORA). It is general-purpose, a high-level programming language developed by Sun Microsystem. Initially known as an...

Read full article >

Before we start on the importance of learning JavaScript, let’s start with a short introduction on the topic. JavaScript is the most popular programming language in the world, precisely it is the language - for Computers, the Web, Servers, Smart Phone, Laptops, Mobiles, Tablets and more. And if you are a beginner or planning...

Read full article >

Java is the most commonly used popular programming language for the creation of web applications and platform today. Integrated Cloud Applications and Platform Services Oracle says, “Java developers worldwide has over 9 million and runs approximately 3 billion mobile phones”.  Right from its first implication as java 1.0...

Read full article >

Java is the most famous programming language till date. 20 years is a big time for any programming language to survive and gain strength. Java has been proved to be one of the most reliable programming languages for networked computers. source:techcentral.com Java was developed to pertain over the Internet. Over...

Read full article >

Looking for Java Training Classes?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for Java Training Classes?

The best tutors for Java Training Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn Java Training with the Best Tutors

The best Tutors for Java Training Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more