Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




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)?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Array From Database Entries
All I need is to create an array with the results from a database column.

PHP Array Entries Max Limit
I would like to know how many entries does PHP associative array can handle.

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 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:

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";}

Getting Total Number Of Entries
Hello, Im trying to retrieve and echo the total amount of cars in the database with PHP Code:

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?

Deleting Entries In A Database
I've got the reading and writing to a database working but want to delete entries ..... how would this be done?

Selecting Duplicate Entries
I'm having the following problem: Let's assume I have a table with 3 fields: ID (type int), NAME(type varchar), EMAIL (type varchar) in a mysql db. The fields have the following data stored:

1, jack, jack@jack.com
2, tom, jack@jack.com
3, jack, jack@jack.com
.
2000, jack, jack@jack.com

Now let's say I have like some thousand entries like that one above with each one containing different data. So if there are entries which have the same email adress, how I can I select exclusively those entries with the duplicate data in it? So the result of a selection should look something like this: (If I want to show the selection results in html): PHP Code:

Multiple Entries For Same User?
I am creating this form, and instead of having a huge list of input boxes for visitors to fill out, I am wondering if it is possible to have the user click on add another button, and a new submittion will be added to that persons file.

Removing File Entries
I am using php3 and someone told me that php3 does not support foreach. In that matter, how would i go about grabbing lines from a file, iterating through all the entries and only delete the one that matches a string. I was thinking of a for() statement but I do not know what the php equivalent of perl's splice() is?

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?

Ignoring Duplicate Entries
I have this samll piece of code that gets the last 5 post from a forum and presents them on the home page. But i am not sure how to prevent duplicate entries from appearing on it. PHP Code:

Retaining Checkbox Entries
I have a table with entries that are ever increasing and each one has an ID number and I want to be able to associate any of those ID numbers to a file, so I created a pages that shows the ID numbers, 100 at a time. Seeing that there are over 800 entries, I have paginated the results and give the user the ability to move back and forward thru the entries to check off which of the IDs they want to use.

However, if IDs on the first page are checked and then the user moves to the second page to check some more, if they go back to the first page, the IDs are unchecked.

- how to keep track and display which of the IDs were checked and
- how to send the information of which ones were chosen to the next step of the process for adding to the table.

Stop Repeat Entries
Can you stop pulling out exactly the same data from a database, for
example, if you had 2 entries which had the name Chris,

Deleting Entries In The Address Bar
I am sick and tired of looking at all that clutter that automatically pops up on my address bar, how do i get rid of all those enteries?

