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?
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.
$county_lat = array();
$county_long = array();
foreach ($sqlCounties as $key => $value){
$county_lat[$value['COUNTY']] = $value['LATITUDE'];
$county_long[$value['COUNTY']] = $value['LONGITUDE'];
}