Folge dem Video um zu sehen, wie unsere Website als Web-App auf dem Startbildschirm installiert werden kann.
Anmerkung: Diese Funktion ist in einigen Browsern möglicherweise nicht verfügbar.
SELECT `id` FROM `tab`
function getUmkreis() {
$ortIDs = array();
$sql = 'SELECT id, plz, ort,
ACOS(SIN(RADIANS(geo_b)) * SIN(RADIANS(49.1096938300675))
+ COS(RADIANS(geo_b)) * COS(RADIANS(49.1096938300675)) * COS(RADIANS(geo_l)
- RADIANS(10.7289164659405))
) * 6380 AS distance
FROM plz
WHERE ACOS(
SIN(RADIANS(geo_b)) * SIN(RADIANS(49.1096938300675))
+ COS(RADIANS(geo_b)) * COS(RADIANS(49.1096938300675)) * COS(RADIANS(geo_l)
- RADIANS(10.7289164659405))
) * 6380 < 10
ORDER BY distance';
$select = 'SELECT id FROM '.$sql.''; /* (hier liegt, glaube ich, das Problem) */
$this->DB->query($select);
$i = 0;
while($this->DB->next_record()) {
$ortIDs[] = $this->DB->f("ortIDs");
}
return $ortIDs;
}
$myOrt = new stadt;
$myOrteIDs = array();
$myOrteIDs = $myStadt->getUmkreis();
echo sizeof($myOrteIDs);
echo "jetzt: ";
echo $myOrteIDs[$ii];
echo "<br>";
for ($ii=0; $ii<sizeof($myOrteIDs); $ii++ ) {
$ort = $myOrt->getOrtData($myOrteIDs[$ii]); /* (hier hab ich ein Problem mit dem mehrdimensionalen Array) */
?>
<option value="<?php echo $myOrt->plz ?>"><?php echo $myOrt->ort ?></option>
<?php } ?>
$select = 'SELECT id FROM '.$sql.''; /* (hier liegt, glaube ich, das Problem) */
$select = 'SELECT id FROM ('.$sql.') AS sub'; /* (hier liegt, glaube ich, das Problem) */
CREATE TABLE `plz` (
`id` int(10) NOT NULL auto_increment,
`land` varchar(5) NOT NULL default '',
`bundesland` varchar(50) NOT NULL default '',
`bezirk` varchar(50) NOT NULL default '',
`kreis` varchar(50) NOT NULL default '',
`frei` varchar(50) NOT NULL default '',
`ort` varchar(50) NOT NULL default '',
`geo_l` double NOT NULL default '0',
`geo_b` double NOT NULL default '0',
`plz` varchar(6) NOT NULL default '',
`bland` varchar(5) NOT NULL default '',
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=13348 ;
--
-- Daten für Tabelle `plz`
--
INSERT INTO `plz` (`id`, `land`, `bundesland`, `bezirk`, `kreis`, `frei`, `ort`, `geo_l`, `geo_b`, `plz`, `bland`) VALUES
(5078, 'DE', 'Sachsen', 'Dresden', 'Kreisfreie Stadt Dresden', '-', 'Dresden', 13.7210676148814, 51.0600336463379, '01067', 'S')
...
...
$sql = 'SELECT * FROM `plz` WHERE `ort` LIKE \'Gunzenhausen%\' LIMIT 1 ';
function getUmkreis() {
$ortIDs = array();
$select = 'SELECT id, plz, ort,
ACOS(SIN(RADIANS(geo_b)) * SIN(RADIANS(49.1096938300675))
+ COS(RADIANS(geo_b)) * COS(RADIANS(49.1096938300675)) * COS(RADIANS(geo_l)
- RADIANS(10.7289164659405))
) * 6380 AS distance
FROM plz
WHERE ACOS(
SIN(RADIANS(geo_b)) * SIN(RADIANS(49.1096938300675))
+ COS(RADIANS(geo_b)) * COS(RADIANS(49.1096938300675)) * COS(RADIANS(geo_l)
- RADIANS(10.7289164659405))
) * 6380 < 10
ORDER BY distance';
$this->DB->query($select);
$i = 0;
while($this->DB->next_record()) {
$ortIDs[] = $this->DB->f("ortIDs");
}
return $ortIDs;
}
<?php
$myOrt = new stadt;
$myOrteIDs = array();
$myOrteIDs = $myStadt->getUmkreis();
echo sizeof($myOrteIDs);
echo "jetzt: ";
echo $myOrteIDs[$ii];
echo "<br>";
for ($ii=0; $ii<sizeof($myOrteIDs); $ii++ ) {
$ort = $myOrt->getOrtData($myOrteIDs[$ii]);
?>
<option value="<?php echo $myOrt->plz ?>"><?php echo $myOrt->ort ?></option>
<?php } ?>
Database error: Invalid SQL: SELECT id FROM (SELECT id, plz, ort, ACOS(SIN(RADIANS(geo_b)) * SIN(RADIANS(49.1096938300675)) + COS(RADIANS(geo_b)) * COS(RADIANS(49.1096938300675)) * COS(RADIANS(geo_l) - RADIANS(10.7289164659405)) ) * 6380 AS distance FROM plz WHERE ACOS( SIN(RADIANS(geo_b)) * SIN(RADIANS(49.1096938300675)) + COS(RADIANS(geo_b)) * COS(RADIANS(49.1096938300675)) * COS(RADIANS(geo_l) - RADIANS(10.7289164659405)) ) * 6380 < 10 ORDER BY distance) AS sub
MySQL Error: 1064 (You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT id, plz, ort, ACOS(SIN(RADIANS(geo_b)) * SIN(RADIANS(4)
Session halted.
SELECT calc.id
FROM
(SELECT id
/* Berechnung der genauen Distanz mit pb, pl, zb, zl*/ AS distance
FROM
(SELECT
plz.geo_b as pb,
plz.geo_l as pl,
zentrum.geo_b as zb,
zentrum.geo_l as zl,
FROM plz
(SELECT geo_b, geo_l
FROM plz
WHERE ort LIKE 'Gunzenhausen%') AS zentrum
WHERE plz.geo_b BETWEEN zentrum.geo_b + 10 AND zentrum.geo_b +10
) AS calc
WHERE calc.distance < 10
ORDER BY calc.distance