Problem:
I am using Google Map API using the link: http://www.phpinsider.com/php/code/GoogleMapAPI/ - and when I try to print out an address on the map manually it will show up but not when selected from a database.
PHP code (this works):
$map->addMarkerByAddress('114 53 Grevgatan 31','The Tudor Arms','<b>The Tudor Arms</b>');
PHP code (this does NOT work):
$location = $row['postalnumber'] . ' ' . $row['address'] . ' ' . $row['city'];
$map->addMarkerByAddress($location , $row['name'],'<b>'. $row['name'] .'</b>');
Desired solution:
To be able to extract data from a table in an SQL database and send it to the Google Map API function.
Additional remarks: When I echo the variables above the address and all information will print out but not when sent to the Google Map API function. Do I need to convert the data into a string?
Yes, you should say google the format like:
$location = $row['postalnumber'] . ' ' . $row['address'] . ' ' . $row['city'];
$map->addMarkerByAddress("'".$location."'", "'".$row['name']."'","'<b>". $row['name'] ."</b>'");
Related
I am using a PHP script to pull large amounts of entries from a database, it looks like this:
foreach($events as $e){ //sets each set of data as a value of $e
$vidID = $e["Test Video YouTube ID"]; //stores each video ID as this variable, so that it can be called when embedding the video
echo "<br>" . '<iframe width="250" height="140" src="http://www.youtube.com/embed/' . $vidID . '?rel=0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>' . "<br>"
. '<strong> DOC: </strong>' . $e["Axial Cut"] . " " . '<strong> IPM: </strong>' . $e["Inches Per Minute"] . "<br>" .
'<strong> WOC: </strong>' . $e["Radial Cut"] . " " . '<strong> FPT: </strong>' . $e["Inch per Tooth"] . "<br>" .
'<strong> SFM: </strong>' . round($e["Surface Feet per Minute"]) . "<br>"; //each value here is displayed. use the form '$e["Column to be dislplayed"].'
This displays each field for the entry I need, then goes to the next entry and does the same, displaying every entry in the database.
My issue is that it only displays them in a vertical line, so what is the best way to format the output in such a way that it displays in a grid, with a set amount of columns?
*EDIT - To clarify, I don't want to use something like a CSS table for this. It limits me in that the data cannot automatically fill into columns, instead each entry would either appear in a single column or I would have to update each field every time the database had a new entry which would be quite tedious. So what is the best way to have data automatically flow into these columns and rows?
I'm working with QRcode at the moment so far it's so good i can scan it and get a result back from the database.
Im getting the data as follow :
$qrcode = QRcode::png('
number:' . $number. '
Name: ' . $name. '
Lastdate : ' . $lastdate . '
check: ' . $check. '');
My question is how can i scan the QRcode and redirect it to an custom link and display it on the website
Thanks,
Kevin
Recently i have made one application like your requirement only. what you need to do is, what ever data displaying through QR code that data insert into database then you will get one record id and using that record id you can make custom URL with creating new php page.
your code:
$qrcode = QRcode::png('
number:' . $number. '
Name: ' . $name. '
Lastdate : ' . $lastdate . '
check: ' . $check. '');
my suggested code:
array('number' => $number,
'Name '=>$name,
'Lastdate '=> $lastdate,
'check '=> $check);
Insert this array into your database
grab inserted recored id.
$custome_URL = "www.yourwebsitename.com/qrcode_scanneddata.php?id=$record_id";
$qrcode = QRcode::png("$custome_URL");
when ever you scan the URL automatically it will open in web browser.
You can redirect by code like this
header('Location: '.$qrcode->url);
I have a web server running Apache2 on Ubuntu 12.04. I have installed geoip-database, libapache2-mod-geoip1.2.5-2, libgeoip1 1.4.8+dfsg-2, and php5-geoip.
I put this test PHP code on my server:
<?php
echo "country: " . apache_note("GEOIP_COUNTRY_NAME") . '<br>';
echo "code: " . apache_note("GEOIP_COUNTRY_CODE") . '<br>';
echo "city: " . apache_note("GEOIP_CITY") . '<br>';
echo "region: " . apache_note("GEOIP_REGION") . '<br>';
echo "latitude: " . apache_note("GEOIP_LATITUDE") . '<br>';
echo "longitude: " . apache_note("GEOIP_LONGITUDE") . '<br>';
echo "timezone: " . geoip_time_zone_by_country_and_region($this->countryCode, $this->region);
When I access it in my browser, I get this output:
country: Japan
code: JP
city:
region:
latitude:
longitude:
timezone:
I'm confused by the fact that only two of the values are coming back. If the GeoIP module were not installed correctly, would it not fail completely without any values at all?
Are there some libraries or something that I am missing?
How do I get my code to return all the values, like latitude and longitude?
You're probably using the free GeoLite IP database. This database only contains country information.
The databases containing more detailed information, such as latitude and longitude, are available from Maxmind on a paid basis.
I'm looking to create a formatted product list from an SQL database. My aim is to have a store on my website with a series of small boxes containing some shorthand information about each product, that when clicked will open a pop-up containing detailed information. (I have a working Javascript/JQuery code to create the pop-ups.)
Here is the PHP code so far, simply to get the information from the database and display it on a webpage...
(I've been using XAMPP to provide an environment for me to test the code in)
<?php
mysql_connect("localhost", "root", "") or die (mysql_error ());
mysql_select_db("Database1") or die(mysql_error());
$strSQL = "SELECT * FROM Products";
$rs = mysql_query($strSQL);
while($row = mysql_fetch_array($rs)) {
echo $row['Brand'] . " " . $row['ProductName'] . " " . $row['Image'] . "<br />";
}
mysql_close();
?>
I want the echoed line to be displayed in a divider, with a divider generated for each record in the SQL database (say I have 10 products available, there would be ten dividers, and 10 different boxes on the webpage). The divider's class is "ProductBox".
echo "<div class=\"ProductBox\">"; $row['Brand'] . " " . $row['ProductName'] . " " . $row['Image'] . "</div>";
This was the closest I have come to a solution, which was simply managing to write a code with no syntax errors - alas, nothing actually displays on the webpage.
If I'm going about this entirely the wrong way please tell me - I'm fairly sure I need to use a SQL database to dynamically update stock on a live website, but if I need to implement a different programming language or whatever then just tell me what you think would work and help me with a solution.
You have an extra semicolon in your code
echo "<div class=\"ProductBox\">"; $row['Brand'] . " " . $row['ProductName'] . " " . $row['Image'] . "</div>";
Replace with
echo "<div class=\"ProductBox\">". $row['Brand'] . " " . $row['ProductName'] . " " . $row['Image'] . "</div>";
mysql_fetch_array needs to be used like this (see PHP Doc):
while($row = mysql_fetch_array($rs, MYSQL_ASSOC)) {
}
or you could just use "mysql_fetch_assoc" instead.
HOWEVER, if you're new to PHP, I HIGHLY RECOMMEND that you get started on the right foot. mysql_query functions are soon to be deprecated. DON'T USE THEM. Most recommend using "PDO" for querying your database. Here's a great tutorial to teach you: http://wiki.hashphp.org/PDO_Tutorial_for_MySQL_Developers
Also, as mentioned, you have an extra semi-colon.
Dont forget these basics markups :
`<HTML>
<HEAD>
</HEAD>
<BODY> put in here your divs
</BODY>
</HTML>`
I have indexed a site using Nutch and now I am searching the index using the Zend Lucene library.
I've actually pulled the Zend libraries into Codeigniter but it is all Zend doing the work.
I can display the title, score and url fine but I can't find the name of the field to display the content from the page.
So far I have the following code
$index = new Zend_Search_Lucene('C:\nutch\nutch-0.9\my-search\index');
$query = $this->input->post('searchQuery');
$hits = $index->find($query);
echo "<p>Index contains " . $index->count() . " documents.</p>";
echo "<p>Search for '" . $query . "' returned " . count($hits) . " hits</p>";
foreach ($hits as $hit)
{
echo "<h4>" . $hit->title . "</h4>";
echo "<p><b>Score:</b> " . sprintf('%.2f', $hit->score) . "</p>";
echo "<p><b>Url:</b> " ."<a href='" . $hit->url . "'>" . $hit->url. "</a></p>";
}
Can anyone help out with the name of the field to display the content or a content summary?
Thanks
I don't know the nutch index format, but whenever I need to check a lucene index I use Luke - Lucene Index Toolbox
It allows you to open an index directory, browse fields and run queries. Very helpful if you're using an unfamiliar index.