473,806 Members | 2,607 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to convert php script to access

How can I convert the following script to be used in access?

<Html>
<head>
<title>Dealer s</title>
</head>
<h5>List of Dealers Nearest to your Zip Code</h5><br><br>

<?
$errflag = false;
$conn = mysql_connect(" localhost:3306" ,"uid","pass ");
mysql_select_db ("tbcdealers ");
$query = "select * from zipcode where Zipcode = '" . $txtZip . "'";
$result = mysql_query($qu ery,$conn);
$row = mysql_fetch_row ($result);
if ($row == false) {
$errflag = true;
$errmsg = "The Zip Code you entered is invalid";
echo "<blockquote>$e rrmgs</blockquote>";
}
else {
$lat1 = $row[3];
$long1 = $row[4];
}
if ($errflag == false){
$sql = "select zipcode.zipcode , sqrt(power(69.1 *(zipcode.latit ude - $lat1),2)+
power(69.1*(zip code.longitude-$long1)*cos(zip code.latitude/57.3),2)) as dist,
$dealer.* from $dealer LEFT JOIN zipcode on " ;
$sql = $sql . " $dealer.zip = zipcode.zipcode where
sqrt(power(69.1 *(zipcode.latit ude - $lat1),2)+
power(69.1*(zip code.longitude-$long1)*cos(zip code.latitude/57.3),2)) < " .
$cboDist ;
$result = mysql_query($sq l,$conn);
$count = mysql_num_rows( $result);
echo "<blockquote><t able border=0>";
for ($i=0; $i < $count; $i++) {
echo "<tr><td>";
$row = mysql_fetch_row ($result);
echo "<b>",$row[3],"</b><BR>" ;
echo $row[4],"<BR>" ;
if ($row[5] <> ""){
echo $row[5],"<BR>" ;
}
echo $row[6],"<BR>" ;
echo $row[7],"<BR>";
echo $row[8],"<BR>";
$dm = sprintf("%3.2f" ,$row[1]);
echo "Distance : $dm miles.<BR><BR>" ;
echo "</td></tr>";
}
Nov 13 '05 #1
2 2221
On 17 Jul 2004 10:58:17 GMT, ga*****@aol.com (Galsaba) wrote:

By understanding what this script does and then completely re-writing
it in Access/VBA. There is no conversion tool.

-Tom.

How can I convert the following script to be used in access?

<Html>
<head>
<title>Dealers </title>
</head>
<h5>List of Dealers Nearest to your Zip Code</h5><br><br>

<?
$errflag = false;
$conn = mysql_connect(" localhost:3306" ,"uid","pass ");
mysql_select_d b("tbcdealers") ;
$query = "select * from zipcode where Zipcode = '" . $txtZip . "'";
$result = mysql_query($qu ery,$conn);
$row = mysql_fetch_row ($result);
if ($row == false) {
$errflag = true;
$errmsg = "The Zip Code you entered is invalid";
echo "<blockquote>$e rrmgs</blockquote>";
}
else {
$lat1 = $row[3];
$long1 = $row[4];
}
if ($errflag == false){
$sql = "select zipcode.zipcode , sqrt(power(69.1 *(zipcode.latit ude - $lat1),2)+
power(69.1*(zi pcode.longitude-$long1)*cos(zip code.latitude/57.3),2)) as dist,
$dealer.* from $dealer LEFT JOIN zipcode on " ;
$sql = $sql . " $dealer.zip = zipcode.zipcode where
sqrt(power(69. 1*(zipcode.lati tude - $lat1),2)+
power(69.1*(zi pcode.longitude-$long1)*cos(zip code.latitude/57.3),2)) < " .
$cboDist ;
$result = mysql_query($sq l,$conn);
$count = mysql_num_rows( $result);
echo "<blockquote><t able border=0>";
for ($i=0; $i < $count; $i++) {
echo "<tr><td>";
$row = mysql_fetch_row ($result);
echo "<b>",$row[3],"</b><BR>" ;
echo $row[4],"<BR>" ;
if ($row[5] <> ""){
echo $row[5],"<BR>" ;
}
echo $row[6],"<BR>" ;
echo $row[7],"<BR>";
echo $row[8],"<BR>";
$dm = sprintf("%3.2f" ,$row[1]);
echo "Distance : $dm miles.<BR><BR>" ;
echo "</td></tr>";
}


Nov 13 '05 #2
ga*****@aol.com (Galsaba) wrote in
news:20******** *************** ****@mb-m25.aol.com:
How can I convert the following script to be used in access?


What do you mean "used in Access?"

Do you mean doing the same thing in an MDB running the program
Microsoft Access?

Or do you mean using an MDB file created with Access as the data
source for a web page?

