homepage Welcome to WebmasterWorld Guest from 184.73.52.98
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Insert a value from an array into MySQL
php, array, MySQL, select, insert
brandozz




msg:4468930
 3:50 pm on Jun 24, 2012 (gmt 0)

Hi all,

Wondering if anybody can help me out with something. I'm pulling a value from a table using the following query:


$q = "select MAX(id) from rma";
$result = mysql_query($q);
$data = mysql_fetch_array($result);
echo $data[0];


I have this query working, it pulls that largest id number from the table called rma. Now I want to take the value stored in $data and insert it into a different table. Any thoughts on how this can be accomplished?

Simply inserting the variable $data into my insert statement doesn't work.

 

brandozz




msg:4468946
 4:41 pm on Jun 24, 2012 (gmt 0)

I was able to get this fixed. I forgot to add the [0] to the insert query:


$sql = "INSERT INTO table SET ref_id='$data[0]';

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved