Array Inserting
Looking for a push in the right direction here. If i have an array like such:
$array[0] = olddata
$array[1] = olddata
$array[2] = olddata
$array[3] = olddata
$array[4] = olddata
$array[5] = olddata
$array[6] = olddata
and want to insert data in between on lines 1,2,3,4,5 without overwriting the data so my array looks like such:
$array[0] = olddata
$array[1] = newdata
$array[2] = newdata
$array[3] = newdata
$array[4] = newdata
$array[5] = newdata
$array[6] = olddata(used to be $array[1])
$array[6] = olddata(used to be $array[2])
$array[6] = olddata(used to be $array[3])
$array[6] = olddata(used to be $array[4])
$array[6] = olddata(used to be $array[5])
How would i go about it..? I'm basically pushing the other data down. The amount i will want to insert will be different every time and the lines i will want to insert the data into will be different every time. However on the upside the new data will always be straight after each other (ie insert new data on lines 2,3,4,5 and push old data down to 6,7,8,9 not insert on lines 2,4,9,6 ect..) So obviously i need some loopishly.. but just not sure where to start.. any suggestions..?
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Inserting Using An Array?
I'm building a site for statistical data for a five aside football team. So my team has five players - goalkeeper - player_two - player_three - player_four - player_five and each match we play in is given a distinct match_id. For each player I want to record the following data: position (ie goalkeeper, player_two) name goals So when I come to submitting my data I want my table to eventually look like this after submit is hit on my form: Now i've started building the design for the addition of this data, but got stuck. I have two questions 1) How can I specify the position of each player that is posted and get that data in the database? 2) When I hit submit 5 rows are saved, but with no data in them? Code:
Inserting An Array
I'm trying to generate a random list within my HTML. I've done random lists before, but this is giving me problems. In the code below, $file should be printing the array I have stored in $file. $file contains raw HTML, comprised of about 10 items right now, but will be higher as I add to it. (That is why I did the $arraycount). I did a var_dump($file) and I can see that $file does indeed contain what I want it to, but I just cannot get the contents into my page. Code:
Inserting Into Array
anybody know an efficient way of appending to an array? $array[]='test'; $array[]='test'; $array[]='test'; $array[]='test6'; $array[]='test'; say... i want to move test6 to the #2 position... and increase the other keys under it... by 1...? i know i could make a function to do this... just didnt know if php had a built in function like that :-)
Inserting At Start Of Array
I am trying to insert an item at the start of an already populated array but I cannot seem to find a way of doing it. Here is an example of what I am trying to do:
Inserting Array To Database
inserting array from form into database. But it give an 'no such index in string error'. I tried $bands[]=HTTP_POST_VARS[band]; and all it does is insert the last value of the array Code:
Inserting An Elemnt Into An Array
Ok, say I have an array, like $array[0] = "89 Chars"; $array[1] = "82 Chars"; But I want to insert and element between those two elements, so that it would be $array[0] = "89 Chars"; $array[1] = "New Element"; $array[2] = "82 Chars"; I have looked through the php manual, and can't find a function to specifically do this, is there any, or do I kind of have to rig it?
Inserting A Value Into The Middle Of An Array: Is This The Best Way?
I'm trying to insert a value into the middle of a simple (numerically-ordered) array, and bump all the later array keys up one. AFAIK, there isn't a function to do this already, so this is the code I came up with... is this the best way of doing it? <?php function array_insert($array, $value, $position) { if (is_array($array)) { $array_out = $array; // so I don't mangle it during foreach foreach ($array as $key => $val) { if ($key < $val) { $array_out[$key] = $val; } else { $array_out[$key+1] = $val; } } $array_out[$position] = $value; return $array_out; } return false; } ?>
Inserting An Array Into Database
If I have the following problem. $adults=$_POST['adults'];//lets say its 2 $children=$_POST['children'];//lets say its 3 $rooms =array('101','102'); foreach($rooms as $roomnumber){ $insertSQL = "INSERT INTO bookings (roomNumber, adults, children) VALUES ( '$roomnumber', '$adults', '$children')"; $Result1 = mysql_query($insertSQL) or die(mysql_error()); } This works BUT..each room gets (say) 2 adults and 3 children whereas I want the numbers spread over each room so that room 101 gets maybe 2 people and room 102 gets 3 people or vice versa and not double -up on the number of overall people. In a real life situation the user would choose the number of rooms and adults etc so the solution would need to allow for this. Can anyone see a way of doing this?
Inserting An Array Into A Database
I'm trying to insert an array into a database along with other information and finding it very difficult. I want to insert a row into the database for each container that I get from "insert page 1". I get the amount of containers needed (insert page 1) <input type="text" name="number_of_containers" size="2"> I use a for loop to make the necessary amount of form fields for two variables and then have two static ones. What I want to do is enter in one row per container. Code:
Inserting Array Into Mysql Table
Anyone know the best way to insert an array from a form into a mysql table. My array is validated from the form and then inserted into the db, only when I SELECT it, it merely saya 'array' in the field.
Inserting Data From A Sql Database Into An Array
I am currently working on a project where I need to put information from a sql statement into an array. Currently I can get one row into the array, but the rest aren't showing. I have checked, and all of the information is getting to the array, but I can only get one row to show up. Here's the code: while(($row = mysql_fetch_array($result))) { $info=array($count=>array('line1'=>$row["first_name"], 'line2'=>$row["last_name"], 'line3'=>$row["product"], 'line4'=>"$".$row["date"])); $count++; } I'm trying to get this array to hold multiple rows from the sql statement, but when I display the array, I can only get one row out of it.
Inserting Arrays Into A Holder Array From A Form
Need to put arrays of info into a holder array. for the moment i am creating the arrays from form info like so... <input type="text" size="30" name="link1[title]"> <input type="text" name="link1[link]" size="30"> <input type="text" name="link1[description]" size="30"> and i thought if i did.. <input type="text" size="30" name="alllinks[link1[title]]"> <input type="text" name="alllinks[link1[link]]" size="30"> <input type="text" name="alllinks[link1[description]]" size="30"> it might work, but no, how do i add the array 'link1' into the holder array 'alllinks'.
Inserting A Complete Array In A Database Field
I have a very big signup form and it is almost impossible to create a full table for it because of very high number of form fields and I dont want to create a field for each of them in my database's table. but I managed to store all the form values in an array, is there a way to fully insert an array to just one field? and for future use select it again as an array?
Inserting A Row
I have a bit of code that takes data out of the database and in a while loop it will desplay it all in rows, I want to know how I can make it so after just so many rows there is a little bit of HTML that is inserted between the rows, Like less say I have 20 rows that is beeing pulled form the database, I want a bit of HTML printed out every 5 rows.
Inserting Data Into A Row
I’ve got a table of three fields (id, name and comments) that contain 30 rows. Each row contains data in the two first fields (an id and a name). The third filed is empty. When a user accesses my page they can select one of 30 names from a drop down menu. After they’ve selected a name the user can write a comment about the person he/she selected. How can I insert the comment from the user into the comment field related to the name selected?
Inserting Into DB Problem
The values for the Insert are being check before they are concated into the $query string ive even tried echo the query and then run the query in the DB manually it worked. PHP Code:
Inserting Html Into Db
i have a table to hold large blocks of text, and naturally the text contains multiple paragraphs. so i want to store <p> tags to separate it out. i tried both addslashes() and htmlspecialchars(), then stripslashes() upon retrieval, but the result includes the tags as text. how do i fix this? NOTE: My db is Msql NOT mysql!
Inserting Records
I'm trying to insert as many as records as possible but less than 100 into a table. First, i get the count inorder how many to add and then depending on the count, i get so many blank form fields to enter. Now, I noticed something really strange. 1.Only the last entered record is inserted into the table. 2.For example, when I type a name, Let us assume "WORLD", only w is inserted into the table and the rest is not.It is the same with all the form fields.whether, i'm trying to enter text or a number,only the first character is inserted.This sounds weird. Could somebody pls tell me why is this peculiar behaviour Here is the code:
Inserting Data Twice
I'm working with a database now, and I have an error here, somewhere. The first time the user hits submit, the data goes in once, the second time the user hits submit, the data goes in twice. I don't know why. PHP Code:
Inserting Xml Nodes
i want to insert new node in an existing XML file using PHP everytime i add a new data into my MySQL table. XML file looks like this: Code: <profiles> <user add="addres2" id="2">username2</user> <user add="addres1" id="1">username1</user> <user add="addres3" id="3">username3</user> </profiles> i dont want to overwrite the existing XML file, i want to insert the new record... Code: <profiles> <user add="addres2" id="2">username2</user> <user add="addres1" id="1">username1</user> <user add="addres3" id="3">username3</user> <user add="newaddress" id="4">new username</user> </profiles> i really don't know where to start with this ..
Inserting DateTime
I am receiving an Internal Error Message when I try to insert datetime into a datetime field. My script looks like this: $EnrolledDate = date("Y-m-d"); $AllottedTime = 3.00; $AccumulatedTime = 0.00; $Email = "vtaylor157@aol.com"; $ItemNo = 154327; Code:
Inserting Into Two Table
I have two tables Table A = {ID, Item} Table B = {ID, IDA, subItem} Where ID auto increment. INSERT INTO TABLE_A ('items') values ('a') If I did an insert into Table A how can I find the ID of the item I just inserted? so I can do INSERT INTO TABLE_A ( IDA, 'items') values ( 'IDA', 'a')
Inserting A Link
I am having a problem inserting a hyperlink to a document into a php function. I have tried quite a few ways but can't seem to do it.
Inserting Into String
anybody know whats the best function to use in inserting more characters in the middle of a string? say i have a string - $str = "ASDVERDDASDV"; - and i want to insert "asdlkmc" someplace in the middle.
Inserting An Id From One Table To Another
I need to link my two table together. The first table(listings) has a row ID (primary and auto inc) my second table (images) has a row LISTING_ID. I cannot get the last id from the listings table to get inserted on to the images table. Code:
Inserting Into Tables
I have a form that gets filled out and the data is stored in a DB. I have a question regarding the insert part. Here is the structure of some of my tables: Code:
Inserting In To Two Tables
I'm creating the createteam.php file and want to create a record (the team) in the teams table and then create a record linking the team and the user who is creating the team (i.e. showing the user is in the team). Code:
Inserting To Database
i have one problem in my website. i have one registration page in which i have several text based fields and 5 upload fields...which will be images. now what i have to do is that insert all the text based data to a table named product. the images should be inserted to a table named productimage. Code:
Inserting Text
when you insert text into mysql wich functions do you use to make sure the text is enter safely.. such functions as htmlspecialchars that changes the html mysql_real_escape_string and others and to retrieve the text. can any one give me some good functions to enter text the way the user enter it in their comment and make sure the text looks the same when it comes out of mysql.
Inserting Data
how to insert select and view data from a database but i cant get it to work, it says that the data has been insterted but when i go to index.php nothing is shown, maybe it is my database? wht should the code be to make a suitable database? Code:
Inserting Data Only ONCE
I currently have the following: $zip = $db->escape($_GET['zip']); $db->query("INSERT INTO zipdata SET zips = '$zip'"); However, every time that page loads it is inserted. Is there a way to make it only insert one time per user.
Inserting Into Database
i have a form for newsletter sign up, the customer enters their email in a text field and hits submit, once submit is clicked it process the form in "newsletter.php" I need to GET the email from the url and then insert it into table newsletter, row "email" heres my messed up code so far.. i don't even know if i'm even close... <?php if($_GET['email']!="") { $newsletter = 'INSERT INTO newsletter (email) VALUES (".$_GET['email'].")'; } ?>
Inserting Data Into A Table
I would like to know if there is anything strange about the script below(I have only just started to learn php so there may well be!) Although it seems to work, occasionally it doesn't just insert a single row into the data base, instead 2 or 3 duplicate rows end up in the table. Could the explanation be that I tried this morning to create a table and forgot I already had one with this table name in the database. Would that have damaged the table in some way making it misbehave! I have commented out the bit about creating tables as I only want to insert data with this script at the moment. One other thought occurs to me, is the problem due to my host freedom to surf as its only a free host and I expect you get what you pay for(or don't pay for in this case). I have subscribed to a pay host http://www.phpwebhosting.com but I am unable to use the database that they have provided because they have informed me that I must use a telnet shell to log into my database and I have absolutly no idea what this is(is it in my Win98?) or do I need to go and get one. I am still waiting for this host to email me back with some help. If there is anyone out there who could tackle all or some of my problems I would be very grateful indeed! One last thought - I think there is something very strange going on as sometimes when I visit my database, there is less entries in this table than last time, some have been chucked away and my id entries are all out of order now, something like 1,2,3,11,5,7,12 - the last insert had id = 12 next to it and somehow another duplicate has sprung up id = 11???????? Whats going on please! <html> <head> <title> Connecting to Mysql server at ISP host</title> </head> <body> <?php $Host = "db.davegraham.f2s.com:3306";// Set the variables for the database access: $User = "p0c79"; $Password = "********"; $DBName = "p0c79"; $TableName = "Jokes2"; $link = @mysql_connect("$Host", "$User", "$Password"); if (!$link) { print("<P>Unable to connect to the " . "database server at this time.</P> "); //note how 2 strings have been concatonated exit(); } else { print("Your now connected to the Mysql server at the host ISP.<P> "); } if (! @mysql_select_db("$DBName") ) { print("<P>Unable to locate the $DBName database at this time.</P> "); exit(); } else { print("The database $DBName has been located.</P> "); } /* $sql = "CREATE TABLE $TableName (ID INT NOT NULL AUTO_INCREMENT PRIMARY KEY, JokeText TEXT, JokeDate DATE NOT NULL )"; if ( mysql_query($sql) ) { print("<P>$TableName table successfully created!</P> "); } else { echo("<P>Error creating $TableName table: " . mysql_error() . "</P>"); } */ $Query="INSERT into $TableName VALUES(Ɔ', 'hello hello hello!', ��-08-08')"; if (mysql_query ($Query)) { print ("The query was successfully executed!<br> "); } else { print ("The query could not be executed!<br> "); } mysql_close($link); ?> </body> </html>
Inserting Multiple Rows Via The Web
I would like to have a form that can have multiple rows inserted on the same page and then submitted to the database in one click. How would I go about doing this with, say, three text fields that are named "name", "email", and "URL"?
Inserting Data Using A Form
I created a script to allow the user to select the number of images to enter. After that the script generates the entry fields dynamically. The final step is entering all images into one column in the db called images. The problem is i got it to work using an advice from someone at devshed forums to use some additonal script. Please see below. 1) HTML File that allows you to enter the number of text boxes to create for each image you want. <FORM METHOD="POST" ACTION="do_show.php"> <P><strong>Number of images:</strong><br> <INPUT TYPE="text" NAME="num_imgs" SIZE=5></p> <P><INPUT TYPE="submit" NAME="submit" VALUE="Go to Step 2"></p> </FORM> 2) PHP file that shows the created text boxes for you to enter the names of these images:
Inserting Into Multiple Tables?
I need to increment the value of 'id' in 5 tables whenever it is incremented in another table.... Is there any way to do this? How?
Inserting Multiple Textfields Into A Db
i have a thing where u enter how many files and it makes that many textboxes for u to enter stuff each named $files[0] , $files[1] , etc i want to put them in 1 thing so like combind em all and put em in like this $download_query = "INSERT INTO abc VALUES('$files1')"; $download_result = mysql_query($download_query); i want all the stuff out of all the different checkboxes to go into like files1 and i like make it take all the text and put it into a variable?
Inserting Emoticons In To A Textarea
I am planning to add emoticons (Smiles) of which is located on another page of which opens up when a user clicks on the link to bring them up. I have created the page to make them clickable to add the information to the textarea on the posting screen. But how would I go about it adding them to the textarea when the user clicks on the graphics? Kind of what they have got on the VB boards?
Inserting Data Into 2 Tables
I've got this products page form and what I have is two tables to insert the data into, about_products,about_urls. What I am trying to achieve is to insert info into about_products table and the URLs associated for that product. The thing is, is that I'm having trouble getting to insert the URLs for that product. Note that the product form is duplicated 8 times. PHP Code:
Help Inserting <p> Tags Into Text
I am having trouble writing this in PHP and was wondering if anyone could help me. On my website I have a basic system where I can type HTML code into a box and it appears on a webpage. As simple as that. The problem is that a lot of the items I am putting into the site are Text based. They are separated into paragraphs by double returns (though the line in-between may have white space on it like spaces). It is very slow to put all the paragraph tags in. What I would like to be able to do is to be able to use html tags like li, ol, table, tr, td th, a, b, c, h1 etc without having to put the paragraph tags in. I then would like php to place paragraph tags around the paragraphs and place a br where there is only one return (but only do this outside the previously mentioned tags).
Database Inserting Problem
In the database i have 2 fields: Subject type text Content type text My query is something like insert into table_name values ('$subject', '$content'). These variables are taken using POST from a HTML formular. the problem is that if i i write into the subject field from the HTML page "Hello friend" into the database it's inserted only the first word ("Hello"); the same happens with content; How to overcome this problem?
Secure A Unique ID Before Inserting Into DB
I am writing an application to handle support requests, and the user needs to have his request number printed out in front of him even before he hits the "submit" button. I have no idea how to secure a unique number without relying on a database. How could this be done ?
Inserting Data Into A Table.
I keep getting a parse error with this code. What am I doing wrong? The SQL statement works in MySQL. Is there something wrong w/the way I'm decaring my PHP variables? Code:
Inserting Into Two Tables At One Click
I want to insert some data into 2 of my tables through my PHP form.How can i do it? For example, field1, field2 should be inserted into table 1 and field3, field4 should be inserted into table 2. I'm able to insert into one table but not into 2 tables simultaneously.
INserting Perl Script
I'm trying to createa PHP page which will fiurst of all gather output from a form. Then I want it to insert a script (sort of like SSI would), but to append these collected variables to the script name.. so i want it to be something like this.. < insert header.html > < insert script.cgi?output=somevariable > < insert footer.html > the thing i really need to know how to do, is how to collect variables from a form. I suppose putting in SSI tags won't do anything to the PHP page. So whats the syntax as to how to collect sent data.
|