Board index   FAQ   Search  
Register  Login
Board index PHP PHP Scripts

Php script question

Links for php scripts

Moderators: macek, egami, gesf

Php script question

Postby sudan4ever » Fri Mar 23, 2012 8:20 pm

I have a php script that uploads multiple images and assign it a value image 1 image 2 on the form drop down menu

so I have an upload for an image and a drop down that assign image1 to that upload

my php script will insert the image to a database I wanted a script that basically inserts to different table on that database based on the image value

so if I have table1 table 2 table 3 ........

I want if image 1 selected from the drop down menu during the upload to be inserted to table 1 and so on

any help will be appreciated
sudan4ever
New php-forum User
New php-forum User
 
Posts: 1
Joined: Fri Mar 23, 2012 8:16 pm

Re: Php script question

Postby freshnet » Sat Mar 24, 2012 3:33 am

Maybe start by posting the code you have for assigning 'image1' to these images for a start, but it's definitely possible. If you have a variable you could just use all or part of that variable as the table name, e.g.

Code: Select all
INSERT INTO '$varforimage1'...


or
//look at the last character of the image variable
Code: Select all
$table = 'Table'.substr($image,-1,1);


or
//look at the last character of the image variable
Code: Select all
if (substr($image,-1,1)==1)
{}
else if (substr($image,-1,1)==2)
{}
etc.


That last one is your best option if the correspondence between $image and $table is not regular (e.g. if you have $image3 -> $table5, $image4 -> $table7 etc.)
User avatar
freshnet
php-forum Active User
php-forum Active User
 
Posts: 252
Joined: Tue Feb 22, 2011 8:19 am
Location: Canada


Return to PHP Scripts

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.