Re: [PHP] PHP & MySQL -> Field Title

2007-05-02 Thread Richard Lynch


On Mon, April 30, 2007 12:47 am, Christian Haensel wrote:
> Good Morning guys and girls
>
> As I am rather lazy, I don't wanna do a data readout on my MySQL table
> in
> the following way with mysql_fetch_assoc()
>
> $data_item1=$data['xitem1'];
> $data_item2=$data['yitem2];
> 
>
> I am trying to do the following:
>
> I have the correct number of fields in the table, which is 116. Now I
> want
> to use a for-loop and read teh data into a string, then shove it into
> another table, which has the exact same layout. I was thinking about
> something like
>
> for($i=0; $i<= 115; $i++) {
> $data_item[$i]=$data[$i];
> }
>
> but now I have the problem with the field names and all... can someone
> point
> me into the right direction? All I have to so is move the contents of
> one
> field to the second database wich has the same layout as the first DB.
>
> Would be thankful for any help :o)

If it's MySQL you can bypass PHP altogether and get this done in about
1 second with something like:

SELECT INTO db2.whatever_table FROM db1.whatever_table;

This will essentially just copy the whole dang table.

Feel free to add field names in the syntax from:
http://dev.mysql.com
to change around the order of the fields or even combine/split fields
in simple MySQL functions.
Which you don't need for this task as you described, but somebody else
might.

Also feel free to add a WHERE clause to get only portions of the
table, which again you don't need, but somebody might.

So, really, using PHP for this is probably silly...

That said, you can use mysql_fetch_assoc and get the field names and
use array_keys and array_values to get the field names and values, if
you really really really need PHP to do something in between one db
and the next.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] PHP & MySQL -> Field Title

2007-04-30 Thread Christian Haensel

Hi Oliver,

below is what I used.

 ".$value."";
 $titel = $fieldname;
 $insert_q .= ",'$value'";
}
$insert_q = $insert_q.')';
$insert_q = eregi_replace("\(,","(", $insert_q);
echo "";
echo $insert_q;
mysql_query($insert_q) or die(mysql_error());
echo "Yup";
$del_q = "DELETE FROM vorlauf WHERE satz_nr = '$fzg_id' LIMIT 1";
$do_del = mysql_uery($del_q);
?>


I'm sure there are better ways to do the whole thing :o) But as long as I 
need to cpy one record at a time, I don't really care much for speed. I just 
put all the stuff into a string and then use that string as query for the 
insertion into the second database.


Scripts like that make me feel good when I say "You can be dumb as heck, ás 
long as you find a way to resolve your problems" :o) It works, and it took 
me just about 10 minutes of research and another 10 of writing :o)


Hope your weather is just as good as ours here...

All the best!

Chris

- Original Message - 
From: "Oliver Block" <[EMAIL PROTECTED]>

To: 
Cc: "Christian Haensel" <[EMAIL PROTECTED]>
Sent: Monday, April 30, 2007 1:11 PM
Subject: Re: [PHP] PHP & MySQL -> Field Title



Am Montag, 30. April 2007 07:47 schrieb Christian Haensel:

but now I have the problem with the field names and all... can someone
point me into the right direction?


<http://www.php.net/manual/de/ref.mysql.php>

php-db at lists.php.net

If you need to use an assoc array, use the following SQL Syntax:

INSERT INTO new_table SET key0=value0, key2=value2, ...,

Regards,

Oliver

--
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



Re: [PHP] PHP & MySQL -> Field Title

2007-04-30 Thread Oliver Block
Am Montag, 30. April 2007 07:47 schrieb Christian Haensel:
> but now I have the problem with the field names and all... can someone
> point me into the right direction?



php-db at lists.php.net

If you need to use an assoc array, use the following SQL Syntax:

INSERT INTO new_table SET key0=value0, key2=value2, ..., 

Regards,

Oliver

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



Re: [PHP] PHP & MySQL -> Field Title

2007-04-30 Thread Auto-Deppe, C. Haensel

nevermind, I made it :o) RTFM sometimes works even for me :O))

Have a great day :o)

Chris

- Original Message - 
From: "Christian Haensel" <[EMAIL PROTECTED]>

To: 
Sent: Monday, April 30, 2007 7:47 AM
Subject: [PHP] PHP & MySQL -> Field Title



Good Morning guys and girls

As I am rather lazy, I don't wanna do a data readout on my MySQL table in 
the following way with mysql_fetch_assoc()


$data_item1=$data['xitem1'];
$data_item2=$data['yitem2];


I am trying to do the following:

I have the correct number of fields in the table, which is 116. Now I want 
to use a for-loop and read teh data into a string, then shove it into 
another table, which has the exact same layout. I was thinking about 
something like


for($i=0; $i<= 115; $i++) {
   $data_item[$i]=$data[$i];
}

but now I have the problem with the field names and all... can someone 
point me into the right direction? All I have to so is move the contents 
of one field to the second database wich has the same layout as the first 
DB.


Would be thankful for any help :o)

Cheers!

Chris
--
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



[PHP] PHP & MySQL -> Field Title

2007-04-29 Thread Christian Haensel

Good Morning guys and girls

As I am rather lazy, I don't wanna do a data readout on my MySQL table in 
the following way with mysql_fetch_assoc()


$data_item1=$data['xitem1'];
$data_item2=$data['yitem2];


I am trying to do the following:

I have the correct number of fields in the table, which is 116. Now I want 
to use a for-loop and read teh data into a string, then shove it into 
another table, which has the exact same layout. I was thinking about 
something like


for($i=0; $i<= 115; $i++) {
   $data_item[$i]=$data[$i];
}

but now I have the problem with the field names and all... can someone point 
me into the right direction? All I have to so is move the contents of one 
field to the second database wich has the same layout as the first DB.


Would be thankful for any help :o)

Cheers!

Chris 


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