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


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Database Delete Repeat Records And Add Up Totals


I have a database full of order records for our website. My goal is to delete people from the same 'address' field and add up the 'total' into one record. Can i get some example code on how this would be done?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Calculate Totals From Repeat Region
I need some help with calculating totals from a repeat region. Some times one number sometimes ten. How can this be done.

View Replies !
DELETE RECORDS - Database Adding New Records
iv got the database adding new records, and now I want it to display all of the records that are there buy name and id number, then i want u to be able to type in the id number of the customer u wish to delete and it shoudl delete it, sounds good buts its not actually deleting the record. it says it does, but its not doing it. Code:

View Replies !
Delete Multiple Records In The Same Database Querie?
I have some code that deletes records from the database, in a loop. However its prety inificient as it makes a seperate database call in every loop whcih is slow. PHP Code:

for ($i=0; $i<count($idarray); $i++)
          db_query("delete from clicks where id='$idarray[$i]'");

Is their a more efficient way of doing that? It is posible to delete multiple records in the same database querie?

View Replies !
Automatic Delete From MySQL Database Table Expired Records?
I have a question . . .

how can i delete from MySQL database table automatic expired records ?
?

One think is to make a service that deleting the expired records . . .

Any other method ?



View Replies !
Excluding Records From Repeat Region In PHP
PHP 4
MySQL 4.0.20
DW MW 2004 7.01

This problem is giving me a bit of a headache, and I'm getting nowhere
with it so thought I'd open it up to all, any help would be greatly
appreciated.

OVERVIEW
--------
I am creating an ecommerce site for an IT reseller. Customers must log
in to use the purchasing side of the site.

Individual customers that log in have certain products that they are
not allowed to see but this varies between users, so no two customer
may have the same hidden products.

To set this scenario up, I have a main table containing the whole range
of products the reseller sells, and a table referencing the hidden
products, consisting of a "User ID" column and a "Product ID" column.

In MySQL 4.1 I would have no problem running a subselect query and
pulling just allowed products into a recordset, unfortunately I am
running 4.0 which does not support this and I am not in a position to
upgrade the server.

I am currently getting around the problem by creating an 'Allowed
products' table rather thatn 'hidden' and listing "User ID" and
"Product ID" for all products they are allowed to view. This causes a
bit of a problem as the reseller has about 6500 purchasing customers
and 20000 products, so the 'allowed' table would grow incredibly huge,
thats 130,000,000 records if all are allowed!
----
The way I am planning to get around this problem is keep the 'Hidden'
table, create TWO recordsets on a page - one, rsFetchProducts, a
"SELECT * FROM Products" and the other, rsFetchHiddenProducts, "SELECT
Product_ID from HiddenProducts where User_ID = 'users id number'".

I then apply a repeat region to rsFetchProducts to list all data from
the recordset.

******************
What I need to do next is to filter this repeat region with PHP,
basically saying - if any of the Product_ID(s) in rsFetchProducts is
equal to any of the Product_ID(s) in rsFetchHiddenProducts, DON'T
include them in the repeat region.
******************

This must be possible, but by background on PHP isn't too great, I know
I need an if condition in the repeat region, but am not sure if I need
to filter directly from the recordset or pop it into an array first and
then filter.

View Replies !
Totals From Database
In my database, I have users who each have a certain amount of minutes logged. What I want to do is display the total amount of minutes everybody has logged collectively. Can someone help me with some code that will add all the minutes of each user together? The furthest I've got in selecting the minutes from the database table.

View Replies !
Records Won't Delete
mysql_query("DELETE FROM guestbook WHERE id = '$recnum'"); It works fine on my local server but it doesn't delete records on the remote server. any ideas?

View Replies !
DELETE Records
I am going to write a php script to delete some records based on values supplies by the user. I was just wondering if the query is correct but there are no records to delete for example if this query was executed but there was no testId 7, would an error occur or would the query be performed but just not delete any records? PHP Code:

$testId = 7;
$q="$q="DELETE  FROM test WHERE testId = $testId";
mysql_query($q, $link_id)or die(mysql_error());

View Replies !
Wants To Delete Old Records
I want to delete records that are more than 7 days old($keeptime). I am new to this and can't figure out the correct code. The table is called 'x4tables' and the field 'tdate' is a timestamp. I have used: Code:

View Replies !
Delete Records Since A Week
I've been trying to delete records since a week and i'm not able to do it. Before with this script, i was doing so many things at a time and i was confused.But, now, i just displaying the records from a table N trying to delete them.Would somebody pls guide me.

I just wanna set the delete flag(i.e, i want to set the RBS_DELETE column to Y or something) when i check a check box to delete it. I've some 5 records displaying on my form and i want to check 3 of them and when i check them and hit submit, i want the RBS_DELETE column to have some value. PHP Code:

View Replies !
How Do You Delete Records From Mysql
Could someone please show me how to delete records from mysql. Maybe even an example in a loop that deletes records based on a criteria.

View Replies !
Delete Records From A Table
I have a table its called queue. It has a field called id. I want to delete all records in the table apart from the ones with id equals to 74 or 75 or 87. How do i do that?

View Replies !
Forms To Delete Records
I am trying to make a PHP script that displays all of the records from a database, then allows a user to edit or delete the records via a form. I need a checkbox beside the names and a text field with a number beside each name. Is there a way to make it delete all names with a check beside them and update all number that have been changed when the user clicks submit?

View Replies !
Delete Records From Table 1
I have a script that doesn't delete records from one database when it should, and now I have to do this myself because database is big and causes problems on the server. What I have is:

TABLE 1, field auction
TABLE 2, field id

so I would like to delete all records from TABLE 1 where the value of the field auction doesn't match the value of the field id in TABLE 2. Can someone help me on this, please? I need to get this database cleaned.

View Replies !
Delete Specific Records
On clients machine, currently to delete on trainee record it runs 10 queries to delete records from 10 tables. At the time of running all queries, server shows (104) Connection reset by peer. An error condition occurred while reading data from the network. I think it because of running 10 queries at a same time. Is there any possibility that through one line of query we can delete record from 10 tables. I've tried following query

DELETE FROM table1, table2, table3, table4, table5, table6, table7, table8, table9, table10 WHERE empID = 11;

But it gives ' error in query.

View Replies !
Delete All Records Starting In R
PHP Code:

$result2 = mysql_query ("DELETE FROM r_CompTables WHERE CompID = R??") or die("DELETE error: ".mysql_error());

I have this code but I want it to delete anything start in R. R will be followed with a number so it could be R5 or R91.

View Replies !
Delete Records Older Than 14 Days
Does anybody know how to make a script that automatically removes mySQL records older than 14 days?

View Replies !
Want To Delete The First Letter In A Column With 275 Records
table : product
column : code

in this column i have 279 records with bv. S1092734 i want to delete the first letter in all those records.

View Replies !
Delete Fixed Number Of Records
i have a table with one field. this field saves times as records. i want to there are 40 recoreds always. in other mean when inserts 41'st record then 1'st record be delete
how to delete fixed number of records at a time of first of my records asc (like select).
in other mean i want to like: delete from table order by time asc limit 0,1

View Replies !
Delete Selected Records From Table.
Can anyone see why this connection doesn't work? It's suppose to delete selected records from my table.

<?php