If the latter, it's pretty simple -- you won't need to do anything
but change the method for opening the result set, using ODBC. It
could look something like this, assuming you've got an ODBC DSN
defined:

$db=odbc_pconne ct("[DSN Name]","[UID]","[PW]");
$Dealers=odbc_e xec($db,"select * from zipcode where Zipcode = '"
. $txtZip . "'");
[I don't know how you'd check to see if it returns no rows; my guess
is that you can test $Dealers somehow to find out if it's empty --
depends on what kind of object odbc_exec() returns]
while(odbc_fetc h_row($Dealers) ) {
[do whatever you want to do with each row]
}

(it also seems to me that you have a structural error in your
control structure: the part executed in if ($errflag == false){}
could just as easily be in the ELSE clause of the original IF
statement, and then you wouldn't need to bother with the $errflag)

(let me also suggest that you could save processing by simply
returning the dealers first; if none is returned *then* check the
zip code table to see if the zip code was invalid or not; that means
you'd have two hits against the back end only when an invalid zip
code was entered or only when no dealers were found)

If the former, it's substantially more complex and can't really be
answered, as it's not going to be at all the same thing.

I've said it a million times, but I'll say it again: I really,
really, really wish people would distinguish Access from Jet: Jet is
the database engine, Access is the development tool and desktop
database program that uses Jet as its native database format. When
you're connecting to an MDB file from anything other than Access
itself, YOU'RE NOT USING ACCESS! You're only using Jet.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
18129
by: Noah | last post by:
Does anyone have a function to convert back and forth between NT style paths and POSIX style? It seems trivial, but I want to make sure I don't overlook some obscure detail. Is it a simple matter of translating / and \ characters? FYI, I need a Python function that does what cygpath does so that I can run a script on either NT or UNIX or Cygwin. I want my config files use one style of path. Yours,
5
18041
by: Andrew V. Romero | last post by:
At work we have an excel file that contains the list of medications and their corresponding strengths. I would like to save the excel file as a text list and paste this list into a javascript function and have JS put this into an array. Then JS would use this array to create a selection list which displays only the names of the drugs. When the user selections one of the drugs, another selection list will be loaded with the avaiable...
4
5395
by: Richard Hollenbeck | last post by:
I'm trying to write some code that will convert any of the most popular standard date formats twice in to something like "dd Mmm yyyy" (i.e. 08 Jan 1908) and compare the first with the second and calculate days, months, and years. This is not for a college course. It's for my own personal genealogy website. I'm stumped about the code. I'm working on it but not making much progress. Is there any free code available anywhere? I know it...
1
6600
by: ian m via SQLMonster.com | last post by:
Hi, I currently have a ms access update query that runs perfectly well and quicly in access however I now need to add this query to convert this qeryu to oracles equivelant sql syntax and add it to the end of an oracle sql script. Unfortunately Im not having much success although i seem to be able to convert it to a working oracle sql. it takes hours to run the statement in oracle where as in access it runs in seconds
25
4396
by: cory | last post by:
Hi, I have an Access database and am having an ASP.NEt application written for it. It is almost complete. I have a hosting company that I signed up with a month ago but before I did anything I asked them if Access and ASP.NET would work on their servers, they said yes so I bought in. Now they are saying my application wont work on their servers using MSaccess and I can only use SQL or asp 3.0. They are saying Microsoft is trying to...
9
2315
by: laredotornado | last post by:
Hello, I am tasked with converting an MsAccess db to a MySQL 4 db in a Linux environment. Can anyone recommend any good freeware/scripts to help me do this? Thanks, - Dave
2
4242
by: egoldthwait | last post by:
I need to convert a 17mb access 2000 db to Oracle and house it in a Citrix farm. The issue: we have never converted an Access Db to Oracle but can probably use Oracle's Workbench to assist with this. Also - the citrix folks do not want us to keep the FE in Access as the queries and other activities consume a lot of power. The users will be in 3 different offices across the globe all accessing the 1 Oracle DB in Citrix. Does anyone have...
5
2581
by: melickas | last post by:
We designed a custom application using Office Developer Tools '97 which included a Run-time version of Access--- so it would not matter if our customer even had any version of Access on their computer. The application ran without problems on our customer's computer for 2-3 years. Then our customer bought a new computer and we had to reinstall the application. Everything was ok for approximately 6 months until our customer was "cleaning up"...
15
2372
by: Steve | last post by:
I am having problems getting values out of an array. The array is set as a global array and values are pushed into it as they are read from a JSON file using a "for loop". When the "for loop" is finished I want to convert the array into a string which can be used by another function. My attempt to do this is not working. The script looks like this: heights=; function getElevationInter(latv,lngv) { var script =...
0
9719
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9598
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10371
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10373
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7650
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6877
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5546
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4330
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3852
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.