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

How do I learn Java? From book or internet or a coaching?
It is good to learn Java from Coaching where you will get more exposure in learning at faster pace.
Suresh
0 0
7
Can we use pointer in java?
No, we can't. Java has reference variables which contains address of objects. The reference variables are substitute to pointers in java. But, we cannot perform mathematical operations on reference variables...
Manish
Is JAVA training only for technical students or a non-technical student also may join?
Any Body can Learn Programming Language.It All depends upon the learning of basics and all.Basics actually makes the thing different.
Vikrant
0 0
6
What are the best websites to learn java as well as get a certificate from them?
To learn basic java i suggest javatpoint is good for knowledge as well as concept but for certification refer book
Abirami
0 0
7
Which programming language should I learn, C++, Python or Java?
It depend on your interest , meanwhile phython is the new boss. Java is evergreen
Navneet
0 0
5

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

Ask a Question

Related Lessons

Easy way to remember Java keyword.
ACCESS MODIFIER ACCESS SPECIFIER abstract, assert, const, final, native, static, strictfp, super, synchronized, this, transient, void, volatile public, private, protected, default DATA...

Rohit Deshbhratar

1 0
0

What Is Java? Explain The History Of Java
i. Ovierview: Java programming language was originally developed by Sun Microsystems which was initiated by James Gosling and released in 1995 as core component of Sun Microsystems' Java platform (Java...

ListIterator Example
public class ListIteratorEx { public static void main(String args) { List<String> li = new ArrayList<String>(); li.add("java1"); li.add("java2"); li.add("java3"); li.add("java4"); ListIterator...
S

Sarthak C.

0 0
0

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

Constructor Overloading
public class ConstructorOverloading { public ConstructorOverloading(){ System.out.println("default"); } public ConstructorOverloading(String a){ System.out.println("a"); } public ConstructorOverloading(int...
S

Sarthak C.

0 0
0

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