Jump to content

[SOLVED] Array inserting help


EchoFool

Recommended Posts

Hey,

 

I need help with an array that i want to insert into a table..

 

The table has 6 fields just named "one" "two" "three" "four" "five" "six".

 

Now with my array i have sorted the numbers in order and now i want to insert it into the database in that order so "one" will have lowest and "six" will have the highest.

 

But i do not know how to do it.. and it should be one row so a while loop for the array won't work because it'll insert 6 rows.

 

This is what i have:

 

<?php

//create array  etc
// get numbers from form etc 
// put then numbers into the array etc
// -------------------
//below is the array sorting
	sort($numbers);
	$check = false;
	$skip = false;
	foreach ($numbers as $next) {
	if ($next == trim($check)) {
	$skip = 1;
		}
	$check = $next;
	}
If($skip){
?>
Duplicate number inserted!
<?php
}
?>

 

Any suggestions on how i can achieve what im trying to do ? I've hit a brick wall on this one.

Link to comment
Share on other sites

Ok thank you, I tried it though having problems with my ' and " not sure where i should and should not use them, this is what i got:

 

<?php
$INSERT = myslq_query('INSERT INTO tabl_nums (UserID,Number1,Number2,Number3,Number4,Number5,Number6,BoughtOn) 
VALUES ('{$_SESSION['Current_User']'," . implode(',',$numbers) . ",'$On')')
Or die(mysql_error());
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.