Passing PHP Arrays To Mysql Best Solution
I am relatively new to PHP and until now I have only needed to use relatively simple php/mysql solutions.
I am working on a problem where I need to store CD information (Artist Name, Album Name, Track Names, Catalog Number)
I am working on a solution with two tables "album" and "tracks" and I am using the catalog number as a key to link the two.
The problem I am having is coming up with the best way to populate the tracks table as there are several tracks for each release. I am assuming that an array would be the correct way and maybe a dynamic form to input the tracks where you decide the number you need to add and this then creates a form with "n" input boxes?
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Looking For PHP Solution To Adding Content To MySQL Database
I have recently used aedpro to quickly make pages for my client to be able to /add/edit/delete/view all/ content in their MySQL database. Though these pages work, they are limited to an all-or-nothing type view within their returned record pages. You can't sort the edit or delete pages to find your information quickly/easily, you have to scroll through all the records to find your record of interest. The database contains over 2000 horses, so scrolling to find a particular horse takes too long. Or, when trying to edit a horse's record, or group of records, you have to scroll to find the record(s) instead of being able to type in the record's horseID number and then go just to that record or group of records to edit. Do any of you gurus out there know of a PHP based MySQL database management system that you have used that is both flexible in its use and easy to install? I have Googled, but nothing is coming up but CMS type systems, which we don't need. Perhaps I am calling this something it is not, thus I can't find it. Any help or direction appreciated.
Passing Arrays
I have an eccomerce site that has a shared secure server this causes problems with my sessions because as soon as you go to the secure server it obviously starts a new session because it is on a different server. Firstly is there a way to stop this. Secondly if not can I easily pass an array to the next page in a form, I don't think this is possible don't all items have to be displayed in the form, each item in the array needs a form field (hidden) in order to pas sit to the next page.
Passing Arrays To Functions
[code] $job_status = array( "unassigned", "current", "completed" ); function gimme($name){ echo $$name; // this is in hopes to echo the contents of $job_status when gimme(job_status) is called } How can I get $name to be the ARRAY $job_status? I'm trying to keep this very modular so that I can also perform: gimme(job_type); among others.
Passing Arrays To New Function
I am filling an array in one function and want to pass it to another. I am making the variable global with the correct syntax (I believe) PHP Code:
Passing 2D Arrays From PHP To Oracle
I have an existing Oracle database application that requires a "simple" front-end (do these things ever turn out to be simple?). There is an existing API written which I would like to reuse if possible. Here is a snippet of the API: TYPE property IS RECORD ( property_key VARCHAR2(8) , property_value VARCHAR2(128) );...
Passing Big Arrays To Another Page
I'm having a little problem on my advanced search system with large amounts of results, when trying to pass them to another page. Tried to use the serialize function but when the results reach a number, for instance, of 300 the link will not handle that. It works for small resultsets. When user search the database for (example) stores in "New York" we get 256 results. Now I want to give the user the chance to search on these results, the stores found in the former query that sell "bread", which would take the user to another page called "advanced search for store features". This to avoid the use of big forms for these advanced searches, where I've created a degree set of search pages (I have about an overall 250 features to search). The main problem seems to pass the array to the other page when large ammounts of data are set on this array, which I'll call here as $storeIDs. When the results are small, the serialize and unserialize function will do the job. Is there a way of going through this in other manner?
Passing Arrays Through Sesisions In 4.2?
I am trying to find out the easiest way to pass an array from page to page through sessions...using php 4.2. I was very familiar with the older versions, but now that I am moving to the new platform with the new variable prefixes ($_SESSION, $_POST, etc..) I feel sort of lost. What I need to do is, for example, have a text field that when submitted, is sent to the same page, but is added to an array with the contents of the array being displayed. I need this to be able to be done as many times as needed. Here is a sort of sample of what I have been working on. Code:
Passing Arrays Between Servers
How can i pass a multi-dimensional array between 2 servers? I tried serialize/unserialize but i have noticed it is working today and tomorrow not anymore. i played a little with it and even tried base64_encode(serialize($array)) only to find out that serialize does not always bring the expected results. Can it be that serialize is buggy (not realy my question)? I do not want to use mysql as both servers are configured to deny remote access. ,I cannot use sessions because one server is a ssl server and the other is not, so this option is also out of question.
Passing Arrays In URLs
Passing Arrays in URLs. I.e passing arrays between two pages. This has been delt with here before but I can't help feeling there is a better way. The two current options are: serialize and urlencode .... then ... urldecode and unserialize OR implode ... then ... explode But if you create a form with a multiple select in it like so: <SELECT NAME=selectname[]> etc .. the array $selectname appears automatically in the backend when the form is submitted. Note that $selectname is an array. This means that php must automatically create arrays from data POSTed in a particular format. If we could pass an array in this format in a url or a hidden form then we wouldn't have to do anything on the recieving page. Anyone know what this format is?
Passing Arrays Between Two Pages
I'm trying to pass array values between two pages and on the second page I want to implode the array so I can use its values to interact with my db. This is what I'm doing right now: Code:
Passing Arrays To Functions
How do I pass an array to a function? This is what I have, and the second function doesn't seem to be getting the array somehow. I'm sure it's in the function declaration... function one(){ return $array; // yes, there is more to this function, and assume that "$array" is a real array } funtcion two($arrayArg){ // <- I'm sure the prob is here. print_r($arrayArg); // This isn't printing anything, when it does in one() } then I call: two(one()); Once again, I'm sure the prob is in the declaration.
Passing $_POST Arrays
I have a form which people fill in, it takes them to a page where the details are all displayed, and they then click on confirm to verify that these details are correct. I thought the easiest thing to do would be to pass the whole post array through the form on the "confirm" page, then just extract it on the next (processing) page However, when I try print_r on the value I assigned to the post array, it just says "Array". My code is below, what have I done wrong? Code:
MySql Not Enable From IIS But Worksfrom Command Line -- With Partial Solution
Problem: MySQL library bound ONLY when PHP is run from the command prompt, and NOT when PHP is run from an IIS Web page. (Error indicates that mysql_connect is an unknown function.) Not only does the library bind from the command prompt but data is retrieved using the EXACT same program file that fails under IIS....
Help Passing Arrays - Serialize Not Working...
I found this example somewhere: <?php if( isset($ser1) ) { $arr1 = urldecode($ser1); $arr1 = unserialize($arr1); echo 'First four elements of array:' echo $arr1[0] . '<br>' . $arr1[1] . '<br>' . $arr1[2] . '<br>' . $arr1[3] . '<br>' } else { $arr[] = 'First' $arr[] = 2; $arr[] = 'Third' $arr[] = 4; $ser = serialize($arr); $ser = urlencode($ser); echo '<a href="' . $PHP_SELF . '?ser1=' . $ser . '">Pass</a>' } ?> It works fine. But my a href statement is something like this: echo '<a href="modules.php?op=modload&name=modname&file=index&req=dosomething&id1=1& id2=1&text=$ser">Pass</a>' I simply can not get this to work. It does not pass the serialized data correctly. If I look in the status bar, it will show text= a:4:{i:0;s: and then when I click the link it displays a:4:{i:0;s:5:"First";i:1;i:2;i:2;s:5:"Third";i:3;i:4;} How on earth do I do this?? Seems like it must be a syntax issue (i.e. my statement has all those &'s and the example does not).
Passing Arrays Through Posts, Gets, And Cookies
I used to use arrays in input data that will be turned into a superglobal more often, but now that I care more about xHTML validity, I don't. Validation checking websites (particularly the W3C validator) yell at me for having square brackets in a name or id attribute. I started going the simple way of just separating what would be the array name from what would be the subscript with an underscore and parsing that out with PHP later. Is there a better, valid way of doing this that will have PHP set up my multidimensional superglobals for me as it would with the square brackets?
Passing Checkbox Values Into The Correct Arrays
I've been looking at some code and the net for the past few hours trying to figure out what's wrong and I'm stumped. I have a form - multiple checkboxes (different names) and text fields going into an array. The text fields behave fine - the values from the first entry will populate elements of the first array. The weird part is that the check boxes will pass the correct values but not always to the correct array element. For example, given two check boxes in a 2 element array, if you check the 1st box in the first element and the 2nd in the second element, on submission, the second element populates the first array element. I've included a snippet of the code as an example - it's echoing things like crazy because I've been trying to see what's been going on. I hope someone can figure this out for me 'cause I'm completely stuck and am on a deadline. Code:
Passing Arrays From PHP To A Perl Script Run As Exec
Is there a way to get PHP to trigger a Perl script to run, AND pass that Perl script one or more arrays? I need to run a Perl script at system level that returns a boolean 1 for fine and 0 for an error. Is this at all possible?
Disable Passing Arrays In Query String?
Is there any way to stop PHP from turning a query string like this: ?var[] into an array when it is read by $_GET['var']? I have quite a few input validations that are easily screwed up by this strange (and apparently undocumented???) feature...
Arrays In MySQL
Can I store an array into an SQL database and then take it back out and it would still be an array?
Arrays Into Mysql
The mysterious message: Couldn't add data to the CATLINK table:Unknown column 'Manufacturing' in 'field list' PHP Code:
MySQL Query And Arrays
I have a 'links' category on Table A and I want to retrieve the links from the Table and display them in a list-like fashion when the page is called upon. How would I go about seperating the links from one another (there a space inbetween each link.. EXAMPLE: http://asdf.com http://asdasd.com http://asdfff.com), loading them into an array (or using the best possible method to acces them easily) and then displaying them in a list like fashion..?
Arrays And MySQL Querys
I can't get an $array[key] to be used as a select query on a mySQL database. I have a 'parts list' which displays on a page (works fine) and is a form. At the end of each row is a input type='text' (quantity) cell with a default 0 The quantity can be altered. At the bottom of the table (form) is a submit to basket Button echo "<form action='basket.php' method='POST'>....
Arrays And While Mysql Functions
How can I get this array to work? I am trying to add data to an array for every row of data? This is a sellection of queries that I need to parse into an array so a function can use the arra to draw a graph. I am new to arrays how can I get this to work? Code:
Arrays Working With MySQL
How can I grab a certain field of a Multi-Dimensional Array using the ID. I have set for that Array? I just want to be able to create a simple function to do pretty much what this function does, but for an array. Code:
Insert Multiple Arrays Into Mysql
I am having problems writing the code to generate my SQL INSERT query. I have 3 arrays and one static variable ($cat_number): $track_name[] $music_link[] $track_number[] $cat_number Should I be using a foreach command. I know how to insert multiple values but its generating the query that i'm not sure about. INSERT INTO table (track_name, music_link, cat_number, track_number) VALUES (var1,var2,var3,var4), (var5,var6,var7,var8), (var9,var10,var11,var12); I don't want to store the actual array in the dataabase, I am just using an array to catch the data.
Multiple Selections, Arrays, And MySQL
OK this place has been great with explaining things that are way over my head, now I could use a boost to get my brain working again. I have a form with a drop down menu with multiple selections. When the form is submitted it shows up in the DB field as "array", as well as the page where I how the form's info. I think I have to set up an array, and loop(?) it, or do I need to implode the array? And how and where would I put these commands on this incredible messy form page. Would someone mind helping me get started? Here's the form: (please don't make fun of me, I used to a Dreamweaver extension to create the form using PHP, before I decided to try and write this stuff myself. I am re-doing the form but this actually works for now, so I am using it. Code:
Sorting Arrays Retrieved From A MySQL Db
I am trying to make a news system. I have done it, but the news are listed with the last on at the bottom. This makes it kind of troublesome to read the latest news when you enter the site and there are a lot of news items, cause you would have to scroll down. PHP Code:
Populating Arrays From MySQL Query
I have the following code: http://pastebin.com/746601 The field 'material' in 'is_material' contains multiple values for each record in 'is_details'. Because of this I have used 'is_material_lookup' as a reference lookup table containing the 'style_code' and 'material_code' which refer to their full details in the respective tables. Currently I have got the script outputting all the details and one material then in the next block of data, repeating the details with a different material. What I would like to achieve is having 1 block of data with a list of all materials in that, instead of the repeat, but sadly I can't know exactly how to do it.
How To Insert Arrays Into Mysql Database
This is my order.php file. Now I try to make a new php-file for processing the ordered items on this page, into another table "ordered_products" in the database. I want to INPUT following values into the table "ordered_products": 'order_num', 'order_item' and 'order_ant' I know how to insert rows in a table using the INSERT query, but I don't know how to do it while looping the arrays. I have to fetch the arrays from this page, and insert them row by row in the "ordered_products" table. Code:
Using Arrays With Mysql Query Results
im currently in the process of making a piece of code that will firstly take all the data from a table in mysql and then assign it to an array. This data will consist of several different rows of data each with different infomation for each field in the table. i want to be able to use an array in a loop so that depending on which number of the loop is on will change the infomation that is assigned to a certain array. Code:
Merging 2 Mysql Resultant Arrays
im currently executing sql queries on two seperate mysql servers. i take back each of these results into individual tables to display them. What i wanted to do was perform a merge of the two arrays, so that i could order the results by my "TimeStamp" field. When i try to perform a basic " $mergedresult = array_merge($result, $isaresult); " i get the following. " Warning: array_merge() [function.array-merge]: Argument #1 is not an array in C:Program Filesxampplitehtdocsseatpub.php on line 164 Warning: array_merge() [function.array-merge]: Argument #2 is not an array in C:Program Filesxampplitehtdocsseatpub.php on line 164 " Im rather new to this and so havent delt with arrays before, but im under the impression my results from the sql queries, are Assoc arrays. can these be merged ? do i need to use an alternate php function ?
Pesky Checkbox Arrays And A MySQL Song Database
I'm not one who likes to ask for help, so for the last three days my brain has been turning to mush while I try to create a DJ Request Song Wish List. Anyone who can help me out will be saving me from severe insanity. :) My goal is to: 1. Display search results for song title, artist and genre. (accomplished) 2. Allow the user to add songs to their Wish List. This is done by displaying checkboxes with the corresponding value equal to the songID. (working on it) 3. Allow the user to update their wishlist by adding/deleting songs. So far I have a form that retrieves the song info from a database in a repeating region. In Dreamweaver: <input name="songID[]" type="checkbox" id="songID[]" value="<b><?php echo $row_RecordsetSearchResults['Title'];?></b> by <?php echo $row_RecordsetSearchResults['Artist'];?>"> This puts the corresponding songID number into a checkbox value, which in turn is submitted by form POST action to the following page as an array. To process this array I have: if(isset($_POST['songID'])) { $songID = $_POST['songID']; print '<p>Song IDs:</p>' // process items $n = count($songID); for($i = 0; $i <= $n; $i++) { //See if the values are being passed from POST echo $songID[$i]; echo '<br>' } $songsInsert = '*'.implode('*',$_POST['songID']).'<br>' $insertSQL = sprintf("INSERT INTO wishlist (Username, Title) VALUES (%s, %s)", GetSQLValueString($MM_Username, "text"), GetSQLValueString($songsInsert, "text")); mysql_select_db($database_ToneDeaf, $ToneDeaf); $Result1 = mysql_query($insertSQL, $ToneDeaf) or die(mysql_error()); } The problem is, I'm using implode. It does store the songs, but only as one long block of text. So if the user picks "New York by Frank Sinatra" and "Hot In Here by Nelly" it is stored as "*New York by Frank Sinatra*Hot In Here by Nelly*" Obviously this gives me no options to make this actually readable, let alone allow the user to remove one of those songs from their list (both would be have to be removed.) Also, referencing only the songID number as stored in the music database doesn't seem a good option, since the song database will be changing frequently and song data may be overwritten. Not sure if there's a viable workaround there. Originally I wanted to store Title, Artist, Genre under seperate columns so I could link them to something like "See more songs from this Artist." However the more I read about arrays and multidimensional arrays, I realize I'm not ready to go there yet. (I just started learning PHP two weeks ago.)
Comparing Values Of 2 Arrays Combined With Mysql Field Names
I am trying to create an edithistory table that has a text column into which I will put a string that can be read using strtok later to revert changes if necessary. I want to build this function so that it's dynamic enough to be applied to every table so that I don't have to write one for each table that might be updated. When a row is added to any table (a new entry), it retrieves the next available editid # from the edithistory table and assigns it to that item in the "edits" column for its row in its own table. Every edit made is a new entry in the edithistory table (entryid auto_increment primary key), and the editid is a reference back to the object being edited. Code:
Passing MySQL Wildcard Into URL
I have a search feature where users can search a database. All works very well except for one small annoying bug. If a user searches for anything using wildcards and the '%' is the FIRST character searched for, my pagination routine doesn't pass the correct value. Say the user enters %300. The page displays the correct data for the first page, indicates that it is page 1 of 11 and when the NEXT link is clicked, the value changes to 00. I haven't figured out why the %3 drops, however I suspect it may be my use of quotes. Particular code is below. Can anyone help me? Platform is Apache on FC3, MySQL and PHP. Browser being used doesn't matter. <? if($pageno == 1) { echo "<TD CLASS=upperLinks>FIRST </TD><TD CLASS=upperLinks>PREV </TD>"; echo "<TD CLASS=data1>FIRST </TD><TD CLASS=data1>PREV </TD>"; } else { echo "<TD CLASS=data1> <A HREF='{$_SERVER['PHP_SELF']}?pageno=1&searchfor=$searchfor&searchtype=$searchtype' CLASS=upperLinks>FIRST</A></TD>"; $prevpage = $pageno - 1; echo "<TD CLASS=data1> <A HREF='{$_SERVER['PHP_SELF']}?pageno=$prevpage&searchfor=$searchfor&searchtype=$searchtype' CLASS=upperLinks>PREV</A></TD>"; } ?> <TD CLASS=data1>(Page <?=$pageno?> of <?=$lastpage?>) </TD> <? if ($pageno == $lastpage) { echo "<TD CLASS=data1>NEXT </TD><TD CLASS=data1>LAST </TD>"; } else { $nextpage = $pageno + 1; echo "<TD CLASS=data1> <A HREF='{$_SERVER['PHP_SELF']}?pageno=$nextpage&searchfor=$searchfor&searchtype=$searchtype' CLASS=upperLinks>NEXT</A></TD>"; echo "<TD CLASS=data1> <A HREF='{$_SERVER['PHP_SELF']}?pageno=$lastpage&searchfor=$searchfor&searchtype=$searchtype' CLASS=upperLinks>LAST</A></TD>";
Passing Variables To Mysql
My script works out a variable (the users ip) and then needs to pass it to a mysql table. Quite simple. But the trciky bit is that I need my php to run this style of script before it posts the data to the sql. Does the table for this hour exist? y/n (there will only ever be one hour table which needs to be overwritten each hour) Does the table for this day exist? y/n (there will be a new table for each day) Does the table for this week exist? y/n (there will be a new table for each week) Does the table for this month exist? y/n (there will be a new table for each month) Create the corresponding table if neccesarry. Post the data to the all the corresponding tables according to the time and date. By doing this I am keeping all the tables amended and can pull them back into another php file which will read the data and post it accordingly.
Passing Username/with Mysql Lookup
I want to pass the username entered at login and at the sametime have a lookup where the team name is found, via username, and both are passed to the user_mainpage.
Passing Variables To A Mysql Query
I would like to find a way to accept user imput passed as a variable then submitted inside a MySQL query, only I want to use a dynamic variable in the initial query, I am still learning this and I am stumped on the best place to pass the variable information in a form without using sessions, I found several articles of interest however none of them went into the kind of detail a novice could interpret and act upon. PHP Code:
Php/mysql Variable Passing In Javascript
I have a phpnuke website, and I use DigiChat chat. Since I have users who register, I'd like to be able to pass there username and email (at a minimum) into the chat system, so they do not have to enter in their information multiple times. I am attempting to use the below file (which was obtained from a website using DigiChat and something called IBForums), but I am not able to get any output on the page when using it. Any help? <?php .............
Passing A Checkbox Variable To A MySQL Db
Im the webmaster for a boxers website, and rather frequently, the publicist sends me links to articles about the boxer that I need to post. So, I set up a form that allows me to pull the information as needed and post it. Basically I have it set up to post the Article Title, Article URL, and Article Date, and I call that information from the db. However, on occassion, one of these links will be a press release, and the only thing that changes is that the text Press Release: is added in front of the article title. I was thinking about creating an extra field in the table called article_pr, and referencing that on the page, and if the row is empty, it would just pull up a space, and if its marked it just pulls up whatever is in there. However, on the form, I need to have a check box that asks if it is a press release. If so, I would need it to print this in the code Press Release:<br> Is there a way to have the check box indicate whether it will put that code in the db field?
Need A Php Solution
I understand my question might not necessarily be a issue specific for PHP. However since my current development is conducted with PHP so I definitely need a PHP solution for it. Here is the situation: 1. A Login form page for user to keyin username/password. 2. After user input correct login info a small window will popup and the parent window (the login form page) still stay unchanged. 3. If user click "accept" on the popup window then the parent window changed. Step 3 is not a big issue for me. But step 2 is a big headaque.
PGP Solution
I would like to be able to take the data submitted to a form, encrypt it using a specified PGP key and email it to a specified recipient. All in PGP.
Looking For An ILS Solution
I'm hoping someone knows of an Integrated Library System that uses PostgreSQL. The group I'm working for had an old system and decided to upgrade. Previously, they were using PHP, MySQL and Koha (www.koha.org) to run their library interface. The new system they have is PostgreSQL, which means I cannot use Koha anymore. Converting the MySQL dump has been hard enough. The Postgres version is 7, so it seems that exporting the dump with phpMyAdmin does not want to work. But thats a different problem all together. So I need to find a replacement for Koha, all I've seem to come up with is a list of ILSs (http://www.anctil.org/users/eric/oss4ils.html) that either use MySQL, or only come in a completely different language. If anyone has any ideas or could point me in the right direction
Passing A Variable From A Form To A MySql Query
I have a form set up with a dropdown list of values for a field "Genre" in my database I can pass the variable to my php script. I know this because I use: $Genre = $_POST['Genre']; echo "<h1> Query result for Genre = ","$Genre", "</h1>"; And the page prints the appropriate value chosen from the form. I'm trying to use the $Genre variable in a mysql query to select records which match. My mysql query works when I use the following code:
Trouble Passing Mysql Table Name To Php Function And Using It!
Trouble passing mysql table name in php. If I use an existing table name already defined everything works fine as the following script illustrates. <?php function fms_get_info() { $result = mysql_query("select * from $tableInfo") ; for ($i = 0; $i < mysql_num_rows($result); $i++) { /* do something */ } } /* Main */ fms_get_info(); But it won't work if I pass a variable table name to the function. <?php function fms_get_info($tableName) { $result = mysql_query("select * from $tableName") ; for ($i = 0; $i < mysql_num_rows($result); $i++) { /* do something */ } }
Help Require For Map Solution
Here is a problem which i'm facing. Now i'm working on a site in which a user will provide the pincode(zipcode) of two positions and a line will be draw on that map between the two pincodes(zipcodes). Now the solution which i found requires a databse storing the details of longitutde and latitude for each pincode(zipcode). Also we do need to provide the latitudinal and longitudinal range of that particular map. Now i want to ask you friends if anybody has got any better solution which is more effective.
|