|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I have following fields plus primary key ID field in my database
Symbol Price Date Time Change Open High Low Volume I have following data stored in $data Array ( [0] => Array ( [0] => RHAT [1] => 7.34 [2] => 7/16/2003 [3] => 3:59pm [4] => -0.35 [5] => 7.73 [6] => 7.80 [7] => 7.24 [8] => 1610487 ) [1] => Array ( [0] => MSFT [1] => 27.52 [2] => 7/16/2003 [3] => 4:00pm [4] => +0.25 [5] => 27.56 [6] => 27.62 [7] => 27.20 [8] => 50506828 ) [2] => Array ( [0] => INTC [1] => 25.31 [2] => 7/16/2003 [3] => 4:00pm [4] => +1.21 [5] => 25.24 [6] => 25.50 [7] => 24.82 [8] => 129156912 ) ) What is standard PHP method to insert these three records into my database? Thanks Cas |
|
#2
|
||||
|
||||
|
If the data is always going to be accurate then you could do something like this:
PHP Code:
HTH
__________________
--------------------- -- SilkySmooth -- --------------------- Proxy | Little Directory |
|
#3
|
|||
|
|||
|
I have a problem that I hope someone can help me with..
My code is like this (index.php file obtained from psychostats, running on a PHP-Nuke site, with Apache server, mysql) <?php if (!isset($mainfile)) { include("mainfile.php"); } $index = 1; include("header.php"); include("functions.php"); OpenTable(); // Make sure a valid sort was given if (!preg_match('/^(name|totalkills|totaldeaths|kpm|kdr|skill)$/i',$sort)) $sort = 'skill'; $sort = strtolower($sort); // Total names to list on a single page. Change this to whatever you want. if (!preg_match('/^\d+$/', $limit)) $limit = 100; // Nothing else below this line needs to be changed unless you want to customize the layout // ---------------------------------------------------------------------------------------- if (!preg_match('/^\d+$/', $start)) $start = 0; $cell1 = 'plrrow1'; $cell2 = 'plrrow2'; $cell = ''; // Set the variables for the database access: $host = "localhost"; $user = "user"; $password = "pass"; $dbname = "nuke"; $Link = mysql_connect ($host, $user, $password); global $prefix; $playerlist = array(); $playerlist[] = array( "plrname" => stripslashes("\[TEST\]test"), "plrhtml" => stripslashes("player_W01LQkldU2Fkbw\.php"), "plrrank" => "4", "plrskill" => "1345", "plrtotalkills" => "433", "plrtotaldeaths" => "293", "plrkdr" => "1.48", "plrkpm" => "0.69", "plrwonids" => "", "plraliases" => stripslashes("\[TEST\]test"), "plricon" => stripslashes("player\.gif"), "plrclanicon" => stripslashes("\<a\ href\=\'clanpage__test_\.php\'\>\<img\ src\=\'clan\.gif\'\ width\=\"18\"\ height\=\"14\"\ border\=\"0\"\ alt\=\"\[TEST\]\"\>\<\/a\>"), ); // [TEST]test $Query = "INSERT INTO ".$prefix."_psychostats (rankid, pname, kills, deaths, kd, kpm, skill) VALUES (".$playerlist['plrrank'].",".$playerlist['plrname'].",".$playerlist['plrtotalkills'].",".$playerlist['plrtotaldeaths'].",".$playerlist['plrkdr'].",".$playerlist['plrkpm'].",".$playerlist['plrskill'].)"; print ("$playerlist[plrrank]"); print ("The query is:<BR>$Query<p>\n"); if (mysql_db_query ($dbname, $Query, $Link)) { print ("Your information has been updated =;0)<BR>\n"); } else { print ("Your information has not been updated<BR>\n"); } mysql_close ($Link); ?> RESULT: The $Query is showed in print, but no values just ('','',''.....) Maybe its not possible to do it like this, anyway if u have some suggestion they are greatly appriciated.. Plz help, Thanks, Ante |
![]() |
| Viewing: Dev Shed Forums > Other > Beginner Programming > Inserting array data into MySQL database |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|