[PHP] Implode a 2D Array

2009-07-02 Thread salmarayan

Can any one tell me how can i implode a two D Array.
i can implode normal arrays, but when i try to implode multidimensional
Arrays, the result is empty.
can some one tell me how to implode an array Like This


$x=array ( [0] = array ( [side] = sell [stock_code] = AFMC.CA [quantity]
= 200  ) ,
[1] = array ( [side] = buy [stock_code] = AFMC.CA [quantity] = 200 );

i want to implode it in a way, the later one i can seperate rows, meaning i
can seperate [0] from [1] and the elements in each row, like the side stock
code using the SPLIT function.
Thanks in Advance. :)
-- 
View this message in context: 
http://www.nabble.com/Implode-a-2D-Array-tp24313886p24313886.html
Sent from the PHP - General mailing list archive at Nabble.com.


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



Re: [PHP] Implode a 2D Array

2009-07-02 Thread Shawn McKenzie
salmarayan wrote:
 Can any one tell me how can i implode a two D Array.
 i can implode normal arrays, but when i try to implode multidimensional
 Arrays, the result is empty.
 can some one tell me how to implode an array Like This
 
 
 $x=array ( [0] = array ( [side] = sell [stock_code] = AFMC.CA [quantity]
 = 200  ) ,
 [1] = array ( [side] = buy [stock_code] = AFMC.CA [quantity] = 200 );
 
 i want to implode it in a way, the later one i can seperate rows, meaning i
 can seperate [0] from [1] and the elements in each row, like the side stock
 code using the SPLIT function.
 Thanks in Advance. :)

You'll have to be more specific in what you want the end result to be
becuse I'm confused.  You already have 0 and 1 separated.  How do you
want to glue them? Maybe you don't really want to implode() them? If you
really want to implode each one, then:

foreach($x as $array) {
$row[] = implode(',', $array);
}

Or maybe (not tested):

$rows = array_map('implode', array_fill(0, count($x), ','), $x);



-- 
Thanks!
-Shawn
http://www.spidean.com

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



[PHP] implode()

2008-11-18 Thread Terion Miller
I have read the whole forum at php.net on implode and I still don't get why
this one does not work

if (isset($_POST['BannerSize'])){$BannerSize =
implode($_POST['BannerSize'],',');} else {$BannerSize = ;}

someone please help


Re: [PHP] implode()

2008-11-18 Thread Yeti
with implode one can reverse the function arguments i know .. but

?php
$BannerSize = '';
if (isset($_POST['BannerSize'])  is_array($_POST['BannerSize']))
{
$BannerSize = implode(',', $_POST['BannerSize']);
}

?

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



Re: [PHP] implode()

2008-11-18 Thread Greg Bowser
$BannerSize = implode($_POST['BannerSize'], ',');

Looks like you have your arguments backwards; try:

$BannerSize = implode(',',$_POST['BannerSize']);

--Greg


Re: [PHP] implode()

2008-11-18 Thread Craige Leeder

Terion Miller wrote:

I have read the whole forum at php.net on implode and I still don't get why
this one does not work

if (isset($_POST['BannerSize'])){$BannerSize =
implode($_POST['BannerSize'],',');} else {$BannerSize = ;}

someone please help

  

Is $_POST['BannerSize'] an array?

e.g. IS there:

$_POST['BannerSize'][1]
$_POST['BannerSize'][2]

Or something similar?

- Craige

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



Re: [PHP] implode()

2008-11-18 Thread Craige Leeder

Can we see the form, please?

As well, try using print_r on the array and see what it outputs.

- Craige

Terion Miller wrote:
yes there is , the selections are coming from a form (which isn't 
working because its not inserting into the db---ah another post later 
I imagine)
do you think a mis used implode would keep any of the data from making 
it to the db? 
I'm more of a designer than a programmer and feel like I'm drowning 
over my head here...





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



Re: [PHP] implode()