(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:

Some Form Entries Cause SQL Error
Some members on my site have been getting SQL errors from entries if they use any special characters (' " , etc). For sake of example, say $entry is a variable declared to hold the value of an entry. How can I adjust $entry so that any special characters will be put into the database correctly without error.

Get All Entries From Today (mysql)
I currently have a page that each time a user visits it, the pageid and timestamp is thrown into a mysql daabase.

so the database looks like so:
linkid time
3 2007-08-22 17:26:21
3 2007-08-20 17:26:21
3 2007-08-22 18:36:59
2 2007-08-22 18:37:21

What i need is for php to show the total amount of visits today as per a certain time zone (or if thats not possible, the past 24 hours)

soo..
Search for all occurrences where linkid = 3 today for a specific timezone (or 24 hours)

MORE SPECIFICALLY
User 1: Lives in New York (EST -5)
registers for my site and sends visitors to his linkid (3)

After two days, this is what the mysql table looks like:
linkid time
3 -=- 2007-08-22 17:26:21
3 -=- 2007-08-20 17:26:21
3 -=- 2007-08-22 18:36:59

But mysql time isn't Eastern time, its another timezone. So when a visitor comes to user1's page at 3pm EST, mysql registers the time as 2007-08-22 17:26:21

So... I want to first add/subtract the number of numbers in the mysql database depending upon the user, and then see the amount of visitors for the day.

Determine Number Of Entries
I have a form in which the user can add more textboxes as need be:
Ing1
Ing2
Ing3
....

There could be 1 input or there could be 30... How can I, in php, determine the number of input controls so that I can then loop through them one by one and process their data?

How Do You Delete Entries From ODBC
i have an Access Database that i can read and write to no problems
however, when i try to delete an entry it all seems to run with no
error but the record never deletes!!!!!  The '$_POST[id]' is from a previous page. Code:

Select Todays Entries
How do I select entries that have been submitted today in sql.

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>";
}

Allow Users To Update Only Their Own Entries
I have three forms in my database, when each form is submitted the current username is automatically entered into the database, and I want the user to be able to edit only their entries. Everybody can view the entries but only them can update it.

How To Remove Entries In A DB That Are A Week Old?
I ahve a social network and I have a bulletin system, taht allows users to post bulletins that all their friedns can read... well anway, i dont want the bulletin to just sit there and take up DB space, how would i go about removing "bulletins" that are over a week old?

Show Older Entries
I have a MySql table with the field "sentdate". How could I set up a query that selects only entries that have a sentdate that is for example 30 days old?

MYSQL Entries Won't Update
I am trying to update some entries in a mysql database that will append the filename to the end of a thumbnail directory entry. So for example /images/thumb/ would become /images/thumb/12345.jpg.

I am stumped because the below code gives no php or mysql errors but the entries are not updated in the mysql db! Code:

Multi Entries Update To Mysql
Could someone help me to figure out how to upgrade multi entries to Mysql by using PHP?

Say, I have a table on Mysql

id Priority
1 Okay
2 wait
3 later
4 asap
5 hold

Now I want to upgrade that table to:

id priority
1 hold
2 asap
3 okay
4 wait
5 later

Is it possible to upgrade multi entries with one submitt button? If yes, could you tell me how it could be done.

I knew I could do it by each entry (submitt button).

Update priority set priority='$priority' where id = '$id'

Changing Apache Log/Environment Entries
I have a question which I'll try to convey as best as I can. I want to change the referer variable so when I do a:

header("Location: $location");

the log files on the resulting location have the information in the referer environment variable that I have set, not what was originally in that referer variable.

Here's an example.

How Do I Control Text Box Pre-Filled Entries
Can someone tell me how to control whether or not a text box is automatically pre-filled. In other words, on some web sites, when you visit them, the username and password automatically fills itself. But on other web sites you have to fill in the username and password each time you visit them.

There is one web site, Yahoo! dot com, where the username and password text boxes are never pre-filled. I have to type in my username and password for Yahoo! dot com each time I restart my browser. It didn't used to be that way. Yahoo!'s web site used to automatically pre-fill the username and password text boxes.

The web site that I'm working on uses cookies. I suppose that I could put a cookie $Name variable in a text box - but there may be a better way of doing it, though.

Preventing Duplicate Form Entries
I have an HTML generated php form which when submitted enters the contents into an SQL database. The problem is that once the user enters their information and the page returns to tell them their submission was successful, if they hit reload/refresh a second submission is entered and this could go on forever unless I include some kind of code which prevents this. I have thought about using the refresh meta tag but really want to exercise my options before I do that.

Selecting 4 Random MySQL DB Entries?
I have a table set up in my MySQL database called 'features'. This table has 10 entries, but I only want to select 4 random rows and display them out in tables.

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:

Multiple Entries In On Column/List Box
I'm creating a page where members can edit their research information. I'm going to have 12 List Boxes, each with about 20-25 words. I want the user to be able to choose as many as they need (by control+click) - and store them all in the database. I expect each member to only have about 4-5 .. but you never know.

The information they submit, all 4 or 5 or however many keywords, will need to be easily searchable on the main page. I also am going to need to make it easy for them to edit/update their keywords. My question is - which is the best way to do this? Do I dumb all the selected values into one column of a table? then when doing a search just do a text search?

And how do I implement the update page? I know how to show previous text in a text form field, but is there a way the options they chose can be pre-selected when they go to update their research?

Limiting User Mysql Entries
I have a script i'm making which is going to be used to search for reciprocal links on different sites and I have user levels such as free, paid, ect... I want to make it so that if the person signs up as a free user they can only add like 2-3 domains to be searched for their links. How would I limit the number of domains allowed to be searched? Would I limit the number of mysql entries allowed in the table for the domains?

How To Return A Random Set Of DB Entries Without Repetition?
i have a sql database with three fields: id, text, category how would i pull a random set of entries without repeated instances and print them in php? example: user has chosen two categories: art, design. user has also chosen to draw 25 entries. I need a script that will return 25 random entries that are in either category art or design without returning the same entry twice.

Editing Datase Entries Via A Form
How would I go about editing a row in a database via a form? I know how to get the information in the text boxes. But what i would like to do is list all the rows in the database and then if i see that one of the rows needs editing or deleting i'll have 2 links under each entry (edit and delete)...and when i click "edit" it would open up a new page with a form with all the info in each text box so i can edit and then re-submit it...

Fastest Way To Print All Database Entries?
Say I have a database with 1000 entries. What's the fastest, dirtiest way to do that.. Like this? PHP Code:

Populating Dropdown With Mysql Entries
I would like to create a combobox in Flash which is populated with mysql data and programmed with php. For example: There are 3 entries in database .ie. apple, bannana, peach. Now these I want in combobox in Flash MX/flash5.

Remove Duplicate Entries From TXT File ?
Is it possible to use PHP to open/read a TXT file (i.e. IP.TXT) that
contains ip addresses (1 per line), remove any duplicates found, and
re-write the file back out to IP_NEW.TXT ?

The reason is, I have ips coming from several sources, i.e. URLSCAN logs,
MySQL dbs, etc. and I can use a DISTINCT on the individual queries, but I
then combine all the results into 1 file which may contain duplicates.

Delete Entries 1 Week Old Or Older.
I have a query that's supposed to remove bulletin entries that are a week old and over, but its not working, and the "date" column is filled with "time();"

<?php mysql_query("DELETE FROM `bulletins` WHERE `date` > (time() + (3600*24*7))");?>


Copyright © 2005-08 www.BigResource.com, All rights reserved