[thelist] MySQL/PHP Associative Array Insert
R.Livsey
R.Livsey at cache-22.co.uk
Sat Feb 1 12:50:01 CST 2003
Bill Haenel wrote:
>.....
> user_id='".$data['user_id']."',
> s_date='".$data['s_date']."',
> e_date='".$data['e_date']."',
> title='".$data['title']."',
> content='".$data['content']."'
> WHERE annc_id='".$data['annc_id']."'";
> if (empty($update)) {
> $query = "INSERT INTO cal_announcements
> (user_id,s_date,e_date,title,content)
> VALUES
> ('".$data['user_id']."',
> '".$data['$s_date']."',
> '".$data['e_date']."',
> '".$data['title']."',
> '".$data['content']."')";
>
>.....
>
>
<tip type="php - cleaner code">
If you are using complex variables such as associative arrays in a
string you can enclose them with curly braces in order to get PHP to
parse them.
ie:
$str = "here are some values of an associative array:
{$assocArr['one']}, {$assocArr['foo']}, {$assocArr['bar']}.";
much nicer (IMO) than
$str = "here are some values of an associative array:
".$assocArr['one'].", ".{$assocArr['foo']}.", ".{$assocArr['bar']}.".";
</tip>
--
R.Livsey
Incutio Web Developer
[ PHP | Perl | Java | C# ]
www.cache-22.co.uk
www.incutio.com
More information about the thelist
mailing list