2008-11-18 Thread Dan Shirah
On 11/18/08, Terion Miller [EMAIL PROTECTED] wrote:

 I have read the whole forum at php.net on implode and I still don't get
 why
 this one does not work

 if (isset($_POST['BannerSize'])){$BannerSize =
 implode($_POST['BannerSize'],',');} else {$BannerSize = ;}

 someone please help


You appear to have it backwards?  Using implode() you should have your
glue (the value you want to identify to implode on) before your $variable.

It looks like you are trying to implode on a comma, correct? So using the
proprer format of implode(glue,variable) you should so something like:

implode(',',$_POST['BannerSize']);

Dan


Re: [PHP] implode()

2008-11-18 Thread Jim Lucas
Terion Miller wrote:
 I have read the whole forum at php.net on implode and I still don't get why
 this one does not work
 
 if (isset($_POST['BannerSize'])){$BannerSize =
 implode($_POST['BannerSize'],',');} else {$BannerSize = ;}
 
 someone please help
 

Including the error that is generated would be a good place to start when 
asking for help.

To us, it is pretty obvious what the problem could be.

But the error would help.

-- 
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare


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



[PHP] Implode? Explode?

2005-06-06 Thread Jack Jackson

Hi all,
I'm trying to fetch similar things - in this case, rows which share a 
series ID no - and bring them into an array and display them grouped by 
 what makes them similar (in this case, series id). I looked at implode 
and explode which seem wrong for this - the only separator I can see is 
that they're each in a table cell.


The result of my query returns something like:

art_id   series_id art_titleseries_name
2   1  Weddings 2004Summer Special
4   1  Summer In The City   Summer Special
5   2  Bags of NY   Op-Art
7   2  Dogs of NY   Op-Art


I'd like to create a list of links to each art_id grouped together as 
series, href code obviously not complete but demonstrative:


pSummer Specialbr /
a href='2'Weddings 2004/a | a href='4'Summer In The City/p

pOp-Artbr /
a href='5'Bags of NY/a | a href='7'Dogs of NY/p


?

Thanks in advance,
Jack

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



Re: [PHP] Implode? Explode?

2005-06-06 Thread Brent Baisley
You're close, but you need to group your data on the series_id first. 
You can do that by looping through your array and creating another 
array using series_id as the array key. You'll end up with a list of 
arrays named after the series_id.


foreach( $result_set as $result_item ) {
//Add an array item to the series_id slot of the grouped_result array
	$grouped_result[ $result_item['series_id'] ][]	= 
array('id'=$result_items['art_id'], 
'title'=$result_item['art_title']);

}

Now you have your data grouped by series_id. Each item of the 
grouped_result array will contain one or more arrays which contain the 
art_id and art_title.


If you are not familiar with multidimensional arrays, this may be a 
little confusing.




On Jun 6, 2005, at 8:32 AM, Jack Jackson wrote:


Hi all,
I'm trying to fetch similar things - in this case, rows which share a 
series ID no - and bring them into an array and display them grouped 
by  what makes them similar (in this case, series id). I looked at 
implode and explode which seem wrong for this - the only separator I 
can see is that they're each in a table cell.


The result of my query returns something like:

art_id   series_id art_titleseries_name
2   1  Weddings 2004Summer Special
4   1  Summer In The City   Summer Special
5   2  Bags of NY   Op-Art
7   2  Dogs of NY   Op-Art


I'd like to create a list of links to each art_id grouped together as 
series, href code obviously not complete but demonstrative:


pSummer Specialbr /
a href='2'Weddings 2004/a | a href='4'Summer In The City/p

pOp-Artbr /
a href='5'Bags of NY/a | a href='7'Dogs of NY/p


?

Thanks in advance,
Jack

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



--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search  Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577

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



Re: [PHP] Implode? Explode?

2005-06-06 Thread Jack Jackson



Brent Baisley wrote:
You're close, but you need to group your data on the series_id first. 
You can do that by looping through your array and creating another array 
using series_id as the array key. You'll end up with a list of arrays 
named after the series_id.


