douchunji1885 2015-06-23 14:07
浏览 230
已采纳

在MySql DB Collection之后更改值

I currently collect data from a mysql table then post the data using Curl. The values are :

title : surname : email
Max     Test      max@test.com

How do i collect the data then change the feild names for post to :

MainTitle : Lastname : MainEmail
Max     Test      max@test.com

this is my current code :

$conn = mysql_connect("localhost","max","pass");
$db   = mysql_select_db("maindb",$conn);
$query = "SELECT * FROM app2 ";
$result = mysql_query($query) or die(mysql_error());

 $url = "http://test.com?"; 
 while($row = mysql_fetch_assoc($result)) {

        $input = urldecode(http_build_query( $row ));

        $ch = curl_init();                    
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_POST, true);  
        curl_setopt($ch, CURLOPT_POSTFIELDS, $input); 
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
        curl_setopt($curl_exect, CURLOPT_HEADER, true);

        $output = curl_exec ($ch); 

        curl_close ($ch); 

        var_dump($output); 

        echo "</br>";
    }
  • 写回答

1条回答 默认 最新

  • douqiao5440 2015-06-23 14:10
    关注

    There are several possible ways to rename the fields, but the easiest may be to do it within your SQL statement:

    $query = "SELECT title AS `MainTitle`, surname AS `Lastname`, email AS `MainEmail` 
              FROM app2";
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!