[PHP-DB] parsing PHP from blob varaibles

2005-04-18 Thread [EMAIL PROTECTED]
When a php statement is part of a markup snippet in a mysql database
table field, what must be done to have the php parse in the html document. 

A simple demo demonstrating my problem is at
http://www.boclair.com/test/blobvars.php
Louise


SV: [PHP-DB] PHP and MySql question

2005-04-18 Thread Henrik Hornemann
Hi,

Your problem is that your variables $Lat1,$Lat2,$Lon1,$Lon2 all reffer
to resultsets and not the Latitudes or Longitudes.
Try something like this: 

$res = mysql_query(
SELECT ZG_LATITUDE, ZG-LONGITUDE FROM zip_code where
zg_zipcode = '$zip');
List($Lat,$Lon) = mysql_fetch_row($res);
$Lat1=Lat-2; $Lat2=Lat+2; $Lon1=Lon-2; $Lon2=Lat+2;

Now you can use the values in your final query. 

Hth Henrik Hornemann 

-Oprindelig meddelelse-
Fra: ReClMaples [mailto:[EMAIL PROTECTED] 
Sendt: 16. april 2005 22:38
Til: php-db@lists.php.net
Emne: [PHP-DB] PHP and MySql question

Hello, I'm kinda new at PHP programming with MySQL.  I am having an
issue and am not sure if this is the corret way to do this:  Here is my
code, I'll start there:

?php

  $Lat1 = mysql_query(
SELECT (ZG_LATITUDE-2) FROM zip_code where zg_zipcode =
'$zip');
  if (!$Lat1) {
echo(PError performing query:  .
 mysql_error() . /P);
exit();
  }

$Lat2 = mysql_query(
SELECT (ZG_LATITUDE+2) FROM zip_code where zg_zipcode =
'$zip');
  if (!$Lat2) {
echo(PError performing query:  .
 mysql_error() . /P);
exit();
  }

$Lon1 = mysql_query(
SELECT (ZG_LONGITUDE-2) FROM zip_code where zg_zipcode =
'$zip');
  if (!$Lon1) {
echo(PError performing query:  .
 mysql_error() . /P);
exit();
  }

$Lon2 = mysql_query(
SELECT (ZG_LONGITUDE+2) FROM zip_code where zg_zipcode =
'$zip');
  if (!$Lon2) {
echo(PError performing query:  .
 mysql_error() . /P);
exit();
  }

$ZipCode = mysql_query(
SELECT * FROM zip_code where ZG_LATITUDE = '$Lat1'
and ZG_LATITUDE = '$Lat2' and ZG_LONGITUDE = '$Lon1' and ZG_LONGITUDE
= '$Lon2');
  if (!$Zipcodesearch) {
echo(PError performing query:  .
 mysql_error() . /P);
exit();
  }

  while ( $row = mysql_fetch_array($ZipCode) ) {
echo(bCity: /b . $row[ZG_CITY]. br);
echo(bState: /b . $row[ZG_STATE]. br); echo(bZip Code:
/b . $row[ZG_ZIPCODE]. br); echo(bArea Code: /b .
$row[ZG_AREACODE]. br); echo(bCounty FIPS: /b .
$row[ZG_COUNTY_FIPS]. br); echo(bCounty Name: /b .
$row[ZG_COUNTY_NAME]. br); echo(bTime Zone: /b .
$row[ZG_TIME_ZONE]. br); echo(bDay Light Savings?: /b .
$row[ZG_DST]. br);
echo(bLatitude: /b . $row[ZG_LATITUDE]. br);
echo(bLongitude: /b . $row[ZG_LONGITUDE]. P); } ?

Basically I'm trying to have a user input a zip code and then have a php
script pull all zip codes that are in a region of that submitted zip
code.
Can you have a look at my code and see what I'm doing wrong?  When using
this it returns no results but makes the connection to the database so I
have to believe that it's within here that I have my issue.

I have Apache/2.0.47 (Win32) PHP/4.3.9 Server and MySql 4.0.14 (I know I
can upgrade and be able to do subselects but I would like to know what
I'm doing wrong here.

Thanks in advance for any help.

Thanks
-rich

--
PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] Parsing PHP sourced from blob

2005-04-18 Thread boclair
When a php statement is part of a markup snippet in a mysql database
table field, what must be done to have the php parse in the html
A simple demo demonstrating my problem is at
http://www.boclair.com/test/blobvars.php
Louise
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP-DB] Parsing PHP sourced from blob

