dsjzmrz78089 2015-02-25 22:05
浏览 80

Android应用程序连接到PHPMyAdmin或PHP

Good Day Everyone!

I am working on something that is new to me and that is to get data from my phpmyadmin and display it in an android application using XAMPP and JSON. I was wondering what could be the steps that must be taken to make this connection possible. For now, I have a php file that inserts data into a database stored in phpMyAdmin and it works. I am looking to display or add data from an android application. Could somebody please give me steps on how to start this or a link that will help me with this issue. Thanks. Here's my php file right now.

<?php

$server = 'localhost';
$user = 'root';
$password = '';
$database = 'testdb';
$productName = $_POST["txtProductName"];
$price = $_POST["txtPrice"];
$db = mysql_connect($server, $user, $password);



$db_select = mysql_select_db ($database, $db);
$query = "Insert into products (name, price) 
Value ('$productName' , '$price')";
    if (!$db) {
        die('Could not connect to database');
    }   

    enter code here
    if (!mysql_select_db($database, $db))
        die("Could not open products database");
    if (!($result = mysql_query($query , $db)))
    {
        print("Could not execute query<br/>");
        die(mysql_error());
    }

mysql_close($db);       


?>
  • 写回答

1条回答 默认 最新

  • douhuan1648 2015-02-26 01:39
    关注

    I recommend that you just create a few php scripts to provide basic CRUD operation and simply called those php scripts from the Android by sending the proper HTTP request to the server for the CRUD operation you want.

    Excellent tutorial that explain this concept is available here

    评论

报告相同问题?

悬赏问题

  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料