foreach( $result_set as $result_item ) {
//Add an array item to the series_id slot of the grouped_result array
$grouped_result[ $result_item['series_id'] ][]= 
array('id'=$result_items['art_id'], 'title'=$result_item['art_title']);

}


That did the trick, Brent. Thanks so much for this useful information.

Now you have your data grouped by series_id. Each item of the 
grouped_result array will contain one or more arrays which contain the 
art_id and art_title.


If you are not familiar with multidimensional arrays, this may be a 
little confusing.


A little is right! But tanks for the intro to multi-dimensional arrays!

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



Re: [PHP] Implode? Explode?

2005-06-06 Thread Richard Lynch
On Mon, June 6, 2005 5:32 am, Jack Jackson said:
 I'm trying to fetch similar things - in this case, rows which share a
 series ID no - and bring them into an array and display them grouped by
   what makes them similar (in this case, series id). I looked at implode
 and explode which seem wrong for this - the only separator I can see is
 that they're each in a table cell.

$query =  select series_id, ... from ... ;
$query .=  ORDER BY series_id, ... ;
$art = mysql_query($query) or die(mysql_error());
$series = array();
while (list($series_id, ...) = mysql_fetch_row($art)){
  $series[$series_name][] = a href=$art_id$art_title/a;
}
while (list($name, $links) = each($series)){
  echo p$namebr /, implode( | , $links), /p\n;
}



 The result of my query returns something like:

 art_id   series_id art_titleseries_name
 2 1  Weddings 2004Summer Special
 4 1  Summer In The City   Summer Special
 5   2  Bags of NY   Op-Art
 7   2  Dogs of NY   Op-Art


 I'd like to create a list of links to each art_id grouped together as
 series, href code obviously not complete but demonstrative:

 pSummer Specialbr /
 a href='2'Weddings 2004/a | a href='4'Summer In The City/p

 pOp-Artbr /
 a href='5'Bags of NY/a | a href='7'Dogs of NY/p


You could actually use:

ORDER BY series_date, series_name, series_id, art_id, art_title, art_id

or something like that, so long you are sorting first and foremost by the
SERIES information, and any other sorting happens AFTER all series_*
fields.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



[PHP] implode errors if array empty

2004-09-22 Thread luke
hi there,

i am using implode to get the contents of an array into a single variable:

$enterprises = implode(,, $enterprise) //enterprise contains the array.

however, if the array is empty (the user didnt select anything in the form),
the implode function errors out.

can anyone think of a way round this?

many thanks,

luke m.

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



Re: [PHP] implode errors if array empty

2004-09-22 Thread luke
resolved with if(empty()) - apologies.


[EMAIL PROTECTED] wrote:

 hi there,
 
 i am using implode to get the contents of an array into a single variable:
 
 $enterprises = implode(,, $enterprise) //enterprise contains the array.
 
 however, if the array is empty (the user didnt select anything in the form),
 the implode function errors out.
 
 can anyone think of a way round this?
 
 many thanks,
 
 luke m.

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



Re: [PHP] implode errors if array empty

2004-09-22 Thread Petar Nedyalkov
Hello,

I suppose the $enterprise variable doesn't hold an empty array but is not 
defined and because of this you get the error. Test with the following 
example:

?php

$array = array();
$comma_separated = implode(,, $array);

echo $comma_separated;

?

It does not send any errors back. If you substitute $array = array(); with 
$array = ; you'll get a woarning: Warning: implode(): Bad arguments. in 
temp.php on line 4.

Just have in mind that when posting multiple select fields and no options are 
selected - you simply have no corresponding value in the _POST array (or in 
the $enterpise variable if you're using register_globals). There's no empty 
array but nothing defined.

On Wednesday 22 September 2004 13:16, [EMAIL PROTECTED] wrote:
 hi there,

 i am using implode to get the contents of an array into a single variable:

 $enterprises = implode(,, $enterprise) //enterprise contains the array.

 however, if the array is empty (the user didnt select anything in the
 form), the implode function errors out.

 can anyone think of a way round this?

 many thanks,

 luke m.

-- 
Cyberly yours,
Petar Nedyalkov
Devoted Orbitel Fan :-)
-
Orbitel - the New Generation Telecom! See www.orbitel.bg.

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



