473,386 Members | 1,753 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to convert php script to access

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_db("tbcdealers");
$query = "select * from zipcode where Zipcode = '" . $txtZip . "'";
$result = mysql_query($query,$conn);
$row = mysql_fetch_row($result);
if ($row == false) {
$errflag = true;
$errmsg = "The Zip Code you entered is invalid";
echo "<blockquote>$errmgs</blockquote>";
}
else {
$lat1 = $row[3];
$long1 = $row[4];
}
if ($errflag == false){
$sql = "select zipcode.zipcode, sqrt(power(69.1*(zipcode.latitude - $lat1),2)+
power(69.1*(zipcode.longitude-$long1)*cos(zipcode.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.latitude - $lat1),2)+
power(69.1*(zipcode.longitude-$long1)*cos(zipcode.latitude/57.3),2)) < " .
$cboDist ;
$result = mysql_query($sql,$conn);
$count = mysql_num_rows($result);
echo "<blockquote><table 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 2199
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_db("tbcdealers");
$query = "select * from zipcode where Zipcode = '" . $txtZip . "'";
$result = mysql_query($query,$conn);
$row = mysql_fetch_row($result);
if ($row == false) {
$errflag = true;
$errmsg = "The Zip Code you entered is invalid";
echo "<blockquote>$errmgs</blockquote>";
}
else {
$lat1 = $row[3];
$long1 = $row[4];
}
if ($errflag == false){
$sql = "select zipcode.zipcode, sqrt(power(69.1*(zipcode.latitude - $lat1),2)+
power(69.1*(zipcode.longitude-$long1)*cos(zipcode.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.latitude - $lat1),2)+
power(69.1*(zipcode.longitude-$long1)*cos(zipcode.latitude/57.3),2)) < " .
$cboDist ;
$result = mysql_query($sql,$conn);
$count = mysql_num_rows($result);
echo "<blockquote><table 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_pconnect("[DSN Name]","[UID]","[PW]");
$Dealers=odbc_exec($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_fetch_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
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...
5
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...
4
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...
1
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...
25
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...
9
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
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...
5
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...
15
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.