I have my site linked to another sites database, I have a form which has fields to submit a query to the external database. The query will be similar to
SELECT src, timestamp FROM files WHERE uploader_id = 1
The query will retrun an array similar to
Array (
[0] => Array ( [src] => http://externaldatabase/0.jpg [created] => 1111111111 )
[1] => Array ( [src] => http://externaldatabase/1.jpg [created] => 1111111111 )
[2] => Array ( [src] => http://externaldatabase/2.jpg [created] => 1111111111 )
[3] => Array ( [src] => http://externaldatabase/3.jpg [created] => 1111111111 )
)
Etc for all files retreived.
I have a database on my site where im trying to write these values to with other values retrieved from the form.
So the table columns would be
fid uid uri timestamp
the uri would be the src, the timestamp is created. the fid auto increments by 1, and the uid would be the id of the user that submitted the form.
How do I add my own variables such as the user who submitted the form to the original array returned from the query so I can populate the table.
Thanks for any help
Here's some pseudo-code:
if $_POST
if isset($_POST['uploader_id'])
$image = [SELECT src, timestamp FROM files WHERE uploader_id = 1]
foreach $images as $uri
insert into myDatabaseTable (uid, uri, timestamp) values ($_POST['uid'], $uri, date('YYYY-mm-dd H:i:s')
endforeach
else
// however you want to handle form validation
endif
endif