2005-04-18 Thread Bastien Koert
try eval (http://ca3.php.net/manual/en/function.eval.php)
Bastien
From: boclair [EMAIL PROTECTED]
To: php-db@lists.php.net php-db@lists.php.net
Subject: [PHP-DB] Parsing PHP sourced from blob Date: Mon, 18 Apr 2005 
17:52:52 +1000

When a php statement is part of a markup snippet in a mysql database
table field, what must be done to have the php parse in the html
A simple demo demonstrating my problem is at
http://www.boclair.com/test/blobvars.php
Louise
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DB] Re: php and tables

2005-04-18 Thread Frank M Flynn
There are two places you can figure out the average: in MySQL or in 
PHP.  Then  you want to sort the results by this Average: in MySql use 
ORDER BY and  in php use array_multisort

in  MySQL your SQL might look like:
SELECT   TEAM, PLAYED, WIN, LOSS, DRAW, POINTS, POINTS / PLAYED as 
AVERAGE
  FROM your  table
  ORDER BY AVERAGE desc

in PHP you'd  have to loop through your results loading  them into a 
local array with  an additional column for average and then use 
array_multisort which has many options (and  I don't exactly remember 
how to make  it  work exactly but look at:  
http://www.phpbuilder.com/manual/function.array-multisort.php to 
see).

I'd do it in  MySQL  but that's me...
Good luck,
Frank
On Apr 17, 2005, at 2:13 PM, [EMAIL PROTECTED] wrote:
From: Vikas Nanda [EMAIL PROTECTED]
Date: April 17, 2005 7:39:57 AM PDT
To: php-db@lists.php.net
Subject: php and tables
Hi
I am new to php and mysql and am having a few problems that I hope 
someone can help with.

What I am trying to do is to display ratings for particular teams 
using some basic code. I needed to print the information out on a 
table with the highest average at the top and then ascending. I have 
all this info stored in a mysql db.
eg
 TEAMPLAYED  WIN   LOSS   DRAW  POINTS   AVERAGE
ENGLAND 16   6 6  4  16
  1.00

I don't know how to print variables out in a table and I don't know 
how to make it ascending.

Any help would be much appreciated.
Thanks
Vikas


RE: [PHP-DB] PHP and MySql question

2005-04-18 Thread ReClMaples
Ok, I tried what you saidHere's the code:

$res = mysql_query(
SELECT ZG_LATITUDE, ZG_LONGITUDE FROM zip_code where
zg_zipcode = '$zip');
List($Lat,$Lon) = mysql_fetch_row($res);
$Lat1 = ($Lat-2);
$Lat2= ($Lat+2);
$Lon1= ($Lon-2);
$Lon2= ($Lon+2);

//echo ($Lat1);
//echo ($Lat2);
//echo ($Lon1);
//echo ($Lon2);

$zipcode = mysql_query(
  SELECT * FROM zip_code where ZG_LATITUDE = $Lat1
and ZG_LATITUDE = $Lat2 and ZG_LONGITUDE = $Lon1 and ZG_LONGITUDE =
$Lon2);
if (!$zipcode) {
echo(PError performing query:  .
 mysql_error() . /P);
exit();
}


while ( $row = mysql_fetch_array($zipcode) )
{
echo(bCity: /b . $row[ZG_CITY]. br);
echo(bState: /b . $row[ZG_STATE]. br);
echo(bZip Code: /b . $row[ZG_ZIPCODE]. br);
echo(bArea Code: /b . $row[ZG_AREACODE]. br);
echo(bCounty FIPS: /b . $row[ZG_COUNTY_FIPS]. br);
echo(bCounty Name: /b . $row[ZG_COUNTY_NAME]. br);
echo(bTime Zone: /b . $row[ZG_TIME_ZONE]. br);
echo(bDay Light Savings?: /b . $row[ZG_DST]. br);
echo(bLatitude: /b . $row[ZG_LATITUDE]. br);
echo(bLongitude: /b . $row[ZG_LONGITUDE]. P);

}

