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




How To Delete Only Certain Text In A Mysql Row?


I have a table setup that has a column setup as friends and users can add friends to this column no problem.

What I would like to know is how to delete only certain parts of the text of the row/cell where their friends are stored.

The friends text is seperated by the following :

" , "

That is a space on either side and comma in the middle of the space.

I know how to explode the results and put into an array to display the reuslts, but is there a way to delete only one of the friends if the text is as follows.

 , thomas , frank , irene ,

I think you can get the idea.

Is it possible to do this or should I just update the whole cell without the array[$i] result being the friend?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
How To Delete Single Email Adres From Text File
I have a textfile:

bla@domain.com
blabla@domain2.com
haha@domain.com
la@domain3.com
zaza@domain4.com

How can I delete a single email from that text file ? E.g. I want to delete blabla@domain2.com so that the textfile will be:

bla@domain.com
haha@domain.com
la@domain3.com
zaza@domain4.com

How can this be done ??

Quickly Adding Text To A Mysql Text Field That Is NOT Empty
Is there a way to insert text into a mysql text field that already has
text into it; without having first to extract the existing data and
append the new text to that string variable and then insert the new
string.

Basically i'm looking for a way to do it with a single query not 2 (one
being a select to gather existing data).

Gaining Access To How MySql Parses Text For Full Text
I want to gain access to the function or process MySql uses to parse words and phrases for Full Text searching. Here is an example.

If the user inputs...

Milan in history

MySql will search for milan, history, and milan history. Is there a way to extract just the combination of terms MySql uses to search the db without the stop words? Stop words are automatically eliminated from the search request unless the user encloses a phrase in quotes.

What I am trying to do is develop a script to highlight found search terms and phrases. I can explode a phrase into single words but if I do that the stop words would be included in the array. If there is some way of getting into the parsed words or phrases MySql Full Text actually uses to search, I can use each of those combinations as a keyword in my highlighting script.

This request is about searching for the code or any code related to the questions involved.

Mysql 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" ?

Delete Entire Line In Text File If Anything In The Line Matches Search String
how would I code a php script that would open a text file, look for a string i specified, and if it finds that string, it will delete the entire line in the text file that contained that text. I'm new to php, so sorry if this is really obvious..

Delete MySql Row By Date
Can someone help me with the following problem:

I have a table that includes a column for "last application date", let's simply call it "date".

Now the problem is how to automatically delete rows where the information in the "date" column has gone old, let's say by -86400 (1 day).

Example: today's date is April 11th, which means that all rows with the info April 10th in the date column would get deleted.

How Do You Do A CASCADE Delete In MySQL?
I'd like to delete a record and all its children records at one time. How
do I do that?

Can you, in one SQL statement,

delete from table 1 where id = 3
delete from table 2 where id = 12
delete from table 3 where id = 12
......

MySQL - Delete Across Two Tables. OT
i cant find the MySQL newsgroup, however i am
hoping to pick up on some expert advice from php/mysql gurus here. I'm
having some trouble performing a delete across two tables.

The tables i have are:

questionnaires (id, name);

questionnaire_questions (questionnaires_id, id, name, qf_type)

The questionnaire_questions table contains a list of questions for a
specific questionnaire (indicated by the questonnaires_id). I would
like to remove a questionnaire, and when doing so all corresponding
questionnaire_questions who have matching id's (questionnaires.id =
questionnaire_questions.questionnaires_id).

I have this statement, however it only works if a questionnaire has
questions... however i would like it to delete even if no questions
exist for that specific questionnaire. The SQL i am using is:

delete questionnaires, questionnaire_questions FROM questionnaires,
questionnaire_questions WHERE questionnaires.id =
questionnaire_questions.questionnaires_id AND questionnaires.id =
THE_QUESTIONAIRE_TO_DELETE_ID

DELETE Problem With MySQL
I've been learning using PHP and MySQL from the tutorial at
freewebmasterhelp.com. Everything works fine, except deleting things.
The script is invoked with a URL like this:

http://www.example.org/test/delete_entry.php?id=35

And here's the script:

<?
include("dbinfo.inc.php");

$id = $_POST['id'];
mysql_connect($server, $user, $password);
$query = "DELETE FROM test1 WHERE id = '$id'";
@mysql_select_db($database) or die("Unable to select database.");
mysql_query($query);
mysql_close();

