RE: [PHP-DB] PHP&MySQL left/substring etc problem

2005-04-18 Thread Juffermans, Jos
If you do "SELECT LEFT(loc1,3) FROM openart_table" the column name in $row
(Bis probably not "loc1". Try this: "SELECT LEFT(loc1,3) AS loc1 FROM
(Bopenart_table". Also, after the fetch you can do some debuggin thru this:
(B
(B"; print_r($row); print "";
(B?>
(B
(BThat prints out a list of all the keys and values of $row and tells you what
(Bcolumns you're receiving (and their names).
(B
(BJos
(B
(B-Original Message-
(BFrom: Sugimoto [mailto:[EMAIL PROTECTED]
(BSent: 19 April 2005 07:58
(BTo: php-db@lists.php.net
(BSubject: [PHP-DB] PHP&MySQL left/substring etc problem
(B
(B
(BHello,
(BI need your help about PHP (ver 4.3.1) and MySQL (ver 3.23) database.
(BI am struggling to customise a database (using left command etc), and am
(Bstuck now.
(BPlease have a brief look at my scripts below.
(B
(BWhat I do like to do is to get first 3 letters from "loc1" column from
(Bopenart_table (MySQL).
(BAnd show the data in the follwoing part...
(B  
(B
(Bbut also I would like to make hyperlinks to jpg files to images/"the first 3
(Bletters from loc1".jpg
(BSo it will be something like this...
(B  
(B  .jpg">
(B  
(B
(BBut when I tried, "select left (loc1,3) from openart_table where.."
(Bdoesnt work properly.
(BI do not want to destroy anything for the rest of the table.
(BI need all data from "tit1", "pub1", "id1", and "ref1" in each column.
(B
(BCould you help me, please?
(B
(B-PHP script from here
(B
(B
(B
(B
(BID No
(BBook Title
(BPublisher
(BID
(BReference
(BLocation
(B
(B
(B";
(B while($row = mysql_fetch_array($result)){
(B  ?>
(B  
(B  ">
(B  
(B  
(B  
(B  
(B  
(B  
(B  
(B
(B
(B
(B
(Bend of script
(B
(B-- 
(BPHP Database Mailing List (http://www.php.net/)
(BTo unsubscribe, visit: http://www.php.net/unsub.php
(B
(B-- 
(BPHP Database Mailing List (http://www.php.net/)
(BTo unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DB] PHP&MySQL left/substring etc problem

2005-04-18 Thread Andrés G . Montañez
> But when I tried, "select left (loc1,3) from openart_table where.."

Try without the space between 'left' and '(',
I mean... LEFT(loc1, 3)
where loc1 is the name of the column,
and 3 the characters you want to show.

-- 
Atte, Andrés G. Montañez
Técnico en Redes y Telecomunicaciones
Montevideo - Uruguay

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