TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 10-01-2008, 03:24 PM   #1 (permalink)
The Wanderer
 
Acrylic's Avatar
 
Join Date: Sep 2007
Location: Rochester, NY
Posts: 6
Thanks: 1
Acrylic is on a distinguished road
Default PHP & MySQL Inserting multiple entires from range.

First off let me explain whats going on, I have a site that people use to share and manage picture url's. The biggest complaint I get is that they can only add one picture url at a time and they would like to start doing them in large batches of like 200. I want to use a method where if they submit a URL with a pattern something like:

http://www.userwebsite.com/pictures/Cleveland[1-100].jpg

It will automatically add the 100 different URL's into the MySQL database. How would I do this? I have been looking around but its driving me crazy! Thanks!!!
Acrylic is offline  
Reply With Quote
Old 10-01-2008, 11:26 PM   #2 (permalink)
The Contributor
 
jcorradino's Avatar
 
Join Date: Sep 2008
Posts: 36
Thanks: 2
jcorradino is on a distinguished road
Default

I would think it would be easier to do it this way

the links would be something like:

(URL)Cleveland#.jpg

and you would have a separate field that tells the range (100 in this case)

your php would look like this:

PHP Code:
$srcImage cleanData($_POST['link']);//always clean user data
$range cleanData($_POST['range']);
$link = @mysql_connect ('server','user','pass')

for (
$i=1;$i<=$range;$i++) {
  
$image str_replace('#',$i,$srcImage);
  
$sql 'INSERT INTO `yourdb`.`table` VALUES (null, "$image");';
  @
mysql_query($sql,$link); //assuming you already made a connection
}
@
mysql_close($link); 
This should do what you were looking for, hope this helps.

Edit: How the hell did you get it to display the link, I keep getting Userwebsite.com - personal website Resources and Information. This website is for sale![1-100].jpg <-that
__________________
Jason Corradino
Applications Developer, Interactive Support - Tribune Technology
J2EE Development, Script Tinkering - Develop, Support, and Maintain Tribune websites.
jcorradino is offline  
Reply With Quote
The Following User Says Thank You to jcorradino For This Useful Post:
Acrylic (10-02-2008)
Old 10-02-2008, 02:05 AM   #3 (permalink)
The Wanderer
 
Acrylic's Avatar
 
Join Date: Sep 2007
Location: Rochester, NY
Posts: 6
Thanks: 1
Acrylic is on a distinguished road
Default

Quote:
Originally Posted by jcorradino View Post
Edit: How the hell did you get it to display the link, I keep getting Userwebsite.com - personal website Resources and Information. This website is for sale![1-100].jpg <-that
Awesome thanks, I knew it would be something easy!

Also, if you uncheck the "Automatically parse links in text" in the Additional Options area it wont parse the links :D
Acrylic is offline  
Reply With Quote
The Following User Says Thank You to Acrylic For This Useful Post:
jcorradino (10-02-2008)
Old 10-02-2008, 02:27 AM   #4 (permalink)
The Contributor
 
jcorradino's Avatar
 
Join Date: Sep 2008
Posts: 36
Thanks: 2
jcorradino is on a distinguished road
Default

thanks, that can be helpful in the future, I did not even notice the additional options box, lol
__________________
Jason Corradino
Applications Developer, Interactive Support - Tribune Technology
J2EE Development, Script Tinkering - Develop, Support, and Maintain Tribune websites.
jcorradino is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 05:27 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design