header("Location: entries.php");
?>

The dbinfo.inc.php file defines the variables $server, $database, $user
and $password. The login part works.

Mysql Delete From A Form
i'm trying to find out how to get this to work. You type in a name of a record in the database and it removes it. In this case it's deleting the record that when you type in the name of the server it looks for it in the column "servername". You type in the servername and it will delete the whole record. Code:

MySQL MultiTable Delete...
I've been able to delete rows from one table successfully but what I want to try next is giving me some problems. I have a users 'id' which is unique. Heres what I want to-do.

DELETE * FROM users WHERE id = 1
DELETE * FROM messages WHERE from = 1
DELETE * FROM comments WHERE user = 1

In each table there oginizaed a little different hense the id , from & user... but thats what I want to-do, without having to-do them all sepreatly, would like it to be efficent. the users ID will be passed along as the var 'id' any thoughts? So pretty much it takes the users id number and deletes them from each table.

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.

Mysql Delete Record
when I run this code below it doesn't delete the record or display any error message

$id = $_GET['id'];
include("../dbconnect.php");
mysql_query("DELETE FROM promotions WHERE id='$id'") or die(mysql_error());

Such a simple thing to do but I don't no why it doesn't work 

How Do I Delete A Full Row In Mysql ?
how do i delete a full row in mysql ?

PHP Unlink() & Mysql Delete
Im trying to delete a file, then delete the row in my table that holds the info for this file. I tried the code below and got this error:

Parse error: parse error, unexpected T_STRING in /nfs/cust/4/97/13/731794/web/Admin/backup/PXS_DeleteBackup.php on line 34


Here is my code:

Mysql Row And File Delete
I have a database with the following colums, imageID, imageName, imageDesc, imageFile, imageHeight, imageWidth, imageThumb, imageThumbHeight, and imageThumb Width. I can easily delete a row from the mysql table, galImages, but I also want to delete two files from a directory. The file names are stored in the columns imageFile and imageThumb.

Php/mysql Insert, Update, Delete All-in-one
I have a check box form in an admin area, that links various related tables into one.

These check box results are stored in an array, and then looped, there are in fact four groups of arrays, but the array length could become large (i.e. dozens - not hundreds)

The issue I have is that from the one form multiple things need to occur.

- If a box is checked and the record doesn't exist a new record needs to be inserted.
- If a box is checked and the record does exist, it should be ignored (as it already exists).
- If the box is unchecked and the record exists, it should be deleted.
- If the box is unchecked and the record doesn't exist it should be ignored (the record doesn't exists).

I'm looking for the logic and process (rather than being hand fed code ) Can this be done with 1 (or more likely 2) sql statements. Or do I have to loop thru the arrays, checking the existance and then applying a specific sql statement depending upon checked status and the records existance. Someone mentioned using IF() in the sql statement, but I am not familiar with that one.

Delete Row From Mysql Only Deletes The Contents?
mysql_query("DELETE FROM cart WHERE ItemId=$ItemId");

There is the code but the result in my databse is that the ID number changes
from, lets say, 77 to 78 with 78's contents being empty. Therefore when I
look at the results - the deleted ID77 is gone but now I have ID78 with no
content!

Does anyone know why and how do I make it stop?

MySQL DELETE: How To Get Page To Refresh?
I have a script that deletes records in a table. It works fine. However, it redirects the browser back to the page and the record stills shows there. Only after the page is manually refreshed does it disappear.

I've used both header("Refresh...") and header("Location...") to accomplish the redriect, but no dice. The only thing that seems to work is if a unique URL is pushed into the address bar, which I do by appending md5(microtime()) to the end of the redirect URL.

Select & Delete Mysql Queries
i've try to insert and delete record at the same page, but it only can insert and can't delete the record. when i click submit button from the previous form, the record is insert into table B and delete from the table A. is the code correct? Code:

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.

Delete Textfile List From MySQL Table
I have a list of email addresses that I need to delete from my database and they are in a textfile, one on each line like below...

a@b.com
c@d.com
e@f.com

etc. does anybody have a snippet of PHP code that I could use to accomplish such a task?

PHP File To Delete Multiple Talbes In MySQL
i installed PHP Nuke, didnt really like it. I think its much more then what I need. Great System, just think alot of it is useless for my needs. In any case i want to delete all the tables it created in my DB. Anyone got a script I can run to delete all tables that start with.

How Do I Delete Selected Rows From MySQL Table?
I am trying to figure out how to delete selected rows from a MySQL database table. The web site that I am working on has a page that will extract rows, using the "SELECT * FROM .. etc." statement from a database and output them in a table - like the one below (bottom part). I've got that part figured out.

What I am trying to figure out is if the user puts a checkmark in one of the checkboxes (below) how would I write the PHP code to delete one or two of the rows from the MySQL table? PHP Code:

How To Delete A MySQL Database Table Without System()
I want to delete a MySQL table without using functions of the OS, so
that my php script can run on any webserver. Can I use a command like

$sql = "DELETE FROM tablename";

or are there better ways to do the job?

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 ?



PHP/MySQL Text And SEO
I'm creating a news script to store news articles in a MySQL database and using PHP to access this DB. I was wondering since PHP processes before the page is loaded will it display the text from the DB and allow this text to be picked up by search engines?

Combo Box / Text Box Php Mysql
this is the the code, now here is the final result.... I get one combo box
<?php require_once('..library_databaseConnectionsonli nequote.php'); ?>
<?
function select_cases_price ()
{
$qy = "SELECT SellingPrice, Description FROM cases";
$rs = mysql_query ($qy) or die (mysql_error ());
while (mysql_fetch_array ($rs))
{ $select .= "<option value='{$r[0]}'>{$r[0]}</option>";
$prices[] = $r{1};
}
return array ($select, $prices);
}
?>

On your web page, call the function.

