dsgdhtr_43654 2015-10-27 19:52 采纳率: 100%
浏览 46

获取MySQL列中的所有值,并在PHP中将其作为csv文本输出

I have been looking all over Stack Overflow and the PHP documentation for an answer to this. So far every time I have tried the example I have gotten a server error or the query failed. This PHP file should be able to perform two functions:

  1. Print out CSV formatted data from all the data in the column called DeviceName in the table with a name of the $tourcode.

  2. Do the same, but with the table StoredTours and the column StoredTourName.

Once the CSV formatted output is printed, I will then use it in a spinner or list picker for the app.

Picture of Database with the name 801929

Here is the Code I have so far with the $action value in the URL being the variable to control what the file does.

<?php

$DBUSER = 'clientapp'; 
$DBPW ='///PASSWORD///';
//$DBPW = $_GET['passwd'];
$DBHOST = 'localhost'; 
$DBNAME = '///DBNAME///'; 

$dbc = mysqli_connect($DBHOST,$DBUSER,$DBPW,$DBNAME);
if (!$dbc) {
    die("Database connection failed: " . mysqli_error($dbc));
exit();
}

//$tourcode = $_GET['tourcode'];
//$action = $_GET['action'];

$tourcode = '801929';
$action = 'devices';

if ($action === 'devices') {

    /* Here I want to print all the values in the column called 
    DeviceName form the table whose name is = $tourcode */


} else if ($action === 'tours') {

    /* Do the same as above, but with the table being 
    StoredTours and the column called StoredTourName */


}?>

It would be very helpful if someone could help me do this.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 keil的map文件中Image component sizes各项意思
    • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
    • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
    • ¥15 划分vlan后,链路不通了?
    • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
    • ¥15 Vue3 大型图片数据拖动排序
    • ¥15 Centos / PETGEM
    • ¥15 划分vlan后不通了
    • ¥20 用雷电模拟器安装百达屋apk一直闪退
    • ¥15 算能科技20240506咨询(拒绝大模型回答)