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

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 August 20th, 2002, 04:18 AM
lindacomel lindacomel is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 7 lindacomel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
how to insert multiple data?

i have another question here..

in many programs, we can just insert data to database.. but what if i got a lot of data, (in my program, i can add or delete criteria) and would like to use all of them to do some mathematical counts and generate graph?..


please help me.. this is really important to my final project.. tq..

Reply With Quote
  #2  
Old August 20th, 2002, 11:07 AM
rathaur rathaur is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: Malaysia
Posts: 81 rathaur User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 m 31 sec
Reputation Power: 7
dear cute linda

one suggestion is to use arrays.
__________________
Rathaur
======================
Knowledge is Power

Reply With Quote
  #3  
Old August 21st, 2002, 12:37 AM
lindacomel lindacomel is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 7 lindacomel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
still blur..

can i mel u rathaur? what's ur mel?

Reply With Quote
  #4  
Old August 21st, 2002, 01:12 AM
lindacomel lindacomel is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 7 lindacomel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
really stuck..

let's say this is example of my interface..

criteria weightage Alternative A |scale A |Alternative B |Scale C
1. Price 0.6 $100 8 $250 7
2. Colour 0.3 Green 4 Blue 6
3. Age 0.1 3 years 5 7 years 8

and now, i would like to know, how i can put the data (criteria, value of
weightage, value of Alternative A, value of scale A,value of Alternative
B, value of scale B in database so that i can use all of them to count and
generate graph especially the weightage and scale?

Last edited by lindacomel : August 21st, 2002 at 01:16 AM.

Reply With Quote
  #5  
Old August 21st, 2002, 01:19 AM
rathaur rathaur is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: Malaysia
Posts: 81 rathaur User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 m 31 sec
Reputation Power: 7
hmm, well, it depends on how you has create your database . Your database should have fields and colomns appropriately to hold all the values. Later in presenting in graph, read from database, present in any chart.

err err, am I rite ?

Reply With Quote
  #6  
Old August 21st, 2002, 01:29 AM
lindacomel lindacomel is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 7 lindacomel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
probs..

the problem is how to hold all the values?

Last edited by lindacomel : August 21st, 2002 at 07:55 AM.

Reply With Quote
  #7  
Old August 21st, 2002, 11:55 AM
rathaur rathaur is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: Malaysia
Posts: 81 rathaur User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 m 31 sec
Reputation Power: 7
Hi cute linda,

First I hope I am answering correctly for you. This simple script shows a multiple entry form for 6 items. I am using array to hold each items properties. All your values are now assigned to arrays. Upon sumbitting, the values are preserved as they are entered. This will enable you to use another for loop , to insert the values into database. Hope this helps.

<?
// this part prints the form
if (!$submit)
{
$numentry=10;
echo"<table width=650 cellpadding=2 cellspacing=5>";
echo"<tr width='650'>";
echo"<td>num</td><td>entry1</td><td>entry2</td> <td>entry3</td><td>entry4</td>";
echo"<td>entry5</td><td>entry6</td></tr>";
echo"<form action=$PHP_SELF method=post>";
for($j=1;$j<=$numentry;$j++)
{
//$fac ="fac_".$j;
echo "<tr width='650'><td>$j.</td>";
echo "<td><input type='text' name=val[$j] ></td>";
echo "<td><input type='text' name=val2[$j] > </td>";
echo "<td><input type='text' name=val3[$j]> </td>";
echo "<td><input type='text' name=val4[$j] > </td>";
echo "<td><input type='text' name=val5[$j] > </td>";
echo "<td><input type='text' name=val6[$j] > </td></tr>";
}
echo "<tr width=650 ><td align='center'> <input type='submit' value='Add' name='submit'> ||";
echo " <input type='reset' value='Clear' name='reset'></td></tr></table></form>";
}

if($submit)
{
//connect to db
//error checking
//here goes your insert queries
for($j=1;$j<=num$entry;$j++)
{
$sql='insert into $table values("$val[$j]",.....$val[$j])/';
//run your query
}


}

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > how to insert multiple data?


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 3 hosted by Hostway