<? list ($select, $prices) = select_cases_price (); ?> And a bit of JS:
<script>
function showPrice() {
array prices (<? echo $prices ?>);
var i = document.form.item.selectedIndex; document.form.SellingPrice =
prices[i]; </script>

<select name="Description" onUpdate="showPrice()"> <? echo $select; ?>
</select> <input type="text" name="SellingPrice" value="">

Saving Text To MySQL
I have a small form where users can comment on some articles on the web
site.
But to prevent abuse I want the form to save the comments and email it to me
to review.

But that means that the user can still abuse the form itself or cause
Query/SQL problems, (with special character for example).

So how would I save ANY text to the database? And if I have to convert the
text how do I retrieve it correctly?

For example if the user enters "This is a quote, 'hello world'" how should I
handle special characters?
Would you advise me to handle all my text fields the same way to prevent
abuse/hacking?

And how should I protect my fields against hacking?

Displaying Text From MySQL
I am working on a very simple news page for a website. I've setup a simple form that writes news to my database and the data is then displayed on my news page. I have gotten everything to work successfully but the content in the article loses all its paragraph formatting when I try to display it. I can use break tags to make the formatting show up but there has to be an easier way.

This is the code I am using now, which I found on a tutorial somewhere and then tried to modify to work for my site: Code:

Mysql Data To A Text Box
I am trying to retrieve a text block from a Mysql database and display it inside of a <textarea> how do i do this?

Mysql Text Field
I have a DB with a column that is set as Text format. The data stored in the field will be stored in many lines. When I get the data from the DB I want it to display where the line breaks are I'm not sure how to write the script to do this. I have worked withe explode before but there is nothing come at the end of each line to do this with.

Rich Text With Php And Mysql
Could anyone recommend a good way to intergrate rich text (blog, forum like text, like this!) into a php/mysql web app I am building?

Does a TEXT field handle the formatting (bold, font size, colours)? and what about storing links?  Or must it be pharsed in and out each time you edit?

Text To MySQL Problem Need Ideas
I know how to upload text files and such my problem is that I may have many many text files so any editing of the files is out of the question. The files are not delimited, well so far I use
and it works but with help of some editing.

Export Mysql To Text File Via PHP
I need help on how to export one of table mysql to text file to download. (not saving text into server)
something with like header("Content-type: text/plain");

PHP - MySQL - Text Files - Speed
I've got a question that I'm sure is answered somewhere but I haven't run across it yet.

I've got a site with a lot of content that's being pulled from a database. Most of the content changes on a very regular basis.. I take it, push it into some templates, and render it to the screen.. pretty standard stuff..

But some of the pages have large blocks of static content. Just as an example, lets take about 50 lines of formatted static HTML.

This content doesn't change very often at all. The site is already designed to push through a template, so putting the content into static HTML pages isn't an option. The question is, should I store that content in MySQL or in a text file?

I figured that MySQL would be easier on the system. The fetches seem like they would be pretty easy for MySQL to handle, no complex queries. I figured that pulling from a text file would require apache/php to open the file, read the file and then close the file every time someone hit that page.

Am I putting unwarrented stress on our database?

Show Text From Mysql By Paragraph
I am trying to develop a site for news paper. i keep articles in a longtext field in Mysql. But when a retrieve the data from database. i lose all paragraphs. the total article in shown in one paragraph.

But i want them be as it is the way i paste them. Pls help to do find out the solutions.

Full Text Search ( Mysql )
I was searching the sql man , for some good ways to search a mysql db. so i found that Full text search the best way is to go becease LIKE just gives to mutch output.PHP Code:

Displaying Text Pulled From A MySQL DB
I have a web edit, delete and update script set up. its all working pretty much as i need except for one thing, the editing function.

When an admin clicks edit beside an entry that page is resubmitted using $PHP_SELF and a variable is set. A check is then carried out in each form field to see if this variable is set, if it is set then a query is carried out and it enters the value of the query result for a table field as the value for the form field. You can see this in the code below.

My problem is this: when the values of the DB are echoes out into the form fields they dont display correctly or they just display the first word until they reach the first space and then nothing else. PHP Code:

Insert Text From TEXTAREA Into MySQL
I'm trying to figure out how to INSERT/UPDATE text from TEXAREA into
MySQL. Because TEXAREA has no VALUE, I'm hitting a brick wall here.


Storing Formatted Text In Mysql
How do I store formatted text in mysql?

Php/mysql Storing Formatted Text
I'm trying to make a message board. Everything seems to be working finally. The only problem is that when posting a reply to any thread. if the person types:

this
is
my
name

It gets displayed as: this is my name , Where as it should display:

this
is
my
name

on 4 different lines.. anybody know how i can do this?

Converting Text Database To MySQL
I have a file 849 lines long with records in, each record takes up 4 lines and records are seperated with <-nrbrk-> Code:

Text Field As Date (MySQL)
I have a generic table used for many different generic
functions. the fields are mainly varchar's but one of these varchars
contains dates (in the format dd/mm/yyyy) for one reason or another.

My question is, can I perform a query on this table, using date
functions on this varchar field? I.e. search for the latest date?

Importing Csv Text File Into MySQL
I have a CSV file delimited by ~. Here is an example of 3 records: Code:

Importing Text File Into MySQL DB
I'm writing a script to import a text file with fields delimited by ~ into a MySQL DB. I'm trying to import everything into an array first, so that one array row = one record row. Here is some dummy data, with the &#390170;' record having a couple of new lines where a new paragraph is. Note the other records have NULL in the same field: PHP Code:

Inserting Formatted Text Into Mysql ?
is there a way to format the text from a multi-line textfield (html), including line breaks, tabs etc. and to properly insert it into a mysql-table ?

Submitting Text For Use In A Mysql Database
This question has been bugging me for month. I have a website where people can enter stuff into a mysql database. Some of this
information will already be shown in some textareas and input boxes, the user may change it and then hit submit. All the values are
then passed to a mysql database, overriding the existing values (after the old ones have been backed-up).

All of this works marvellous, apart from characters like &, ' and ". To make it even worse, some of the original text already
contains &039; and other numeric character codes.

Any values from the database are displayed by retrieving them from the DB

[simplified of course]

mysql_quer(...)
$row = ...
$Vold1 = $row[x];
$Vold2 = $row[y];
etc...

<INPUT VALUE=$Vold NAME="x">
<TEXTAREA>$Vold</TEXTAREA NAME="y">

Any values that are submitted are processed as follows:

$V1 = trim(stripslashes(htmlentities(trim($_POST["x"])))))
$V1 = trim(stripslashes(htmlentities(trim($_POST["y"])))))

then $V is inserted into the table using a mysql query.

Text To Date And Insert To Mysql...
Kindly break out the 4x2 and bring me to my senses.
I seem to have gotten myself totally confused with php.net, mysql.org pages
on dates etc, as well as groups.google.

Could someone explain, even using pseudo code, how to take a text input I
have set up as YYYY-MM-DD using php, and convert to a value mysql will
insert into a Date (not timestamp, not datetime) field.


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