General SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesGeneral SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old March 30th, 2004, 09:18 AM
gat gat is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 24 gat User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Imploded resultts?

Ok i have this SQL that inserts two vars into an art_cat table..

PHP Code:
$sql2 = mysql_query("INSERT INTO art_cat (sub_cat_id, art_id) VALUES ('$var', '$art_id')");

However, the var '$var' holds the imploded data, e.g

1_2_3_4_5

so when the data is entered into the DB, i get the following


art_id sub_cat_id

69 1_2_3_4
_____________________

I would like the infor to be added like this though

art_id sub_cat_id

69 1
69 2
69 3
69 4
______________________

could someone show me how i would need to alter my SQL for this to work.

would i need a 'for each' loop according to the $var variable, then for each number, insert the art_id and number.

this would make all my other code work correctly.
thanks.

Reply With Quote
  #2  
Old April 21st, 2004, 01:14 PM
Unquick1 Unquick1 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 5 Unquick1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Check the explode funciton:

http://ca2.php.net/explode

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesGeneral SQL Development > Imploded resultts?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway