[PHP-DB] Re: moving a selection of records from one table to another (identicalin structure) table?

2006-09-27 Thread Kae Verens

Evert wrote:

Hi all!

What is the best/easiest way to use PHP to move a selection of MySQL
records from one table to another table, which is in the same database
and which has the same structure as the first table?


here's a stab at it (not tested):

$ids_to_get(1,3,5,6,8);
$q=mysql_query(
'select * from from_table
where id='.join(' or id=',$ids_to_get).''
);
while($r=mysql_fetch_array($q)){
$fields=array();
foreach($r as $k=$v)$fields[]='`'.$k.'`='.addslashes($v);
echo('insert into to_table set '.join(',',$fields).'br /');
#   mysql_query('insert into to_table set '.join(',',$fields));
}


obviously, first try the above to make sure the SQL looks right, before you 
uncomment the line that does the damage


Kae

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



[PHP-DB] Re: moving a selection of records from one table to another (identicalin structure) table?

2006-09-27 Thread Kae Verens

Evert wrote:
 Hi all!

 What is the best/easiest way to use PHP to move a selection of MySQL
 records from one table to another table, which is in the same database
 and which has the same structure as the first table?

here's a stab at it (not tested):

$ids_to_get(1,3,5,6,8);
$q=mysql_query(
'select * from from_table
where id='.join(' or id=',$ids_to_get).''
);
while($r=mysql_fetch_array($q)){
$fields=array();
foreach($r as $k=$v)$fields[]='`'.$k.'`='.addslashes($v);
echo('insert into to_table set '.join(',',$fields).'br /');
#mysql_query('insert into to_table set '.join(',',$fields));
}


obviously, first try the above to make sure the SQL looks right, before you 
uncomment the line that does the damage


Kae

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



[PHP-DB] Re: searching through a string

2006-09-18 Thread Kae Verens

Ron Piggott (PHP) wrote:

If $file_name includes the path
/path/to/file/file_name.pdf
is there anyway of searching from the right hand side to the left and
getting the file name out the $file_name variable?  The file name starts
the character following the last /


this should do it.
$filename=preg_replace('/.*\//','',$filename);

Kae

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



[PHP-DB] Re: reg expressions- please help!!!!!1

2005-03-08 Thread Kae Verens
Jonathan Trepczyk wrote:
 i am trying to use regular expressions in php to query a Mysql
 database( obviously flights tables).
 
 the idea is to provide a a search tool for the users to type in flight
 searchs, eg. when is the next flight from London heathrow to
 Manchester or how much is a flight from London Gatwick to Manchester.
 etc
 
 can some help with some ideas or sql queries i can use to query my
 database and then provide an appropriate answer or response to eaach
 query

you haven't provided any information on why regular expressions are needed
in this case.

can you provide a sample table and query?

-- 
kae verens
http://verens.com/

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