I get no results with this still, it acutally doesn't even go to the this
page.  When I uncomment out:

//echo ($Lat1);
//echo ($Lat2);
//echo ($Lon1);
//echo ($Lon2);

and comment out everything below this, I get the expected results for
$Lat1,$Lat2,$Lon1, and $Lon2.  So I have to believe my issue is below those
lines, can anyone see what I have that is incorrect here?

-Original Message-
From: Henrik Hornemann [mailto:[EMAIL PROTECTED]
Sent: Monday, April 18, 2005 2:44 AM
To: php-db@lists.php.net
Subject: SV: [PHP-DB] PHP and MySql question


Hi,

Your problem is that your variables $Lat1,$Lat2,$Lon1,$Lon2 all reffer
to resultsets and not the Latitudes or Longitudes.
Try something like this:

$res = mysql_query(
SELECT ZG_LATITUDE, ZG-LONGITUDE FROM zip_code where
zg_zipcode = '$zip');
List($Lat,$Lon) = mysql_fetch_row($res);
$Lat1=Lat-2; $Lat2=Lat+2; $Lon1=Lon-2; $Lon2=Lat+2;

Now you can use the values in your final query.

Hth Henrik Hornemann

-Oprindelig meddelelse-
Fra: ReClMaples [mailto:[EMAIL PROTECTED]
Sendt: 16. april 2005 22:38
Til: php-db@lists.php.net
Emne: [PHP-DB] PHP and MySql question

Hello, I'm kinda new at PHP programming with MySQL.  I am having an
issue and am not sure if this is the corret way to do this:  Here is my
code, I'll start there:

?php

  $Lat1 = mysql_query(
SELECT (ZG_LATITUDE-2) FROM zip_code where zg_zipcode =
'$zip');
  if (!$Lat1) {
echo(PError performing query:  .
 mysql_error() . /P);
exit();
  }

$Lat2 = mysql_query(
SELECT (ZG_LATITUDE+2) FROM zip_code where zg_zipcode =
'$zip');
  if (!$Lat2) {
echo(PError performing query:  .
 mysql_error() . /P);
exit();
  }

$Lon1 = mysql_query(
SELECT (ZG_LONGITUDE-2) FROM zip_code where zg_zipcode =
'$zip');
  if (!$Lon1) {
echo(PError performing query:  .
 mysql_error() . /P);
exit();
  }

$Lon2 = mysql_query(
SELECT (ZG_LONGITUDE+2) FROM zip_code where zg_zipcode =
'$zip');
  if (!$Lon2) {
echo(PError performing query:  .
 mysql_error() . /P);
exit();
  }

$ZipCode = mysql_query(
SELECT * FROM zip_code where ZG_LATITUDE = '$Lat1'
and ZG_LATITUDE = '$Lat2' and ZG_LONGITUDE = '$Lon1' and ZG_LONGITUDE
= '$Lon2');
  if (!$Zipcodesearch) {
echo(PError performing query:  .
 mysql_error() . /P);
exit();
  }

  while ( $row = mysql_fetch_array($ZipCode) ) {
echo(bCity: /b . $row[ZG_CITY]. br);
echo(bState: /b . $row[ZG_STATE]. br); echo(bZip Code:
/b . $row[ZG_ZIPCODE]. br); echo(bArea Code: /b .
$row[ZG_AREACODE]. br); echo(bCounty FIPS: /b .
$row[ZG_COUNTY_FIPS]. br); echo(bCounty Name: /b .
$row[ZG_COUNTY_NAME]. br); echo(bTime Zone: /b .
$row[ZG_TIME_ZONE]. br); echo(bDay Light Savings?: /b .
$row[ZG_DST]. br);
echo(bLatitude: /b . $row[ZG_LATITUDE]. br);
echo(bLongitude: /b . $row[ZG_LONGITUDE]. P); } ?

Basically I'm trying to have a user input a zip code and then have a php
script pull all zip codes that are in a region of that submitted zip
code.
Can you have a look at my code and see what I'm doing wrong?  When using
this it returns no results but makes the connection to the database so I
have to believe that it's within here that I have my issue.

I have Apache/2.0.47 (Win32) PHP/4.3.9 Server and MySql 4.0.14 (I know I
can upgrade and be able to do subselects but I would like to know what
I'm doing wrong here.

Thanks in advance for any help.

Thanks
-rich

--
PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] PHPMySQL left/substring etc problem

2005-04-18 Thread Sugimoto
Hello,
I need your help about PHP (ver 4.3.1) and MySQL (ver 3.23) database.
I am struggling to customise a database (using left command etc), and am
stuck now.
Please have a brief look at my scripts below.

What I do like to do is to get first 3 letters from "loc1" column from
openart_table (MySQL).
And show the data in the follwoing part...
  td? echo $row["loc1"]; ?br/td

but also I would like to make hyperlinks to jpg files to images/"the first 3
letters from loc1".jpg
So it will be something like this...
  td
  a href="/image/? echo $row["loc1"]; ?.jpg"? echo $row["loc1"];
?/abr
  /td

But when I tried, "select left (loc1,3) from openart_table where.."
doesnt work properly.
I do not want to destroy anything for the rest of the table.
I need all data from "tit1", "pub1", "id1", and "ref1" in each column.

Could you help me, please?

-PHP script from here
html
body
table border="1" bordercolor="black" cellspacing="0" align="center"
BGCOLOR="#CC" width="900"
tr bgcolor="#ffcc66"
td align="center"bID No/bbr/td
td align="center" BGCOLOR="#CC3366"bBook Title/bbr/td
td align="center"bPublisher/bbr/td
td align="center"bID/bbr/td
td align="center"bReference/bbr/td
td align="center" width="10%"bLocation/bbr/td
/tr

?
mysql_connect(localhost,root,cheers);
mysql_select_db(openart);
if($tit == "" 
   $res == "" 
   $pub == "" 
   $date == "" 
   $id == "" 
   $ref == "" 
   $loc == "" 
   $type == "" 
   $vol == "" 
   $fre == "" 
   $note == "")
{
 echo 'Type something';
}

elseif($tit == "%" || $res == "%" || $pub == "%" || $date == "%" || $id ==
"%" ||
   $ref == "%" || $loc == "%" || $type == "%" || $vol == "%" || $fre ==
"%" || $note == "%"){
 echo 'Not Valid';
}

else{
 if($tit == ""){
$tit = '%';
 }
 if($res == ""){
$res = '%';
 }
 if($pub == ""){
$pub = '%';
 }
 if($date == ""){
   $date = '%';
 }
 if($id == ""){
   $id = '%';
 }
 if($ref == ""){
$ref = '%';
 }
 if($loc == ""){
$loc = '%';
 }
 if($type == ""){
$type = '%';
 }
 if($vol == ""){
$vol = '%';
 }
 if($fre == ""){
$fre = '%';
 }
 if($note == ""){
$note = '%';
 }
$result = mysql_query("select * from openart_table
 where tit1   like '%$tit%'
   and res1   like '%$res%'
   and pub1  like '%$pub%'
   and date1  like '%$date%'
   and id1   like '%$id%'
   and ref1  like '%$ref%'
   and loc1  like '%$loc%'
   and type1   like '%$type%'
   and vol1  like '%$vol%'
   and fre1  like '%$fre%'
   and note1   like '%$note%' order by tit1");

$rows = mysql_num_rows($result);
 echo $rows,"Records Found p";
 while($row = mysql_fetch_array($result)){
  ?
  tr
  tda href = "openart_detail.php ?iden=? echo $row["openart_id"] ?"?
echo $row["openart_id"]; ?/abr/td
  td? echo $row["tit1"]; ?br/td
  td? echo $row["pub1"]; ?br/td
  td? echo $row["id1"]; ?br/td
  td? echo $row["ref1"]; ?br/td
  td? echo $row["loc1"]; ?br/td
  /tr
  ?
   }
}
?
/table
/body
/html

end of script

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php