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




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:




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
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.

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?

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?

Array From Database Entries
All I need is to create an array with the results from a database column.

(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");

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());
}

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:

Print Database
I'm sure someone somewhere has made one but I can't find a script for it.  I'm looking for a script that will take all of my database and print the database tables, columns and values into an HTML table.

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:

Print Output Based On Database Result
What I am trying to do is print out an existing text file based on what is in my database.

I want to show/print the contents of text1.inc (which is located in my includes directory) if the database contains query shows it contains "yes" and I want to show/print the contents of text2.inc (which is located in my includes directory) if the database contains query shows it contains "no". Code:

Fastest MySQL Functions
i was wondering if anyone knows what the fastest mysql functions/libraries there are. i was reading that mysqli is up to 40x faster than mysql, but wasn't sure if i should use the object vers or just the function based ones.. also, if there's anything faster?

Fastest Way To Look For An Array Of Char?
If I have a string, (variable len), and I am looking for the first position
of one char in array starting from position 'x'

For example,

// the 'haystack'
$string = "PHP is great, php is ok";
// the needles
$char[] = 'P'
$char[] = 'r'
$char[] = 'k'

I would search the $string for the first $char starting from 3 and it would
return 7, (for 'g').

I could use many strpos(...) but that does not sound very efficient.
So what would be the fastest way to get the first position?

And, I am using PHP 4.x, not 5, (otherwise I guess I would use strpos(...)).

Fastest Way To Read URLs.
I would like to know what is fastest way to read contents of web page? I would like to know what possibilities are there. Currently with "file_get_contents()" reads around 10-13 pages in 30 seconds (Default max execution time). I know I can change max execution time so it can read more pages but I would like to find another way if it is possible...

Also I would like to know is it possible to print out the results while still loading page? Maybe it is browser(my settings), php setup or script fault so I'm not sure.

Fastest Way To Format MySQL DATETIME In PHP 5
You've got a MySQL DATETIME string that you pull out of the db as a variable.
Why? Because you're cool. And, because this DATETIME is so hot right now.

Our DATETIME looks like:

2007-10-13 03:47:05

But you want it to take off its clothes and get it to look like:

3:47:05
=================================================
What line(s) would you use on this skanky little DATETIME to get it how you want it? Its the speed that's key here, boys. We all know you can pull out and use a lame ass substring function. But we should all be above that by now.

What Is The *fastest* Method To Extract Directory From Url ?
given is string:

http://www.server.com/dir/dir2/dir3/file.html
or
myname@domain.com

and result should be:

http://www.server.com/dir/dir2/dir3/
or
myname@

how to make it *really fast* without strrev and strstr ?

Which Fetch Is The Fastest Mysql_fetch_ Array,assoc Or Another?
I think the title says it, but I'm wondering if i'm only using an associative key should i just use assoc or is the speed so minimal it don't matter?

Print Function Won't Print?
I have been using echo in PHP but I saw most examples use the print function so I tried it, but It wouldn't display anything on the page, I am trying this on a localhost. I used echo instead and it works...so I was just wondering what is it that I haven't setup that the print function isn't working.

This was the code i using:

session_start();
print($counter);
$counter++;
session_register("counter");

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

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

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?

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?

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?

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.

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

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.

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.

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?


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