Re: [PHP] implode errors if array empty

2004-09-22 Thread Marek Kilimajer
[EMAIL PROTECTED] wrote:
resolved with if(empty()) - apologies.
isset() is more apropriate as $enterprise is not defined at all, empty() 
will issue a notice.

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


Re: [PHP] implode errors if array empty

2004-09-22 Thread John Holmes
From: Marek Kilimajer [EMAIL PROTECTED]
 [EMAIL PROTECTED] wrote:
resolved with if(empty()) - apologies.
isset() is more apropriate as $enterprise is not defined at all, empty() 
will issue a notice.
No it won't. 

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


Re: [PHP] Implode slows down file reading? [was: str_replace performance in large mailing script]

2003-08-28 Thread Curt Zirzow
* Thus wrote CPT John W. Holmes ([EMAIL PROTECTED]):
 From: frederik feys [EMAIL PROTECTED]
 
  I thought str_replace caused slow down of my mailing script, but it
  seems to be this line of code:
 
  $fd =
  implode(,file(http://www.domain.org/store/min/Mailing_template.html;)
  );
 
  I first put the mailing template in $fd (only once) and then replace
  (str_replace) elements of it to individualize HTML emails.
  Btw i'm using php version 4.0.6.
 
  Are there better(faster) ways to read the contents of a file?
 
 file_get_contents() ?
unfortantly this is only (PHP 4 = 4.3.0).

imploading a file all the time from file simply doesn't make sense
to me, i would fread() the file directly into a string instead.

 
 The slow down is probably because you're going through HTTP to read the
 file. Is there a reason for that? Any way you can cache the file locally so
 it's not read through HTTP all of the time?

Yep, reading through http is  the slowdown.



Curt
-- 
I used to think I was indecisive, but now I'm not so sure.

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



[PHP] Implode slows down file reading? [was: str_replace performance in large mailing script]

2003-08-27 Thread frederik feys
Hi all,

I thought str_replace caused slow down of my mailing script, but it
seems to be this line of code:

$fd =
implode(,file(http://www.domain.org/store/min/Mailing_template.html;)
);

I first put the mailing template in $fd (only once) and then replace
(str_replace) elements of it to individualize HTML emails.
Btw i’m using php version 4.0.6. 

Are there better(faster) ways to read the contents of a file?

Thanks!
Fré

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



Re: [PHP] Implode slows down file reading? [was: str_replace performance in large mailing script]

2003-08-27 Thread CPT John W. Holmes
From: frederik feys [EMAIL PROTECTED]

 I thought str_replace caused slow down of my mailing script, but it
 seems to be this line of code:

 $fd =
 implode(,file(http://www.domain.org/store/min/Mailing_template.html;)
 );

 I first put the mailing template in $fd (only once) and then replace
 (str_replace) elements of it to individualize HTML emails.
 Btw i'm using php version 4.0.6.

 Are there better(faster) ways to read the contents of a file?

file_get_contents() ?

The slow down is probably because you're going through HTTP to read the
file. Is there a reason for that? Any way you can cache the file locally so
it's not read through HTTP all of the time?

---John Holmes...

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



Re: [PHP] implode()

2002-11-26 Thread Jef
 implode() expects an array as the second argument. You're passing a
string. In
 fact with the code you have above I don't see why you don't just tack the
 comma on the end in the first place:

if($image11_name != '') $sqlUpdate .= image11='$image11_name', ;

The reason being the comma at the end of the SQL command will prevent the
command from working because SQL will expect another entry. However, your
comment about implode expecting an array helps out. Thanks.




Jef



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




Re: [PHP] implode()

2002-11-26 Thread Jason Wong
On Wednesday 27 November 2002 02:19, Jef wrote:
  implode() expects an array as the second argument. You're passing a

 string. In

  fact with the code you have above I don't see why you don't just tack the
  comma on the end in the first place:
 
 if($image11_name != '') $sqlUpdate .= image11='$image11_name', ;

 The reason being the comma at the end of the SQL command will prevent the
 command from working because SQL will expect another entry. However, your
 comment about implode expecting an array helps out. Thanks.

Yes, but as you're building up the SQL statement manually you just leave out 
the comma off the last line!

Using implode() is appropriate if you're programatically (sp?) building an SQL 
statement using an array.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
What I need is a MATURE RELATIONSHIP with a FLOPPY DISK ...
*/


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




Re: [PHP] implode()

2002-11-26 Thread Jef
   implode() expects an array as the second argument. You're passing a
   string. In fact with the code you have above I don't see why you don't
just tack
   the comma on the end in the first place:
  
  if($image11_name != '') $sqlUpdate .= image11='$image11_name', ;
 
  The reason being the comma at the end of the SQL command will prevent
the
  command from working because SQL will expect another entry. However,
your
  comment about implode expecting an array helps out. Thanks.

 Yes, but as you're building up the SQL statement manually you just leave
out
 the comma off the last line!

 Using implode() is appropriate if you're programatically (sp?) building an
SQL
 statement using an array.

The problem is I don't know which will be the last element in the string. I
am allowing 9 images to be changed, 9 text labels to be changed, and 9 links
to be changed. I don't know which will be the last. I'm using an update sql
command to change the database when these changes are being made.

When I set the $sqlUpdate to be an array the printed result is ARRAY. When I
print the sql command it reads UPDATE mp SET ARRAY. What am I doing wrong?




Jef



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




Re: [PHP] implode()

2002-11-26 Thread Jason Wong
On Wednesday 27 November 2002 02:57, Jef wrote:

 The problem is I don't know which will be the last element in the string. I
 am allowing 9 images to be changed, 9 text labels to be changed, and 9
 links to be changed. I don't know which will be the last. I'm using an
 update sql command to change the database when these changes are being
 made.

Re-reading your original post I see what you mean.

 When I set the $sqlUpdate to be an array the printed result is ARRAY. When
 I print the sql command it reads UPDATE mp SET ARRAY. 

I think you mean Array. Because $sqlUpdate is an array you can't simply 
print it out (you'll just get 'Array' printed). 

 What am I doing
 wrong?

You didn't use implode(), which after all is the subject of this thread ;-)

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
How many surrealists does it take to screw in a lightbulb?

One to hold the giraffe and one to fill the bathtub with brightly colored
power tools.
*/


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




Re: [PHP] implode()

2002-11-26 Thread Joakim Andersson
Jef wrote:

implode() expects an array as the second argument. You're passing a


string. In


fact with the code you have above I don't see why you don't just tack the
comma on the end in the first place:

  if($image11_name != '') $sqlUpdate .= image11='$image11_name', ;



The reason being the comma at the end of the SQL command will prevent the
command from working because SQL will expect another entry. However, your
comment about implode expecting an array helps out. Thanks.



This is how I would do it:
?php
$separator = ;
if($image11_name != '') {
	$sqlUpdate .= $separator . image11='$image11_name';
	$separator = , ;
}
if($image12_name != '') {
	$sqlUpdate .= $separator . image12='$image12_name';
	$separator = , ;
}
if($textfield11 != '') {
	$sqlUpdate .= $separator . textfield11='$textfield11';
	$separator = , ;
}
if($textfield12 != '') {
	$sqlUpdate .= $separator . textfield12='$textfield12';
	$separator = , ;
}
if($textlink11 != '') {
	$sqlUpdate .= $separator . textlink11='$textlink11';
	$separator = , ;
}
if($textlink12 != '') {
	$sqlUpdate .= $separator . textlink12='$textlink12';
	$separator = , ;
}

if($sqlUpdate != ) {
	$query = UPDATE my_table SET  . $sqlUpdate;
	// Execute query
} else {
	// Nothing to update...
}
?

Regards
Joakim


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




[PHP] implode()?

2002-11-25 Thread Jami
I need help once more. I have a variable that is a string with spaces. What I need to 
do is put a + sign in the spaces so that the string will print like 
This+is+a+string. I have tried using implode, but I get this error:

Warning: Bad arguments to implode()

The code I am using is as follows:

$prod = implode(+, $_POST['product']);

Is this the correct thing to use, or is there another way to change the string?

Thanks.

Jami



Re: [PHP] implode()?

2002-11-25 Thread Rasmus Lerdorf
str_replace

On Mon, 25 Nov 2002, Jami wrote:

 I need help once more. I have a variable that is a string with spaces. What I need 
to do is put a + sign in the spaces so that the string will print like 
This+is+a+string. I have tried using implode, but I get this error:

 Warning: Bad arguments to implode()

 The code I am using is as follows:

 $prod = implode(+, $_POST['product']);

 Is this the correct thing to use, or is there another way to change the string?

 Thanks.

 Jami



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




Re: [PHP] implode()?

2002-11-25 Thread Jami
Ok, figures I would be looking for something else and find the solution.
urlencode(). Thanks for the reply Rasmus.  :-)

Jami


- Original Message -
From: Jami [EMAIL PROTECTED]
To: PHP General [EMAIL PROTECTED]
Sent: Monday, November 25, 2002 11:26 PM
Subject: [PHP] implode()?


I need help once more. I have a variable that is a string with spaces. What
I need to do is put a + sign in the spaces so that the string will print
like This+is+a+string. I have tried using implode, but I get this error:

Warning: Bad arguments to implode()

The code I am using is as follows:

$prod = implode(+, $_POST['product']);

Is this the correct thing to use, or is there another way to change the
string?

Thanks.

Jami




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




Re: [PHP] implode()

2002-11-25 Thread Jason Wong
On Tuesday 26 November 2002 14:51, Jef wrote:
 I am having difficulty with the implode function. What I am doing is
 building a string for an UPDATE SQL command. At the end of the building
 portion of the code, I want to insert a comma between the various fields
 that will be updated. However, it is not working. Here is a portion of my
 code...thanks, in advance for any assistance received

   $sqlUpdate = SET ;
   if($image11_name != '') $sqlUpdate .= image11='$image11_name';
   if($image12_name != '') $sqlUpdate .= image12='$image12_name';
   if($textfield11 != '') $sqlUpdate .= textfield11='$textfield11';
   if($textfield12 != '') $sqlUpdate .= textfield12='$textfield12';
   if($textlink11 != '') $sqlUpdate .= textlink11='$textlink11';
   if($textlink12 != '') $sqlUpdate .= textlink12='$textlink12';

   $update = implode(,, $sqlUpdate);
   $sql = UPDATE mp  .$sqlUpdate;

 I get a bad parameter message on the line with the call to the Implode
 function.

implode() expects an array as the second argument. You're passing a string. In 
fact with the code you have above I don't see why you don't just tack the 
comma on the end in the first place:

   if($image11_name != '') $sqlUpdate .= image11='$image11_name', ;


-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
Better tried by twelve than carried by six.
-- Jeff Cooper
*/


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




[PHP] implode()

2002-11-25 Thread Jef
I am having difficulty with the implode function. What I am doing is
building a string for an UPDATE SQL command. At the end of the building
portion of the code, I want to insert a comma between the various fields
that will be updated. However, it is not working. Here is a portion of my
code...thanks, in advance for any assistance received

  $sqlUpdate = SET ;
  if($image11_name != '') $sqlUpdate .= image11='$image11_name';
  if($image12_name != '') $sqlUpdate .= image12='$image12_name';
  if($textfield11 != '') $sqlUpdate .= textfield11='$textfield11';
  if($textfield12 != '') $sqlUpdate .= textfield12='$textfield12';
  if($textlink11 != '') $sqlUpdate .= textlink11='$textlink11';
  if($textlink12 != '') $sqlUpdate .= textlink12='$textlink12';

  $update = implode(,, $sqlUpdate);
  $sql = UPDATE mp  .$sqlUpdate;

I get a bad parameter message on the line with the call to the Implode
function.



Questions? Comments? Suggestions?



Jef



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




Re: [PHP] Implode?

2001-02-27 Thread Richard Lynch

 What is the best way to pull data from one table and insert into another?

insert into newmembers(name, email, whatever) select name, email, whatever
from oldmembers

 How can I delete entries from a table with a php document?

The same way you select entries.

mysql_query() can send *ANY* query to your database.

 The gist of what I'm trying to accomplish is this.  This is somewhat of a
 detailed outline, so please bear with me.

 1. I have one table (members) that has all the old data.
 2. I'm am going to send an e-mail to every entry in that table that has an
 e-mail address and have a link for them to follow to a PHP page.  Any
entry
 that does not have an e-mail address, will be moved over with a different
 (but similar) PHP script that will do a mass search and move of that data
to
 the new table (memberdetail)

Wouldn't it be easier to present different info to members based on their
email or lack thereof, and similarly based on their password or lack
thereof, than to mess around with shuffling all the data from table to
table?...

--
Visit the Zend Store at http://www.zend.com/store/
Wanna help me out?  Like Music?  Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Implode?

2001-02-25 Thread Kenneth R Zink II

What is the best way to pull data from one table and insert into another?
How can I delete entries from a table with a php document?

The gist of what I'm trying to accomplish is this.  This is somewhat of a
detailed outline, so please bear with me.

1. I have one table (members) that has all the old data.
2. I'm am going to send an e-mail to every entry in that table that has an
e-mail address and have a link for them to follow to a PHP page.  Any entry
that does not have an e-mail address, will be moved over with a different
(but similar) PHP script that will do a mass search and move of that data to
the new table (memberdetail)
3. That PHP page will ask for there name and e-mail address then display a
list of matching results to edit.
4. The edit page will pull data from (members) and insert then updated info
into a new table (memberdetail).  Password protected.  Unless you know the
password for that information, it will error and stop (exit () ).
5. If the insertion is successful, I want it to open a new window (if
statement that contains target="_blank") which will display the new data and
then the old page will refresh itself to a new page (if statement with a
meta tag).  If not, I want it to error and stop. (exit() ).  I have already
implemented anti-duplication into our new insert script (for memberdetail).
The new table (memberdetail) gets scanned for duplicate information in 5
fields (but can easily but expanded to cover more then that) before it
inserts data.  If it finds duplicate information it displays it with an
option to accept it. (password protected).  If accepted (with proper
password) it will delete the old information (from members) and refresh the
page while opening the new information in a new window.
6. The refreshed page will be passed an variable (id) from the old table
(members) and delete the entry (from members).
7. Lastly, it will refresh and pass the name and e-mail address from step 3
and display any remaining matches if any.
8. If there were any results from the search in step 7, then it will do step
4 again.  If no remaining entries it will error and stop. (exit () )

Doing it this way will help us clean up our old information and get more
current information for our new website.  Anything that is not moved over
will be erased after a couple of months.  That should give them plenty of
time to update and move the old data to the new site.

Thanks.

Kenneth R Zink II [EMAIL PROTECTED]ICQ# 5095094
'87 GMC S-15 Ext. Cab (Hurricane) ...BBC 524 being built !!!
http://www.s-series.org/htm/windstorm/project-windstorm.htm
'85 Chevy S-10 Blazer (FireStorm) ...Soon to be 3.4L SFI !!!
http://www.s-series.org/htm/firestorm/firestorm.htm
'84 Oldsmobile Delta 88 Delta 88 Royal Brougham.
Racing by the grace of God!!!


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]