RE: get id field in table

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



gonzalo...

i didn't see your original post... but this might help... assuming some
things... not actual code, but you might get the idea.

assume your tbl looks something like

mysql db/tbls:
table foo
 dog  -int
 cat  -varchar(10)
 etc...
 id   -auto generated

you can set up the mysql db/tbl to allow specified user(s) to access the
db/tbl, for the given port. specifiying/allowing user access is via the
'grant privilege' function for mysql.


in your php you need to connect with the db, as well as invoke queries that
are run on the targeted db

 $db2_host  	-host system (ip address)
 $db2_user 		-user for db (matches the grant)
 $db2_passwd 	-user passwd
 $db2_database 	-name of mysql database

 // Make the database connection.
 $link2 = new mysqli($db2_host, $db2_user, $db2_passwd, $db2_database);
 //check connection/error
 if(mysqli_connect_errno())
 {
    printf("connect2 err: %s\n",mysqli_connect_error());
    exit();
 }

 $q4 = "select * from foo where cat='ted';";

   $res = $link2->query($q4);
   while($row = $res->fetch_array(MYSQL_ASSOC))
   {
      $id = $row['id'];
   }

this gets you the 'id'....

to get a better understanding of how all this works, take a look at the
mysql site, as well as the sections of the php site that deal with
interfacing with mysql. you'll see the information on mysql/mysqli cmds, as
well as information on how to deal with the interfaces using procedural and
object oriented methods...

have fun!!!



-----Original Message-----
From: Jochem Maas [mailto:jochem@xxxxxxxxxxxxx]
Sent: Wednesday, December 20, 2006 8:24 AM
To: Roman Neuhauser
Cc: Gonzalo Gorosito; php-general@xxxxxxxxxxxxx
Subject: Re:  get id field in table


Roman Neuhauser wrote:
> # jochem@xxxxxxxxxxxxx / 2006-12-20 16:58:43 +0100:
>> Gonzalo Gorosito wrote:
>>> Hello!
>>>
>>>
>>>
>>> How can I identify the field ID in some table (MySQL)?
>> the answer is probably the opposite of the answer to the following
>> question:
>>
>> is this a mysql mailing list?
>
> Questions beginning with "How" usually aren't boolean. :)

you got me! I thought the guy was a Soiux indian - and that we was saying
hello :-P
given that my cleverly disguised 'f*** off with your off topic question'
reply
has bneen blown clear out of the water I feel obliged to provide a pointer
to the answer.

YO GONZALO - IM ASSUMING YOUR USING PHP ... start by reading this page:

	http://php.net/manual/en/function.mysql-fetch-field.php

>

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

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux