Array From Database Entries
All I need is to create an array with the results from a database column.
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Extracting Database Entries
I have a non-profit's web site that wishes to allow their members to fill out information regarding summer camp information (name, contact info, mailing info, physician's name, etc) online and submit it. I can handle taking the info with PHP and putting it into a mySQL database easily. But what has me stuck is that they want the ability to print out hard copies of selected submissions (their choice) if they need to. Would I have to display all the database entries in a form on a new page with a select box next to each entry and have them pick that way, then loop through and print out the selected ones or is there a better, more direct (read: easier) way to accomplish this? Does this sound like something for which there may be a pre-written PHP script that can be altered?
(PDO) Database Entries Are Not Possible, Even Without Errorfeedback!
I am trying to insert with PDO-Sqlite rows through a form. I can do whatever I want, I don't find the sollution where I made the error. Perhaps somebody of you could help me?! However, the database is created with sqlite, and the entries should be done with PDO_SQLITE. However, no entries are done anyways and I am one step going nuts, specially because I don't receive no warning or errormessage on the screen. Code: <?php require_once('HTML/Form.php'); require_once('I18N/UnicodeString.php'); require_once('HTML/Table.php'); class Formular { private $ServerVar = array("Auswahl","Betreff","Eingabe"); function __construct() { $this->ServerVar["Auswahl"] = $_GET['Auswahl']; $this->ServerVar["Betreff"] = $_GET['Feld']; $this->ServerVar["Eingabe"] = $_GET['Eingabe']; $this->MeinFormular(); //$this->sqdb(); if(($this->ServerVar["Betreff"] === null) or ($this->ServerVar["Eingabe"] === null)) { $this->MeineDB(); $this->TextFeld(); } elseif (($this->ServerVar["Betreff"] === "") or ($this->ServerVar["Eingabe"] === "")) { $this->MeineDB(); $this->TextFeld(); } else { $Auswahl = $this->ServerVar["Auswahl"]; $Betreff = $this->ServerVar["Betreff"]; $Eingabe = $this->ServerVar["Eingabe"]; $this->MeineDB2($Auswahl,$Betreff,$Eingabe); $this->TextFeld(); }
Edit The Entries In The Database
I have a script that allows you to edit the entries in the database. All is working fine except when you pull up an entry for editing the subject field only prints out the first word of the subject??? I know the entire subject line is in the database, but only this part of the script won't print it out. All the other fields work fine. Code:
Limit Entries In Database?
Im using a guest book script that uses a Mysql database. Id like to limit the number of entries it will save in that database to say, 100. I emailed the fella who wrote the script and he replied with: Just make a simple if the id is bigger than 100 or how many entries you want ... then just redirect to the index page. I dont know a whole lot about PHP although Im learning and this is what Im trying which isnt working. if ($id > 100){ echo "<meta http-equiv=refresh content=1; url=http://www.mysite.com/blah>"; }
Preventing Multiple Database Entries.
I am trying to make my form processor detect if an item name submitted to the database already exists I would like to display a message saying the item is already in the db. I tried something like this if ($Item_Name == "$row["Item_Name"]") { print "That item is already in the database"; } Now I know this is wrong but if someone could point me in the right direction it....
Don't Display Duplicate Database Entries?
I have a restaurants database that has a lot of restaurants listed with the same name in the same city with only the category changed. This is the code that I have that displays the list of restaurants. Can someone tell me what to add to it so that it will only display one of each restaurant of a certain name? PHP Code:
Output Database Entries In A Table
I'm trying to display the entries in a table of two columns, one entry per table cell - in other words, two entries per row, number of rows based on number of entries in the database. But it still doesn't seem to work. It displays one entry per row... I don't know where the problem is. Here's my code:
How Do I Display All Database Entries Between Two Dates
I have two dates in a form " startdate" and enddate" when i display the results i would like to show all results between, and including the two dates. how do i do this... this is my current query: My Variables: $userid = $_GET['idr']; $fromdate = $_GET['fromdate']; $todate = $_GET['todate']; The query: $result = mysql_query("SELECT date, status, time, notes FROM timeclock WHERE userid='".$userid."' ORDER BY time");
Add Entries To Array
What I want to achieve: A select list in a form should grow with every data entry. Example: I have a list of towns to choose from for a single entry. If there is a town, not in the list, I would like to have the option to enter one in a text field. Next time I approch the input form, the newly entered town shows up in the select list. What do I have to do, to expand the select list (resp. the table behind)?
Using Checkboxes To Update Multiple Database Entries
I have a query that shows a list of options that a user can toggle on or off using a checkbox. query... form... while($row = mysql_fetch_array($result))... <input name="menu_show_attribute[]" type="checkbox" class="checkbox"'); if ($row['menu_show_attribute'] == 1) { echo (' value="'.$row[menu_id].'" checked /> } else { echo (' value="'.$row[menu_id].'" />'); } The list is generated from boolean values in a DB. This populates my form with checkboxes, some are checked and others are not. I'm using an if statement to sort it (checked). This works fine. The problem is when the user un-checks a checkbox, the value does not get passed and the DB does not update - set/change it to 0. The only values that get passed are the checkboxes that are checked. Below is the query / code after the submit button has been pressed. Are radio buttons the answer? Any help / suggestions would be very much appreciated. //process form for ($i = 0; $i < count($menu_show_attribute); $i++) { if (isset($menu_id) == 'checked') { $menu_show_attribute = 1; } elseif ($menu_show_attribute != 'checked') { $menu_show_attribute = 0; } $query = 'UPDATE menu SET menu_show_attribute = "'. $menu_show_attribute.'" WHERE menu_id = "'. $menu_show_attribute[$i].'"' echo("<br>"); echo $query; $result = mysql_query($query, $db) or die(mysql_error()); }
Duplicated Entries In Array
I have an array. I need to check if key (key => value) is being duplicated... I've already checked all values not to be duplicated and found out they are.. I am trying to make script which would print me which key is being duplicated.
Deleting Duplicate Entries From MySQL Database Table
The topic is related to MySQL database. Suppose a table "address" contains the following records ------------------------------------------------------- | name | address | phone | ------------------------------------------------------- | mr x | 8th lane | 124364 | | mr x | 6th lane | 435783 | | mrs x | 6th lane | 435783 | | mr x | 8th lane | 124364 | ------------------------------------------------------- Quote:
Deleting Blank Entries From Array?
The resulting arrays that i get from my select statements always seem to have some blank entries, in addition to the correct ones. It is rather odd, is there any way i can scan through it and delete these blank entries? Here is the print_r of the arrays. PHP Code:
Sort Results By Date/time, Limit 5 Database Entries Of Today &/or Upcoming Days
I'm designing a website for my fraternity and in the database I have entries which contain past events, todays events, and upcoming events. My problem is that I can not figure out how to sort the query results to display: 1) only past events based on the CURRENT DATE 2) only the events which fall on the CURRENT DATE or after, limiting the results to 5 entries 3) all events that fall on CURRENT DATE or afterwards Example: Today is September 15, 2007 Problem 1) Displaying all events that happened before September 15, 2007 Problem 2) Displaying only 5 results that fall on September 15, 2007 or after Problem 3) Displaying all events that are happening on or after September 15, 2007 And obviously I would like the CURRENT DATE to change depending on what date it is, currently. Ok so now I've been very redundant in my explanation of my problem here is the code and a link to what that particular page looks like. Code:
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:
Building An Array From A Database
Just a quick questions. I'm retrieving two fields from a database one being "id" and the other "name". I am currently using this to load the results $i=0; while($row = $db->fetchArray($results)) { nameArray[$i] = $row; $i++; Which fetches the results by Association and gives me these results: Array ( [0] => Array ( [id] => id1 [name] => FirstName ) [1] => Array ( [id] => id2 [name] => SecondName ) ) is there some way to modify the code so I get this result: Array ( [id1] => FirstName [id2] => SecondName ) It seeem like it should be possible but I just can't seem to work it out.
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?
Pulling Database Value In To Array
How do I pull information from one of the fields in my database and put this into an array. The information in the field is stored as follows with a comma between each number 1342,1873 I need to get these numbers in to the array, then after this I can pass each value and check this against another table in my database. I tried $arr=array($row['numbers']); and of course it did not work. I need it so when pulled from the database it formats like below $arr=array("1342","1873"); foreach ($arr as $value) { // rest of code // }
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:
Putting Content From Database Into Array
I have a problem with the following code, what i try to reach is that i want to compare a value with a value out of the database and if equal then display that else display that. The problem is that i can't put the content from a database row into an array, the following: PHP Code:
Create Array From 2 Database Fields
I want to create an array of product prices, with the product id as the index and the product price as the value, so i can place the prices for particular products wherever i want on my page. Both product id and price are taken from the Products table SELECT prod_id, prod_price FROM Products Due to the client wanting an unusual layout, I cant just loop a table with the data, I need to be able to print $Price[2]; (for product id 2) wherever I like, for example.
Fastest Way To Do Database / Array Search
I am trying to write a script that allows users to search through a database of names. But rather than give a search string and then return all those that match, I would like it to search each time the user types a new letter in the text box. That's badly explained - this example might help! The user types "r" and I displays all the names with r in them. The user continues and types "i" so the textbox shows "ri" and displayed are all the results with "ri" in them. I as doing currently this by re-querying the SQL database where the names are hosted but it takes too long to query, return and refresh the page. What would be a better way of storing this database info to allow a faster search? Maybe load it into a PHP array first (stored in another file) and search within that? (Can you do 'clever' searches in PHP?) Or into a javascript array? The list could be upwards of 1000 names. The databse shouldn't change that often so I could have a script that updates the array every 24 hours or every time a new name is added.
To Insert Array Value In Database---important
ihad an array in php and iwant to insert its value in database the coding is: <?php $nv_pairs = explode('&',$query_string); $array[50]; list ($name, $value) = explode ('=',$nv_pairs); $i = 0; foreach($nv_pairs as $array[$i]) { $array[$i]= preg_replace('/\%0d%0a+/',"<br> ; ; ; ; ; ; ",$array[$i]); $array[$i]= urldecode ($array[$i]); $array[$i]= preg_replace('/d*=/', " ",$array[$i]); $array[$i]= urldecode ($array[$i]); $i++; } ksort($array); while(list($key,$value)=each($array)) { if (preg_match("/d+/",$value)) { echo "<br> <b>$value</b>"; } else { echo " <b>$value</b>"; } } ?>
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.
Looping Database Values To Create An Array
I have a fairly simple php code problem I think, I want to loop values from a mysql database within an array to fill the array. I'v never done this before so your help would be valued if someone had the time. *denotes where I want to use database values*
Update Database With Textbox Array W/ PEAR
I am having slight problems with trying to get my page to work properly. Right now i have a form which displays the information of the rows in the database through textboxes. I have two textbox arrays: name[] and price[]. first i connect to database... if form was submitted it goes through this code:
Checking If A Value Is Not In An Array And Deleting Record From Database
I have been trying to figure this one out and have come up against a brick wall although I know it should be relatively simple. I have a form that passes an array to a php script from a multiple select box that is created dynamically. If a user deselects an item then I want to delete the record from the database but am having a big problem with it. The table in the dbase is quite simple with just three fields: id classid formid Basically, the form send through a classid and a formid value and I want to delete any records that have a classid that are not in the form array and have a formid which is passed as a hidden value. I suppose really what I want is to know how to see if a classid is not in the array that is passed.
Retrieving (Data + Fieldnames) From Database To Array?
I'd like to poll a database and get the table contents, as well as the field names from that table. I've been to php.net but this time I cannot find something helpful. I can get the data, and retrieve it into an array noproblem. [1] I can get the data+fieldnames and put it into a list. [2] But I cannot seem to be able to fill an array with the data *and* the fieldnames. If you check both chunks of code, you will se what I'm doing....
Gettting Data From Database The Splitting Up Then Using An Array
in my database i have information like w_2 and i_1. The letter is reference to another table name which I need to use an array for and the number is refernce to an id. So what I need is for when I get the data for it to be split into the letter and the number separately and then put the letter into an array to get the table name. Code:
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?
Deleting Database Rows From An Array Of Variables
I have a form with a list of checkboxes, which are each filled with a date in the format 27012007, for example. The name of each of the checkboxes is the same as the date. Basically when the user presses the submit button I would like all rows in the database table "users" with the corresponding column "date" to be deleted when the form variables date correspond to those in the "date" rows. I think all the checked dates might also need to be put into an array. Would anyone know how to do this?
Putting An Array In A Mysql Database Table Field
I want to insert an array into my database but i've got a problem with it. Before i insert the array into the dbase i check if everything is in the array with print_r($array). Everything that should be in the array is in there so i insert it into the dbase. When i check my dbase with phpmyadmin the field that should contain my array has the word array in it so i assume the array is in the dbase. But when i retrieve the data from my dbase and check my array with print_r i get the following error: Warning: Argument to array_values() should be an array in.
Address Element Of The Array Formed By Query To Database
I am making a function wherein if a query is passed it returns the result set cursor. Now before I return the cursor, I would like to process each element of the array. How do I address each element of the array, considering the field names are as per the query and not known. The function is function useforquerytodb($thequery){ global $PHP_SELF, $DATABASE; return mysql_db_query($DATABASE,$thequery);}
Limit The Entries
How can I limit the number of entries into the database, so after the limit is reached a text like "sorry limit is reached" is displayed, if the limit is not reached a form is displayed.
Duplicate Entries
I am currently using the form below for people to enter data into mysql, at the moment this has no methed of checking to see if the data they enter already exists, can anyone provide help as to how to this? PHP Code:
Approval Of Entries
I'm designing my first PHP and MYSQL application. It is going to be a database of singing groups. I'm going to allow individuals to enter thier groups info into the database. However, I'd like to be able to set up an admin screen that would allow me to approve each entry first before it can be viewed. As well as let me do some other admin functions, such as edit records, delete records. Any suggestions?
File Entries
I want to open a local file and add lines of text to the top of it, before any previous text in the file. How?
Duplicate SQL Entries
I have a buddy system on my site and I have found that duplicate buddies can be added into the database. Here how I have this set up: user 1 want to add user 2 as a buddy. user 1 goes to user 2's page and clicks "add as buddy" A PM goes to user 2 and asks him if he accepts or declines if user 2 clicks accept a php script is run Problem: This script need to detect if that buddy already exists, if so do nothing or overwrite the original. Right now it just adds the entry again. I am using a very simple table: UID BID --------- 1 | 2 This would mean user id 1 has a buddy with a buddy id 2 Here is the non-functional code: $query = mysql_query("UPDATE buddies SET uid='$uid', bid='$bid' WHERE uid='$uid' && bid='$bid'"); print "Buddy Has been overwritten"; //would prefer it not do anything at all if entry exists if ($query == 0) { // No records updated, so add it $query = mysql_query("INSERT INTO buddies (uid, bid) VALUES ('$uid', '$bid')"); print "Buddy Added";}
Deleting Entries From Mysql
I have business listings that I have pulled from a database(MySQL) and printed to the page, in an admin page, for review. I'm trying to write a script to add and one to delete the listing. I get an SQL error, 'check the manual for blah blah near " on line 1' Here is the 'delete script:
Displaying Entries In Rows Instead Of On Top Of Each Other
I'm altering a voting script for our dog rescue so that we can hold an online photo contest. I'm very new to php & mysql..kinda just muddling my way about with this. I want to display the entries in a row across about 4 or 5 photos and then keep it going that way, but I haven't a clue as to how to do this....
Multiple Blank Entries?
When I go to my secondary page of results after I fill info out on a form on the first, I get 3 blank entries automatically inserted into the mysql tables. This second form has these blank entries printing up each time even if I go in to the second page w/o filling out any info on the first. Is there a way I could prevent these blank entries from being automatically entered? Like some code that says that if something is blank then not to have it entered into the tables? or something easier?
|