Array Directly Into A Table
I have been doing some thinking and am trying to find a shortcut. I have an array that I would like to add directly to my db. This array contains 122 - 125 string values. My data base will have 125 fields. Is there a way to insert the array into mysql without doing the obvious which would be to make a single insert query that would name all of the fields and then somehow make a foreach to loop through the individual elements of the array.
$fields = explode(" ", $record);
//separates each tab separated value in array $record and puts it in $fields
//Time to insert into database
$query = "INSERT INTO residential(//definitely do not want to declare 125 fields here) VALUES(//$fields array)";
$result = mysql_query($query); //Run the query.
View Complete Forum Thread with Replies
Related Forum Messages:
Can I Put A Mysql Query Result Directly Into A Multidimensional Array?
I have two joined tables: Departments - which contains the department description and a key Positions - which contains position data What I'm attempting to achieve is to display the department title in one table cell and then list all the positions associated with that department in the cell under neither the title. I need to generate a table two column table with as many rows as required, depending on the number of departments, which is dynamic. Do this I'm trying to turn the result of my SQL query into multidimensional array e.g. dept = VioP positions = "designer", "engineer" etc, which I can do then use to generate the table. I've done a search on the forum and looked around the manual and I'm stumped on how to achieve this, a point in the right direction would be greatly appreciated. The query I'm using is below. PHP Code:
View Replies !
Printing Directly From PHP
Currently I work in a school and I wish to build a PHP/MySQL portal which allows teachers to enter student exam marks online through the portal. The same site will provide reporting etc. and prints the result of each student on a separate page, which can then be sent by post. In order to print the results I wish to create a print button (or something similar) which once pressed, extracts the individual student details from the Database and sends them directly to the printer without outputting anything on the screen. IS this possible with PHP?
View Replies !
Streaming Content Directly?
Could someone tell me if there's a way to filter & stream the content of a different site directly to someone's browser (without redirecting the user to the other page)? Right now, I'm accessing my friend's site, filtering the data, and putting his content on a part of my page. I'd like to know if there's a way to speed this up. Saving his files to my host and then sending the data out again is taking more processor power than I'd like to be using for this task.
View Replies !
Reload Image Directly
I am uploading a new image to my database. The upload works ok and the new image is stored ok on server. The problem is can I force a reload on cache to display the new image. If I reload the page it works fine but if i dont then the old image is displayed.is there a way to force a reload of image.
View Replies !
Printing Directly And Emailing
i have a registration web page....on the last page i give out all the information of the registration (student ID, course ID, Name etc etc...) now what i want to do is ....Email all that information to the email of the student (which he/she has provided earlier in the registration process) and also let them print out that information "with a printer friendly page".
View Replies !
Can Php Read .xls Files Directly?
I'd like to be able to read a microsoft spreadsheet with php. I know that php can read mysql, so I was thinking that maybe it could read excel spreadsheets as well. Does anyone know if that can be done?
View Replies !
Number Rows Directly
I need to do something like this: SELECT row_nr, * FROM asdf LIMIT 10 The column row_nr should be 1, 2, 3 ... 10, but row_nr is NOT a value in the table, I need it to be "generated" some way in the query. The reason is that I want to do something like INSERT INTO table SELECT row_nr, * FROM and so on, And I need every one of those queries to be numerated (in row_nr) starting from 1 and going to as many rows as the query results in. how to solve this one?
View Replies !
Send An Email Directly
I am wanting to know how to send an email directly from my website. I want it to send an email to a user through a socket connection without me needing my own SMTP server or me using a 3rd party SMTP server. It should work something like http://www.mustap.com/phpzone_post_95_sending-email-in-php-the-hac but it should be something I can put into a production function.
View Replies !
Sending Attachments Directly From Form
I have a form with a normal upload type form item, now when this form is submitted I want to attach it to an E-Mail, and then send it out. What do I do in the PHP form processing code to do this? Obviously I would use MIME mail, but what is the easiest way for me to do this. Specifically this is for attaching a Resume to a job application that will be sent to an E-Mail address immediately. So the file types will be the normal, '.txt', '.doc' etc.
View Replies !
PHP To Reading Directly From ISAM Files
Are there any utilities that would allow me to use PHP to read directly from an ISAM file? I have a customer who's application uses keyed ISAM files, but there is no ODBC driver available. We don't need to have writing capabilites, just reading. There doesn't appear to be any native support within PHP, so I am hoping to find a utility that I could modify for my purpose. The thought of writing something in PHP using direct file access commands (fopen,fread, etc) is a bit intimidating ! Perhaps someone knows of a "tutorial" on this ?
View Replies !
Cannot Access Session Variable Directly
Basically, a variable called $city_code is passed through the URL and picked up in the script. If that $city_code has not been set as a session variable, then I want to set it. For some reason I cannot access that city_code directly. So, if the city_code is SIN, then I want to be able to access it as $_SESSION['sin']. However, I can only access it as $_SESSION[$city_code]. I have included 2 echo statements in the script to show where it went wrong. The echo $city_code returns SIN. However. the echo $_SESSION['sin'] just returns Notice: Undefined index: sin. I should also point out that the script actually does what I want it to do, just that I cannot access the session variable directly. (say $city_code = 'sin') PHP Code:
View Replies !
Outputing Image Directly To Browser
can one "stream" image data to a browser? I created an image using gd and when I do imagepng I just get the binary data for the image written as text instead of the image itself. Now I'm writing the file to a temp file and using html to load the temp but seems like a waste of cycles and space ;/ Anyway around this?
View Replies !
Security Alert! The PHP CGI Cannot Be Accessed Directly.
I have installed php4.2.2 using the windows installer but i am having problem. I get the message: Security Alert! The PHP CGI cannot be accessed directly. This PHP CGI binary was compiled with force-cgi-redirect enabled. This means that a page will only be served up if the REDIRECT_STATUS CGI variable is set, e.g. via an Apache Action directive.
View Replies !
Stream From FTP Directly To MySQL While Parsing CSV
I have some files that sit on a FTP server. These files contain data stored in a tab-separated format. I need to download these files and insert/update them in a MySQL database. My current basic strategy is to do the following: 1) Login to the ftp server using the FTP library in PHP 2) Create a variable that acts like a file handle using Stream_Var in PEAR. 3) Use ftp_fget() to read a remote file into this variable (this is so I don't have to write it to disk). 4) Parse that data now stored in memory using fgetcsv() (again treating that variable as a file handle using Stream_Var). This produces an array. 4) Insert/Update the data in the array using DB in PEAR. This all seems to work and it means I don't have to write anything to disk. Everything is handled in memory so not temp files are needed. The downside is that some of these files are very large so the program can consume large amounts of memory. I want to see what I can do to reduce this memory usage. In a perfect world I don't need to keep the entire file in memory. As soon as a single line is read via FTP I should be able to pass that line off to the CSV parsing code and the MySQL insert/update should be able to take place as each line is parsed by the CSV library. I.E. I should have more than a buffer worth of data in memory at a time. A buffer would need to be able to store at least a entire line but my memory requirements would drop significantly. My problem is that I can't seem to be able to figure out how to do this with the current PHP libraries. It seems that most functions in PHP are not designed around the idea of piping streams of information together. The other restriction I have is that I am limited to just PHP 4.3. Any ideas or is holding the entire file in memory the best way (other than writing my own libraries).
View Replies !
Referencing Returned Objects Directly
Is it possible to directly reference an object that is returned by a function in PHP? ie this: echo ReturnAnObject()->SomeMember; instead of this: var $Object = ReturnAnObject(); echo $Object->SomeMember; 'cus I can't work out the syntax if it is. :-(
View Replies !
Use Exec To Run The Program Directly From The Server.
I have an image manipulation program that is run from commandline, I have never used exec before and I'm scared to becuase I don't want to mess up my server or anything. Basically, I want people to be able to upload an image, then arrange for some manipulations to take place on the file in a temporary batch file, then use exec to run the program directly from the server. The program is called nconvert.exe, and the main thing I want to do is convert DDS textures into BMP files, the command, from Windows "cmd" is: nconvert -out bmp %1 %1 being the dds file to be manipulated. How would I go about doing the exec part? I know how to do the upload, but not the exec.
View Replies !
Include Code Directly From A Database
I searched through the forums and didn’t see a discussion of my question so here it goes. Is it possible to use a php include() to insert code directly from a database? For example, if I have a file something.inc which contains the following: <?php …. Some php statements ?> and have in my index.php file the statement Code:
View Replies !
Running A PHP Script Directly From The EditPlus Editor
I recently installed both the PHPDEV2 package on my Windows 98SE Pentium 2, and I started writing PHP programs using the EditPlus Editor. Somewhere I read a comment about the possibility of running PHP scripts directly from the EditPlus Editor, but the writer (I forgot who it was) didn't tell how to do this.Can anybody help me with this? I hope this is not a trivial question, so that more people will profit from the answer(s)!
View Replies !
Access A Protected Page Directly, Without Logging In
On the first page a session variable ($_SESSION["admin"]) is created and set to true, if your login details are correct. On the pages being protected I then check to see if this session variable is true, and this works fine. The problems arise when I try to access a protected page directly, without logging in (impersonating an intruder). The code I'm using to check is just below, and further down is the error message. I don't get it really. I'm not sending any headers before checking the session variable. PHP Code:
View Replies !
Array To Table
is there some way i can have a script dump all the details in this array into database tables without having to type it all out manually? I'd like it in fields of gameid and gamename specified in the case clause...but short name will do if thats all i can get. All the info would be best if possible. Here is the array... PHP Code:
View Replies !
Getting Array From Table
How do I take values from a table as an array? I have a table with day, month and year as headers for it and want to read them as an array like this: $booked = array("day", "month", "yeear");
View Replies !
Sessions - Stop People From Directly Accessing The Edit Page.
i saw there was another thread about sessions, but i thought it would be best not to hijack his thread. Anyway, I have a password for my site, which passes the user onto another page to edit the content, but i need some help with sessions so that i can stop people from directly accessing the edit page. But all the examples i have seen dont go this far with the sessions, and i dont know where to go from here.
View Replies !
To Write An Array To A Table
I have a javascript array to pass to PHP: var javascript_array={{"1","Elisab eth","London"},{"2","Antony"," Paris"},{"3","Augusto","Roma"} ,{"4","Tom","Miami"}} I transform it into a string var string="1,Elisabeth,London;2,A ntony,Paris;3,Augusto,Rome;4,T om,Miami" I separated any old array with a ";" and any element of a singhe array with...
View Replies !
Fetching Array From MySQL Table
Some told me to better learn some basics of php and mysql, but i encountered a problem that i couldn't solve with all the tutorials out there. I tried the following code to fetch an array from a MySQL table named Gallery: PHP Code:
View Replies !
Insert Into Table Via Assoc Array
I am trying to populate data from an array into a table, but i cant figure out what i am doing wrong. //mysql query $sql = "SELECT charge_location.dept_code, charge_location.week, Sum(charge_location.total_hrs_paid) AS sum_of_total_hrs_paid, Sum(charge_location.hrs_non_chargeable) AS sum_of_hrs_non_chargeable FROM charge_location GROUP BY charge_location.dept_code, charge_location.week"; $result = mysql_query($sql); $num_results = mysql_num_rows($result); //populate the stats_table for($i=0; $i<$num_results; $i++){ $row = mysql_fetch_array($result); mysql_query("insert into stats_summary values( ($row[dept_code]), ($row[week]), ($row[sum_of_total_hrs_paid]), ($row[sum_of_hrs_non_chargeable])) "); } PS i get no errors when it executes, just fails to populate the table.
View Replies !
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.
View Replies !
Using An Array To Insert Data Into A Table.
This works: $col1 = 2; $col2 = 2; $col3 = 2; $col4 = 2; $query = "INSERT INTO test (a,b,c,d) VALUES ($col1,$col2,$col3,$col4)"; and this does not $col = array(2,2,2,2); $query = "INSERT INTO test (a,b,c,d) VALUES ($col)";
View Replies !
Creating An Array From An HTML Table
Before I try to do this myself (I remember doing it in Java years ago and it was a pain).... Has anyone run across a function that will take a string parameter containing an HTML table, and return a 2-dimensional array with each element corresponding to the contents of a table cell? I see plenty of examples of doing the opposite: convert an array to an HTML table. I want to go the other way, from an HTML table to an array.
View Replies !
Need Help On How To Retrieve The Respective Value Of Array From Another Table
I'm using explode() to extract and make an array() readable. I'm able to make the array() from dbase readable. categories_table { catid name 1 'test1' 2 'test2' 3 'test3' } implode_table { email catid test@local 1,2,3 help@local 2,3 } For example, if test@local logged in to the system, how can test@local load all the information of the catid he selected? My code for the moment fetch only all the catid that's being saved under test@local account. foreach (getImplodeCategoriesByEmail($email) as $explodeCat) { $delimiter = ","; $content = $explodeCat['catid']; $splitContent = explode($delimiter, $content); foreach ($splitContent as $result) { echo $result; } } Assume that getImplodeCategoriesByEmail($email) is fetching all the records that match the email. This piece of code worked. It gives me a result of 123. THE PROBLEM: HOW CAN I LOAD ALL THE INFORMATION OF THE EXTRACTED CATID? The output should be like this 1 test1 2 test2 3 test3
View Replies !
Multidimensional Array In To A MySQL Table
Trying to load an multidimensional array into a MySQL table with columns as follows, level1,level2,level3,illust,item,description,partN o,qua,price,remarks,weight ,size,mass the array first line is $input[0][level1]Engine the array secondline is $input[0][level2]Cylinder Head etc.. A 'foreach' inside a 'foreach' echo of the array gives the following, which is correct. 0, level1, Engine 0, level2, Cylinder Head 0, level3, 0, illust, 001.pdf 0, item, 1 0, description, Casting 0, partNo, 238356 0, qua, 1 0, price, 1,245.00 0, remarks, This is for the Z350 series 0, weight, 5 0, size, 5x5x5 0, mass, 37 1, level1, Engine 1, level2, Cylinder Head 1, level3, 1, illust, 001.pdf 1, item, 2 1, description, Valve, inlet 1, partNo, 452790 1, qua, 4 1, price, 5.46 1, remarks, This is for the Z350 series 1, weight, 5 1, size, 5x5x5 1, mass, 37 2, level1, Engine 2, level2, Cylinder Head 2, level3, 2, illust, 001.pdf 2, item, 3 2, description, Valve, exhaust 2, partNo, 345436 2, qua, 4 2, price, 5.99 2, remarks, This is for the Z350 series 2, weight, 5 2, size, 5x5x5 2, mass, 37
View Replies !
Sorting A Table Into An Array In Mysql
Can someone tell me how to sort a table using a while function. This is what i want to do. I have table that has 17 fields, the first two are id and date and the rest of date..but what i want to do is take the data and sort it by the date and put the rest of the data under that date. example: date Data date Data I asume the array will look like this result[0][0] result[0][1] result[1][0] result[1][1] and so on .....
View Replies !
Populate Array With Mysql Table
What I would like to do is populate an array with some information pulled from a mysql table. as an example lets say I have a table that shows: id ¦ name ¦ nickname what I would like to do is have my array as follows: $name_ar = array( 'name1' => 'nickname1', 'name2' => 'nickname2', 'name3' => 'nickname3', /* and on and on */ ); Arrays are not my favourite things, some help?
View Replies !
HTML Table Data Into Array
I want to know if it already exists. I need some PHP code that will read a web page and return all text that comes between <td></td> tags in an array. So if there were three tables on that page, it would return the first table's fourth row, third column in a variable such as: $tableArray[0][3][1] // ^ ^ ^ - 2nd <td></td> // ^ ^ - 4th <tr></tr> // ^ - 1st <table></table> Does something like this exist somewhere where I can grab it, or do I have to build it from scratch?
View Replies !
Php Array Data To Html Table
I parse an XML file every day into php and use the print_r() function to display the contents. It looks like this: <Name="JOE" score="1.2538" /> <Name="BOB" score="136.69" /> <Name="ANN" score="0.5729" />
View Replies !
Update Table From Array Values
I have a table with records and each record has a groupid, userid and a statusid. Where a status is a particular number within these records, I need to gather those groupid and userid into an array. Then i need to use the values in the array to update the same table with a new statusid. So, i basically need guidance on how to do this. This is what I have so far: $sqlquery = "SELECT groupid, userid, statusid FROM mytable WHERE statusid = 1"; $result = mysql_query($sqlquery); while ($datarow = mysql_fetch_array($result)) { $myarray[] = $datarow[groupid]; $myarray[] = $datarow[userid]; }
View Replies !
Comparing PHP Array From Checkbox To MySQL Table
My problem involves updating a MySQL table using checkbox input. I'm relatively new to both PHP and MySQL so I'm looking for a little direction on the smartest way to accomplish my goal. When a user goes to a project page, they are able to categorize their project by area. The user checks a series of checkboxes and the results are stored in an arrays called $category_ids. I'll called the project id $project_id. What I want to do is compare the array $category_ids to entries in a MySQL table for $project_id. Then I want to add the links that aren't already in the table and delete the ones that need to be deleted. The table has these fields: projects_cat_link (table) ---------------------- category_id ¦ project_id (fields) Does anyone have any tips on how to do this? I've gathered that maybe there's a way to get the MySQL data into a similarly formed array and then use functions like array_diff to compare. But then I'm not sure how to use the comparison in a MySQL query to add/edit/delete the links.
View Replies !
Recursive Array From A Twin-column Table
I have a MySQL table with two columns: catagory and parent. Parent contains the parent catagory of the catagory. I need to query the db ONCE, assigning the info to an array, then create a recursive array parenting catagories and grouping accordingly.
View Replies !
|