Re: [PHP-DB] PHP and JOIN... (I know.. it's easy!)

2005-03-08 Thread Kae Verens
Tristan Pretty wrote:
 I'll then make a page that looks like this:
 
 file name:  User(s)
 12.doc  [EMAIL PROTECTED] (12 times)
 [EMAIL PROTECTED] (1 times)
 [EMAIL PROTECTED] (2 times)
 etc..
 
 I'll make the email addresses/file name links to detailed info, but I'm
 fine with doing that...
 
 Once I see a few Joins in action based on what I'm trying to do, I'll get
 it.. I'm self taught (as most of us are right?) and learn better from real
 life example than books...
 
 Please find my table structure below...
 
 ===
 
 // stores only file id, user id and date etc...
 CREATE TABLE `captures` (
   `id` int(11) NOT NULL auto_increment,
   `user_id` int(11) NOT NULL default '0',
   `date` date NOT NULL default '-00-00',
   `file_id` int(8) NOT NULL default '0',
   `page_id` int(11) NOT NULL default '0',
   `ip` varchar(255) NOT NULL default '',
   PRIMARY KEY  (`id`)
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=22 ;
 
 // all data pertainign to the file
 CREATE TABLE `files` (
   `file_master_bu` varchar(255) NOT NULL default '',
   `id` int(8) NOT NULL auto_increment,
   `uploaded_by` varchar(255) NOT NULL default '',
   `uploaded_date` date NOT NULL default '-00-00',
   `edited_by` varchar(255) NOT NULL default '',
   `edited_date` date NOT NULL default '-00-00',
   `file_title` varchar(255) NOT NULL default '',
   `file_name` varchar(255) NOT NULL default '',
   `file_cat` varchar(255) NOT NULL default '',
   `file_type` varchar(255) NOT NULL default '',
   `file_desc` text NOT NULL,
   PRIMARY KEY  (`id`)
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=19 ;
 
 // the users who fill out forms, are put here. I do a search each download
 to see if they're in the database already, based on email address... but
 that's kinda irrelevent here... ;-)
 CREATE TABLE `users` (
   `id` int(11) NOT NULL auto_increment,
   `salutation` varchar(255) NOT NULL default '',
   `forename` varchar(255) NOT NULL default '',
   `surname` varchar(255) NOT NULL default '',
   `email` varchar(255) NOT NULL default '',
   `tel` varchar(255) NOT NULL default '',
   `fax` varchar(255) NOT NULL default '',
   `company` varchar(255) NOT NULL default '',
   `job_title` varchar(255) NOT NULL default '',
   `street` varchar(255) NOT NULL default '',
   `street2` varchar(255) NOT NULL default '',
   `city` varchar(255) NOT NULL default '',
   `zip` varchar(255) NOT NULL default '',
   `state` varchar(255) NOT NULL default '',
   `country` varchar(255) NOT NULL default '',
   `hear` varchar(255) NOT NULL default '',
   `us_opt` varchar(255) NOT NULL default '',
   `eu_opt` varchar(255) NOT NULL default '',
   PRIMARY KEY  (`id`)
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=13 ;


select count(captures.id)file_name,email from capture,files,users where
users.id=captures.user_id and files.id=captures.file_id group by file_name;

That /may/ do it.

-- 
kae verens
http://verens.com/

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



[PHP-DB] Re: How to calculate size of INT(x) field

2004-03-05 Thread Kae Verens
Richard Davey wrote:

Hi all,

Sorry for such a newbie question! But I have been digging through the
O'Reilly MySQL book + MySQL Cookbook and cannot find an answer to what
I think is a very simple question:
When creating an unsigned INT field, how does the value in brackets
(if given) limit the size of the field? I.e. what is the difference in
possible maximum values held between an INT(10) and an INT(4)? I know
MySQL will create an INT(10) as standard but I'm not sure I need it to
be able to hold a number that high.
IIRC, the highest permitted value of an unsigned int is:
8^(number of bytes)-1
so, INT(4) above is 8^4-1 (approx 65500), and INT(10) is 8^10-1 (quite a 
bit bigger)

Kae

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


Re: [PHP-DB] option selected

2002-11-25 Thread Kae Verens
mike karthauser wrote:



Once i have selected from the drop box the variable is submitted back 
to my
table and saved.

When re-edit the data - the record already has a value for catcode which i
want to reflect within the drop box - in html it would be the addition of
selected=selected within the .

Are there any recommended methods of doing this?


I'd change the following:
 printf(option value=\%s\%s/option\n, $myrow[catcode],
$myrow[title]);

into this:
$l=$myrow['catcode'];
?option value=?=$l;??=($catcode==$l)?' 
selected=selected':;??=$myrow['cattitle'];?/option?

--
Kae Verens   ___\_   webworks.ie
work: www.webworks.ie   _\\__   webhosts
play: www.contactjuggling.org  ___\\\___  design
kae:  kverens.contactjuggling.org _ code


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



[PHP-DB] problem selecting from mssql database

2002-10-02 Thread Kae Verens

I have connected successfully to an MSSQL server, as can be seen by the 
following generated list of existing tables:
http://webworks.ie/200210/

When I try to select from those tables, I get errors, as seen here:
http://webworks.ie/200210/newhomes.php

The source of the above is here:
http://webworks.ie/200210/newhomes.phps

-- 
Kae Verens   ___\_   webworks.ie
work: www.webworks.ie   _\\__   webhosts
play: www.contactjuggling.org  ___\\\___  design
kae:  kverens.contactjuggling.org _ code


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




[PHP-DB] problem selecting from mssql db

2002-10-02 Thread Kae Verens

I have connected successfully to an MSSQL server, as can be seen by the 
following generated list of existing tables:
http://webworks.ie/200210/

When I try to select from those tables, I get errors, as seen here:
http://webworks.ie/200210/newhomes.php

The source of the above is here:
http://webworks.ie/200210/newhomes.phps

any obvious errors?

-- 
Kae Verens   ___\_   webworks.ie
work: www.webworks.ie   _\\__   webhosts
play: www.contactjuggling.org  ___\\\___  design
kae:  kverens.contactjuggling.org _ code


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