douhan1992 2013-08-01 16:21 采纳率: 100%
浏览 148

sqlite值到php变量(drupal)

I have little SQL expirience and think this question may be so simple there is almost no support for it online. How do i pull a single value from a single record in a SQLite database and place it in a php variable? Here is my working code so far...

<?php              
$sqlc = db_query("SELECT COUNTY, LATITUDE, LONGITUDE FROM countytable");
$sqlCoutnies = $sqlc->fetchAll();?>
alert('<?php echo count($sqlCoutnies); ?>');              
<?php

This returns a popup displaying "100" which is the correct amount (of counties in iowa). My goal is to create 2 php arrays. One with the key value pair of COUNTY->LATITUDE, and the other with COUNTY->LONGITUDE. What could i add to my code to create this?

  • 写回答

2条回答 默认 最新

  • doushu5451 2013-08-01 16:28
    关注

    A single record would mean you need a WHERE clause in your SQL.

    So

    $sql = 'SELECT county, latitude FROM countytable WHERE id = 1'
    

    That returns the county and latitude for the id record number 1.

    评论

报告相同问题?

悬赏问题

  • ¥15 关于大棚监测的pcb板设计
  • ¥20 sim800c模块 at指令及平台
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计