You are here: Re: php + mysql. updating various tables using the same peice of code. « PHP Programming Language « IT news, forums, messages
Re: php + mysql. updating various tables using the same peice of code.

Posted by Kurt Milligan on 01/28/07 13:33

Hi

While I'm not entirely sure I understand your issue, it seems like
there are a couple of possibilities:
1) Give the date field in every table the same name (which can be
confusing unless they have the same purpose; however, having an
"updated" timestamp field in every table can be handy to know when a
record was last updated).
2) Have an associative array that maps from table name to date field
name. So, depending on the table you are using, you get the name of
the date field from the array, like:
$dateFields = array('users' => 'user_table_date_field', 'addresses' =>
'address_table_date_field');

$stmt = 'select * from users where '.$dateFields['users'].' =
'.cleanUp($_GET['date']);

[The "cleanUp()" function is not really part of the discussion...I
just wanted to make sure you are checking the input for Bad Stuff
before using it in a query, as anyone can put anything in the GET.]

HTH

-Kurt

On Jan 27, 7:41 am, "McGowan" <Boome...@gmail.com> wrote:
> Hey, I'm wondering how I can get an update statement to work with data
> being passed through the URL. the problem is that the statement needs
> to work no matter what table is being worked on as any table must be
> able to be processed by the same page.
>
> The problem is that I can't use $_GET['field_name'] because I dont
> know what the field name is going to be. Also I do not know what field
> is going to be the primary key so I don't know how to get the 'where'
> statement to work properly.
>
> I realise there are probably tens if not hundreds of ways of making
> this work but I honestly can't do it.
>
> Thanks,
> Oliver

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация