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 Complete Forum Thread with Replies
Related Forum Messages:
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 !
Finding Only Records That Don't Match
I have a MySQL query that is supposed to pull records from a 'links' database. In the website, users can vote on links so I register a vote in a vote table with a link id and a user id. I need a way to pull all links that do not have a matching record in the vote table that has a specific user_id. Code: SELECT * FROM links, votes WHERE votes.link_id = links.id AND votes.user_id != 1 The problem is that there may be several records in the vote table for a single link_id. If user 1 has voted on link 800, and so has user 2, then this query will still pull link 800 because it finds a record in votes where the user_id is not 1. How can I change it so that NO records from the links table are pulled if the votes table has a record for the link_id and the user_id? If user 1 has voted on link 800 then I want to completely ignore link 800. If user 1 has not voted on 800 then I want to pull link 800.
View Replies !
Delete Column Names On A Match
I have a table with attributes like this: catA_totals catA_averages catA_median catB_totals catB_averages catB_median catC_totals catC_averages catC_median catD_totals catD_averages catD_median .... etc and I decide I no longer want to have the median tables, how can I select all these tables and drop them... something like drop *._medians or something like that. I saw the alter table can use multiple drops, but only when all the column names are explicitly typed.
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 !
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 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 !
Delete Statement Problem
I am using a simple delete statement in my php script (below) $q = "DELETE FROM commenttype WHERE TypeID=".$_POST['selectcat']; the problem is it doesnt delete the whole row it only deletes the text in one of the fields of the row. Has anyone else had a similar problem? It works when I run the sql directly from a program such as mysqlphp
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 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 !
Updated SQL Statement Returns No Records
I am writing a forum style log using MySQL as my databse I have written the following query which worked successfully: [SQL] SELECT a.buildnumber, a.entered_by, a.date, b.Description as primdesc, c.Description as secdesc, a.notes, a.resolved as status FROM tbl_fault_log as a, tbl_primary_fault as b, tbl_secondary_fault as c where (a.primary_fault_id = b.id) and (a.secondary_fault_id = c.id) ORDER BY a.id ASC; [/sql] the table tbl_fault_log has a field history_id which links to tbl_history where all other history records for each record in tbl_fault_log are kept. I want to amend the above query to include a count of history records in tbl_history for each record in tbl_fault_log. Code:
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 !
Match Array Key To Query Match
I have an array that I output through a loop. It's a list of states. Now I need to run a query ona table and if I find any results associated with this state in db mark this table with, say <strong>State</strong> tags. Having difficulties figuring it out. I'd hate to run a query 50 times to get the results. There's gotta be a better way.
View Replies !
Preg Match To Match A Url
Trying to use preg_match to match the following form http://www.example.com/user-45...what am i doing wrong? preg_match("/^http[://]+[www]+.[a-z0-9-_]+.[a-z.]{2,6}+[/a-z0-9-_]$/i",$_POST['url'])
View Replies !
Delete Record - When The Delete Link Is Clicked The Next Page Is Blank And Nothing Is Deleted.
This is my "delete.php" and this "todo/delete.php?id=64" an example of a link to it generated from the index.php page. When the delete link is clicked the next page is blank and nothing is deleted. What have I done wrong? <? include("dbinfo.inc.php"); mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $id="delete from todo where id='$id'"; mysql_query($id); mysql_close(); ?>
View Replies !
Mysql Delete - $query = Mysql_query("DELETE
how would i do the following ? $query = mysql_query("DELETE notes, datestamp, abs_value, ID FROM absence_mgt WHERE datestamp='$date' AND ID='$vtc_login' ") or die(mysql_error()); im just getting "Unknown table 'notes' in MULTI DELETE" ?
View Replies !
Displaying Priorty Records And Normal Records In The One Dataset.
I have a page which displays the records from the database and uses paging to display the records in groupes of 10 per page. I now want to be able to show results depending on the database field (display) in the database (can be set to either "full" or "limited"). If the record and the field display is equal to "full" i want to then display this record at the top of the record set and display all the fields. If the record is equal to "limited" i want to display different results and they must show after all the records which are equal to "full". I can't output two different recordsets as i use paging and only want to show 10 records per page. Code:
View Replies !
Problems With The Listing Of Records, Editing Of Records
I'm having problems with the listing of records, editing of records, and deleting of records. I'm not sure what I'm doing wrong. The listing script is calling the add entry script. So I add the record, the database is updated, and nothing else happens. I don't get a list of records from that table. When I did SQL programming off the mainframe, you did a simple select statement. I'm not sure why the PHP list script is calling the add entry script. Code:
View Replies !
Convert An IF ELSE Statement To A SWITCH CASE Statement?
How do I convert an IF ELSE statement to a SWITCH CASE statement? The switch case below doesn't work. $textlen = strlen($descr); if($textlen>10 && $textlen<50) { $completeness = 1; $deduct = 1000; } elseif($textlen>50 && $textlen<100) { $completeness = 2; $deduct = 500; } else { $completeness = 0; $deduct = 2000; } switch($textlen) { case >10 && < 50: $completeness = 1; $deduct = 1000; break; case >50 && < 100: $completeness = 2; $deduct = 500; break; default: $completeness = 0; $deduct = 2000; break;
View Replies !
If Statement Construction Within An Echo Statement
I have a form that is being used to "update" user info and I need the information to be pulled from the users table. In order to get the variables into the form, I am echoing it in and using an mysql array to place them into the form. at the t-shirt size part of the form the code is as follows ....
View Replies !
Statement Within An Echo Statement
I have a series of fields being drawn from a db and displayed on the page. I would like to insert an image if the value of one of the fields == 1 otherwise no image I can't quite get my head around the right way to do this. I know the following syntax is wrong, but this is what I'd like it to do: PHP Code: echo "<p>" . $itemname . "<br />" . $itemdescription . "<br />" . (if ($showitem == 1) echo <img src="image.jpg">; ) . "</p>";
View Replies !
PDF Mix & Match
I was wondering if anyone had any experience of splitting & appending PDF's? A client has a huge pdf, and he wants to give the user the ability to mix and match the chapters that they want to download. The final final will be 1 pdf, but may consist of various different chapters chosen from a list. The chapters will be ripped from 1 master pdf. Oh, and the PDF is not just text it contains all manner of images,links & the like! And that is what is required. I was wondering if anyone had any pointers regarding this? I'm thinking PDFLib, but I haven't fully looked into it yet.
View Replies !
Match Only Three
I have this code: $numbers = array("04","13","18","21","30","46","(05)"); foreach($data as $key => $value) { if($data[$key][5] == $numbers[0] && $data[$key][6] == $numbers[1] && $data[$key][7] == $numbers[2] && $data[$key][8] == $numbers[3] && $data[$key][9] == $numbers[4] && $data[$key][10] == $numbers[5] && $data[$key][11] == $numbers[6] )//did they win the jackpot? { echo "You have Won!<br /><br />"; } else { echo "You did not win this time :(<br /><br />"; } } The above code will check the $data[$key] array and match the values against the values in the $number array. That is fine. However what if I wanted to see if only 3 values in the $numbers array matched the numbers in the $data[$key] array. How would I do that?
View Replies !
Where Match () Against ()
i would like to change the following line WHERE MATCH (artists.artist) AGAINST ('$id') to WHERE DOESN'T MATCH (artists.artist) AGAINST ('$id') ie i would like to show all results where $id does not occure.
View Replies !
Match Against
I want use a match against in search engine on multiple tables. In other term I want to create an index and fulltext across 2 tables.
View Replies !
PHP Pattern Match
I need to convert the following pattern which I found in a php program into a perl regex... but I have NO CLUE WHAT IT DOES! &[^;]; <[^>]*> Actually, for the second one, I have an idea as to what it does, but I'm not sure... they are both used in this context:
View Replies !
Run SQL With Value Match To $array
I wonder if it is possible to do "select" in mySQL database with value matching to an $array. For example, $array = array("shanghai", "beijing"); I want to select cities whose names match the values in $array. Instead of using foreach(), is it possible to do the select with the array itself. I know some languages support this function. For example: SELECT fieldname FROM cities WHERE city_name in '$array' Is it possible in PHP with MySQL?
View Replies !
Regex: How Do I Match A Dot?
I am trying to match the dot, so that it actually matches "a dot" and not "everything". How do I write that? Example: the word "st." I have tried '/st./i' '/st./i' Sorry if this question is noobish. I have not been able to find the answer searching the net.
View Replies !
While Query Only Does First Match
I'm generating letters based on the date a lead was entered into the database. I've tried moving the } into several places. If I move it before the 2nd query I get all the letters but no dealers. If I move it to the bottom (as it now) I get 1 letter with the dealers. I can't figure out what to do to make the query generate all the letters with their associated dealers. PHP Code:
View Replies !
Trying To Match Date..
I am trying to make an Order History Lookup page for an E-commerce site. Now.. when an order is submitted the dateinserted is formated as date("U") and stored in the Db table. Now.. when I create the lookup date formfields I have them as such: Month (02) Day (25) Year (02) How would I go about getting these values so that I can compare exactly against the date("U") string that is stored in the DB?
View Replies !
Regex - How To Match Until Something
How do you replace an occurence until a certain point: You can see my example code below and the output: $string1 = 'Hello world today' $string2 = 'Hello blahblah' $string1 = preg_replace ( '/Hello.*(?!today)/', 'Hello ***' , $string1 ); $string2 = preg_replace ( '/Hello.*(?!today)/', 'Hello ***' , $string2 ); echo "$string1 - This should be Hello *** today "; echo "$string2 - This is correct "; Outputs: ====== Hello *** - This should be Hello *** today Hello *** - This is correct
View Replies !
|