if (isset($_POST['delete'])) // && isset($_POST['delcus']))
{

foreach ($_POST['delcus'] as $val)
{
echo "$val";
$conn= mysql_connect( "localhost", "user", "password" );
$sql = mysql_select_db( "snow" );
$del = mysql_query("DELETE * FROM request WHERE qid =" .$val);
//$rows = mysql_num_rows($del);
$rs = mysql_query($conn, $sql, $del);
if($rs)
.........................

View Replies !
Multiple Delete From A List Of Records
If I have a list of records from a database on the screen, each with a check box beside them, how would I delete all the records that have been ticked? I assume I would use a variable similar to checked[], but not sure what syntax I would use to remove them from the database? Would I loop round each record comparing the checked[] value and it it's set, delete the record?

View Replies !
Do A DELETE Statement To Remove Any Records That Don`t Match.
I`m just trying to figure out the best method to delete my records and wondered if it was possible to do a DELETE statement to remove any records that don`t match. Here is my code so far:

$Query="select blah its huge:-)";
$RESULT=mysql_query($Query);
$my_rows=mysql_num_rows($RESULT);

for ($a=0; $a<$my_rows; $a++){
mysql_data_seek($RESULT, $a);
$Array = mysql_fetch_array($RESULT);
printf("%s<BR>", $Array['Email']);}

My Query returns Matched Records, what I would like to achieve is deletion of the records that didn`t match, would it be possible to do that under the printf statement. So delete all the records in the table that don`t match up to $Array['Email']??

View Replies !
Delete Option From My View Records Page
I have a list of things I need to do with my database - but this is my next hurdle - the delete query within my view records page. I want to be able to click on a button or link to delete a record in a table. I was envisaging that each record would have a delete button or link next to it and clicking that would remove it. Here is the script I have created to view "Devices": PHP Code:

View Replies !
Delete Records And Files In 1 Statement At Same Time?
How can i delete records and files in 1 statement at same time?

View Replies !
Auto Delete The Old Records But What If Server Clock Was Set Up Wrong In Maintenance?
I want auto delete any events that the event date is at least 1 day older than current date. No problem for the php programming. get the current data (server clock), check the events date and delete the old records. My problem is that for some very rare cases.

Say if for extrem cases I have 1000 new events saved in database. But somehow, I or the the hosting company do the server maintenance, and reset the time clock of the server, in case in the maintenace, the server time clock was set up wrong say 2005, was set up as 2006. Code:

View Replies !
Delete From Database
I have code that does not delete from a database. The same code (cut an
paste in the same file, but different function and having a different query)
works. So, of course, I tested the query interactively. I echoed the query
and did a cut and paste when interactively connect to the database. That
one worked so it isn't the query since interactively it is seeing exactly
the same thing as the code produces.

Here is the code:

function deleteCatalog($catalog) {
$query = "DELETE FROM CatalogNames WHERE sCatalogID='" . $catalog . "'";
mssql_select_db($database_Login, $_SESSION['Login']);
$result = mssql_query($query, $Login);
...
}

The $query echos:
DELETE FROM CatalogNames WHERE sCatalogID='CMP'

As an example of code that works (in the same file)
function addToCatalog($cat_id, $cat_name) {
$query = "INSERT INTO CatalogNames (sCatalogID, sCatalogName) " .
"VALUES ('" . $cat_id . "', '" . $cat_name . "')";
mssql_select_db($database_Login, $_SESSION['Login']);
$result = mssql_query($query, $_SESSION['Login']);
...
}

The second and third lines are identical (cut and pasted) as in other places
in the same code. In fact, it is only in this file that I do all the
database work. Every other function works. This is the only delete,
however.

View Replies !
Delete Database
using php and mysql how can i tell the my website to move any entry older than 30 days to a different table and then delete it below i have some script i did try but this doesnt work (im using unix timestamp incase that changes anything)

mysql_query("
INSERT INTO newsarchive (id, postdate, title, newstext)
SELECT id, postdate, title, newstext FROM news WHERE postdate < DATE_SUB(curdate(), INTERVAL 30 DAY)");

mysql_query("DELETE FROM news WHERE postdate < DATE_SUB(curdate(), INTERVAL 30 DAY)");

mysql_close($link); //clean up

View Replies !
What To Do If There Are No Records In The Database
I am pulling data from the database and displaying it using the code below:

$db = mysql_connect("localhost", "root");

mysql_select_db("pyramid",$db);

$result = mysql_query("SELECT * FROM table where area='Wales'",$db);

while ($myrow = mysql_fetch_row($result)) {

echo "blah blah";

}
?>

What do I do if there are no records? At the moment it just doesn't display anything. How do I get it to display a message saying there are no records?

View Replies !
Why The Totals Don't Add Up?
Can anyone tell me why the totals don't add up? PHP Code:

View Replies !
Recursive Database Delete
I have two tables in my database, one for the folders, where each folder has a parent id and an id itself, and one for the files where each file has a parent id for the folder its in. Now If the user deletes a folder, every file and folder within it, no matter how many there are, should be deleted. Can anyone give me the idea?

View Replies !
Delete Item From Database
I still can't figure out how to delete an item from my shoppingcart. I have tried different ways to do this, but its impossible.

-a button or link that deletes a item from my database
-the php script that deletes it

here is a suggestion:

$slett = "DELETE ID, VARE, MODELL, STR, ANTALL, PRIS,
TOTALPRIS FROM USER_TRACK
WHERE USER_ID = "$user_id"";

But how can i assign this to a button?

View Replies !
Delete Row In Database By A Selectbox?
I'm having a world of trouble with this. I have a selectbox of names....when they selectone and hit delete I want it to delete it from the database. I dont think i'm getting any value from the select box. Here is the code I have : PHP Code:

View Replies !
Delete A Row From A Database Table
I'm trying to delete a row from a database table.  I've made a connection yet it's not working.  Is there something wrong with the following code?

mysql_query("DELETE * from  `contactinfo` WHERE Submission_Number = 1 ");

View Replies !
How To Delete MySQL Database.
I've got three hostings with the GoDaddy hosting service. The hostings are supposed to provide only one MySQL database each. I've just recently noticed in the phpMyAdmin program that separate databases, each with the name "test," has appeared in two of the three hostings.

I don't know how they got there. I didn't put them there. I contacted GoDaddy's technical support. They said that the "test" databases automatically comes with the phpMyAdmin program. Of course, that's not right. Anyway they said that I could delete the extra database without damaging anything.

View Replies !
Delete Data From Database
Let's say i have two tables,

table_one;
userid,userinput,indexno

table_two;
cond,qant,amp,indexno

the indexno in table_one and table_two are the same.if i choose to delete one row of data in table_one,i want the data with the same indexno in table_two be deleted as well.
how can i achieve this?

View Replies !
Update Certain Records In Database
I would like to update certain records in database so they are all written in lowercase....i have tried with it but doesn't work:

<?php
$db = mysql_connect("$host", "$user");
mysql_select_db("albums",$db);
$result = mysql_query("SELECT * FROM albums",$db);
while ($myrow = mysql_fetch_row($result)) {
$al_artist = strtolower($myrow[1]);
$al_name = strtolower($myrow[2]);
$site = strtolower($myrow[4]);
$sql = "UPDATE albums SET al_artist='$al_artist', al_name='$al_name' site='$site' WHERE id='$myrow[0]'";
$query = mysql_query($sql);
}
mysql_close($db)
?>

View Replies !
Deleting Records From Database
I have another question about record deletion from
database.

For example, my database has 10 records with ids 1
through 10. If I delete id #10 then everything is good
and all the records are still 1 through 9. However, if
I delete record id #4, then in my db I would have
records 1 through 10 with id #4 missing.

Is there a command that syncs the database? How do I
go about this to keep all the ids in the right order
after the deletion? or What do I need to do to prevent
that from happenning?

View Replies !
Insering Records Into Database
I am trying to insert some records through a form into my database(INTERBASE).I have test1.php where i have two include files, namely:connection.ini and aim.ini
In connection.ini, i have the db connection details and aim.ini, i have the form fields and the sql statements.Now, when i run my program, i am able to see the output, but, they are not inserted into my db.could some body please figure it out. Code:


View Replies !
Retrieve Last Ten Records From The Database
using LIMIT I know how to easily retrieve the first 10 records from the database. But is there an easy way to retrieve the LAST 10 records  from the database? e.g

$sql = "SELECT * FROM employees";

How would i retrieve the last 10 records.

View Replies !
Wont Add Records To My Database
can u check my codes and tell me whats wrong because for some reason it wont add records to my database, im using phpadmin v4.23 here are my codes

<htmL>
<body>
<form action="insert.php" method="post">
First Name: <input type="text" name="first"><br>
<input type="Submit">
</form>
</body>
</html>

here are my php codes

<?
$username="root";
$password="";
$database="trial";

$first=$_POST['first'];


mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
....

View Replies !
Database Records Query
Can anyone help me with the following mySQL code. Probably a simply solution but i cant find the answer anywhere. I have a table called news full of articles each one has an associated news_id. What i need to do is query the database and pull out the last article. Then i want to pull out the second to last article and finally the third to last article.

View Replies !
Show All Records From Database
How to show all records from database. (i mean row by row).for my code, i can only show the last record.

$query = "SELECT * FROM tblpatient";
$result = mysql_query($query);
$row = mysql_fetch_assoc($result);
while ($row = mysql_fetch_assoc($result)){
echo $row['Name'];
echo '<br/>'
echo $row['Address'];
}

View Replies !
Batch Add Records To Database
I would like to create an option on my admin page to add batch records to Mysql database.

I guess I need a textarea, a field limiter and a line break :)

After the form has been submitted, the script should parse the data into arrays and add each array value to the database, most probably with a loop.

Can someone help me here? Example:

books

title | year | author

And what if I want to upload and insert CSV format (without phpmyadmin)?

View Replies !
Monthly Totals
I have a table with some records. Only one record per day, but maybe none or lots per month. The values entered are valid for every day from the date of record to next record or today. The user enters a date, And i need two totals: the total for just the chosen month, and the balance (total of all records upto the chosen month). Code:

View Replies !
Totals In A Sql-table
I have a mysql table which stores points of users from a competition. I can
display the table with php, you see which user has points and how much, the
one with the highest points stands on one (off course).

But, I want to display the total amount of points of all users together form
the table standm in the column pts.

I really don't know how to get the total value of all values together. My
first idea is to do something with count, but this only counts the rows.

View Replies !
How Do I Get Totals From A Field?
I am building a simple income and expenditure app for myself, with seperate tables for income and

expenditure. The income table looks like the following:
id INT AUTO_INCREMENT PRIMARY KEY,
date DATE,
income1 INT(10) NULL,
icome2 INT(10) NULL,
income3 INT(10) NULL,
income4 INT(10) NULL,
etc

What has stumped me is how to extract all the entries and get totals of each field?

I want to be able to extract and view totals for each field (eg total_for_field1,

total_for_field2, etc) and then add them all to give me the total for all. One option I had was to automatically increment the current amount with the new entry, but I would like to be able to later trace each entry.

View Replies !
Get Totals For Query
I have a table called call_event. The call_events table has colum called Time_taken. Data in this colum is stored as a decimal vaulue. EG. 4hrs and 15 minutest would be stored as 4.25.

I would like to be able to do a mysql query which give a total of all the returned values from a query but Im not quite sure what syntax I need.

The query I would like to do is to find out the the total time for a call.

I would imagen the query would be somthing like this

Query = SELECT Time_Taken FROM call_event WHERE call_id ="$call_ID";

When running this query it will return all the times_taken which have the call_id field = to $call_ID.

eg 4.5, 3.25 0.00 5.0

However what do I need to do get the total for all these values eg 4.5 + 3.25 + 0.00 + 5.00 = 12.75 I want to be do a query that will return the value of all the time_Taken added up for example in this case I wanted the query to return 12.75

Is this possible with just a query or do I need to do somthing funky with php to add up all the returned values?

View Replies !
Mark A Row In My Mysql Database As To Be Delete
Is there a way in php that I can mark a row in my mysql database and then later so delete these rows that have been marked?

View Replies !
Database Auto Count What About Delete?
I have a table that give a unique ID to certain Articles.
To give the ID i simply use the Auto count of the DB.

But what happens when i delete a record? i am now missing an ID.
How can i insert a row and give it the first available number?

For example ID 1, 2, 4, 5, 6

i would Insert and set the ID number to 3.

View Replies !
Delete Data From MySQL Database
I am new to PHP and MySQL but I have setup a MySQL database. I can view the information in an HTML table using PHP scripts and can delete an entry form the database table, but what i need to do is to be able to delete an entry by selecting a radio button next to the relevent information however when i try to add a form in the PHP script i get an error.

View Replies !
How To Delete Multiple Entries From Database?
I ran this script Im working on twice by accident which caused a ton of duplicate entries. I dont want to start over so how would I delete multiple entries in a database?

View Replies !

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