& MySQL - Updating & Deleting Records
I am very new to MySQL and have built myself a small database for website update requests. The thing is Instead of having a "enter the record id # and press edit" I want to have a small edit icon at the end of each record I am displaying in a table. I've got the table data box setup at the end of the record and this is what I put in it: Code:
View Complete Forum Thread with Replies
Related Forum Messages:
Updating Mysql Records
I have programmed the code to display the information of a particular person in the form so that he/she can change his/her details in the form and hence update his/her records.I have tried with the following code.It displays the form with the previous data. But when I submit,it blanks the fields (excepting the name,surname and dob which I have blocked from making any correction).The remaining 7 fields become blank with the last field's (ExamsPending) value to be zero. Code:
View Replies !
Problems Updating Records In MySQL With PHP
Sorry to ask what is probably a simple answer, but I am having problems updating a table/database from a PHP/ PHTML file. I can Read From the Table, I can Insert into Table/Database, But not update. Here is a copy of the script I am using. I do not know what version of MySQL my host is running nor do I have Shell Access to it. I would like to setup a script so my website users can update thier records without my intervention. Also you may send replies to stevennyoung@yahoo.com Begin Script <?php $db = mysql_connect("localhost", "username", "password"); mysql_select_db("databasename",$db); if ($id) { if ($submit) { $sql = "UPDATE tablename SET EMail='$EMail',Username='$Username',Password='$Pas sword',Item= '$Item',Price='$Price',URL='$URL' WHERE Username='$Username'"; $result = mysql_query($sql); echo "table Updated."; } else { // query the DB $sql = "SELECT * FROM tablename WHERE Username='$Username'"; $result = mysql_query($sql); $myrow = mysql_fetch_array($result); ?> <form method="post" action="<?php echo $PHP_SELF?>"> e-Mail Address:<input type="Text" name="EMail" value="<?php echo $myrow["EMail"] ?>"><br> Username:<input type="Text" name="Username" value="<?php echo $myrow["Username"] ?>"><br> Password:<input type="Text" name="Password" value="<?php echo $myrow["Password"] ?>"><br> Item:<input type="Text" name="Item" value="<?php echo $myrow["Item"] ?>"><br> Price:<input type="Text" name="Price" value="<?php echo $myrow["Price"] ?>"><br> Item URL:<input type="Text" name="URL" value="<?php echo $myrow["URL"] ?>"><br> <input type="Submit" name="Update" value="Update table"> </form> <?php } } else { // display list of articles $result = mysql_query("SELECT * FROM tablename",$db); while ($myrow = mysql_fetch_array($result)) { printf("<a href="%s?Username=%s">%s %s</a><br> ", $PHP_SELF, $myrow["Username"], $myrow["Item"], $myrow ["URL"]); } } // Close DB Connection mysql_close() ?>
View Replies !
Deleting/updating/creating Problem
<? include 'db.php'; $update = "UPDATE topics SET fid = 'gdis' WHERE pinned='No'"; $up = mysql_query($update) or die(mysql_error()); if(!$up){ echo "WHYYYY!!!?!?!?!"; }else{ echo "Woop!"; } ?> It echoes out Woop! therefore meaning it's worked, but looking in my PHPmyAdmin table it hasn't changed. I can't edit it in PHPmyAdmin because it is currently getting errors when deleting/updating/creating things.
View Replies !
Need Help With Deleting Records
I'm trying to add a link on the display of a record to delete that record. The main part of the record is stored in pw_event, then there are several rating fields for that record stored in pw_rate, and there is also several records for the first record stored in pw_whois. I need to have a link that will deleted everything for that record in all three tables. Here is my display script: PHP Code:
View Replies !
Deleting Records
1) student: student_id student_name student_address 2)subjects subject_id student_id subject_name 3)hobbies hobby_id student_id hobby_name what i want is that when i delete the record from student table it should delete all the records of that id from subjects and hobbies table, i am using phpmyadmin for creating tables and the type of the table is default MyISAM
View Replies !
Updating Auto Increment Field After Deleting A Record
So much for thinking MySql is smart, but what's an easy way to update an auto increment field after deleting a record. the code is below, please help, specifically part 3 is where the magic happens. thanks in advance. by the way id is the name of the auto increment field. Code:
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 !
Automatically Deleting Records
My web hosting company offers phpMyAdmin to administer MySQL dbs. My question is, is there anyway to have records that are older than X amount of time be deleted automatically? Or do I need to add some PHP code to my site to handle this?
View Replies !
Automatically Deleting Old Records?
I'm sort of new to working with databases...I'm trying to write a script that automatically deletes old database entries. I thought this should work, but I keep throwing syntax errors. any ideas? CREATE EVENT delete_old_mess ON SCHEDULE EVERY1 HOUR DO DELETE FROM 'messages' WHERE 'date' < NOW( ) - INTERVAL 2 DAY
View Replies !
Deleting Multiple Records With Implode
My question is about deleting multiple records (selected checkboxes). mysql_query('DELETE FROM instant messages WHERE msg_id IN ('. implode(', ', $_POST['msg_id']).')'); It works OK, but it's important to check that users can delete only their own instant messages but not messages of other people. mysql_query('DELETE FROM instant messages WHERE uname='$username' and msg_id IN ('. implode(', ', $_POST['msg_id']).')'); It doesn't work - I am getting parse errors. Any ideas?
View Replies !
Updating Records
I am know to PHP i've been tring to do this **** for days now could someone PLEASE help me. Ok Im tring make an admin page where user can update multiple records at same time using checkboxes.Im using email as primary key. Here is the code **form page** <form action="update.php" method="post"> <input type="submit" name="submit" value="Select First 10 Names"> </form> **update.php** <?php if ($submit =="Select First 10 Names") { ?> <form method="post" action="<?php echo $PHP_SELF; ?>"> <hr size=3> <?php $query = mysql_query("select * from Names order by Last_Name limit 10"); while($row = mysql_fetch_array($query)) { $first_name= $row["First_Name"]; $middle_name = $row["Middle_Name"]; $last_name = $row["Last_Name"]; $email = $row["Email"]; $photo=$row["Photo"]; ?> <table width="100%" border="0" > <tr> <td align=right width=50%> <?php echo "First Name: <input type=text name="first_name" size="30" maxlength="40"value="$first_name" ><br> "; echo "Middle Name: <input type=text name="middle_name" size="30" maxlength="40" value="$middle_name"><br> "; echo "Last Name: <input type=text name="last_name" size="30" maxlength="40" value="$last_name"><br><br> "; echo "Email: <input type=text name="email" size="30" maxlength="40" value="$email" readonly><br><br> "; echo "Photo: <input type=text name="photo" size="30" maxlength="70" value="$photo"><br><br> "; echo "<input type="checkbox" name="email[]" value="$email"><b>Update?</b> "; ?> </td> <td align=right width=50%> <?php echo "$photo"; ?> </td> </tr> </table> <hr size=3><br> <?php } ?> <input type=submit name=submit value="Update Enteries"> <input type=reset> </form> <?php } if ($submit=="Update Enteries") { if (is_array($email)) { while (list($key,$value) = each($email)) { $query= mysql_query ("update Names set First_Name = '$first_name' Middle_Name= '$middle_name' Last_Name='$last_name' where Email='$value'"); } } } ?>
View Replies !
Updating Multiple Records
I'll try and explain my problem!! Database table : Book Table : BookWords Fields : BookWordID Word Description I want to show : The word is $word add your description $description using th code below: [PHP]$db = mysql_connect("localhost", "root",""); mysql_select_db("Books",$db); $result=mysql_query("select * from Bookwords",$db); while ($rec=mysql_fetch_array($result)){ $wordid = $rec["BookWordid"]; $description = $rec["description"]; echo "$wordid: <input type=text name=quantity[$description]><br> "; } This is ok so far. Now i want the user to be able to add the description from the form and have the db automatically updated. I've tried the different methods I've found on this forum and I cant get anything to work!!!
View Replies !
Updating Records With An Array
I'm trying to update records using values selected from a multiple selection select box. Here's the code i'm using in the update page: if (isset($_POST['team_id'])) { foreach ($_POST['team_id'] as $value) { $sql4 = "UPDATE team_members_x SET date_id = '".$_POST['date_id']."', team_id = '".$value."' WHERE date_id= '" .$_POST['date_id']."'"; $result4 = @mysql_query($sql4,$connection) or die(mysql_error()); } } This doesn't seem to update my records correctly though.
View Replies !
Updating Only Some Records Of Some Tables Of A Database
I manage a couple of mysql databases that are hosted on my server as well as at my ISP. We do update quite often some records in different tables & databases. As in South Africa, we pay per GB of traffic, complete dumping of all databases every day is excluded. I am looking at a better way of only synchronizing the records that have been modified. In every table I created, I have a date_created & a date_modified, and of course everytime there is an automatic or manual update of the data, date_modified is updated. Code:
View Replies !
Updating Multiple Records On Submit
I have a page of results generated by a query and next to each displayed record is a checkbox. On selecting the checkbox(es) and submitting the form, a column in the table will be updated. E.g. Name = "blah" Address = "blah" Status = "added" [checkbox] If checkbox is selected, the column 'Status' will be updated to a new value. Can anyone explain the concept of what I need to do so I can have a go at working it out (if my explanation makes any sense)?
View Replies !
Error In Code For Updating Records
I'm trying to update records that are stored in my db on products. what I am doing is I am clicking on an image of a product to update. When I click on a product it brings me to my admin_update2.php page and passes in the value of shopName and prodId. I can see from the url that these values are being passed through ok. However I am getting an error saying Parse error: parse error, unexpected $ in /home/c/ciaracousins/public_html/admin_update2.php on line 143 line 143 is just a blank line at the very bottom of my page. Any idea what is wrong with this?? Code:
View Replies !
Updating Multiple Records In A Recordset?
Back in my OOP/ADO days you could query the database, get a recordset object, modify any records you wanted to in your calling app, then "batch update" the recordset back to the database. Does PHP support something similar to this? For example if I have 10 records and I need to set field 'x' = a different value for each record, do I have to execute 10 queries against the database, or can I update them through the mysql_result and flush them all at once? Hope that makes sense...
View Replies !
Process To Compare Records For Updating, Is There Am Efficient Technique?
I have a large database where the records have many fields (80+) and have users periodically updating it by submitting uploads. Is there a quick and efficient manner to compare the record that is being uploaded to the one that already exists in the DB before updating? The records have over 80 fields, so stepping through every field would be painful, and why update the record if nothing has changed. Is there some binary or boolean manner to weight both the existing record against that being offered, and if they are equal then do not go through the process of uploading and importing. Any ideas welcome.
View Replies !
Deleting Records - "not A Valid Result Resource" Error.
I have two pages for Deleting the first is the selection page, lists the records with checkboxes next to them for the user to select and then a Delete button that passes to the second page. My first page shows up just fine. So here's a line from my first page just so ya can see the name i'm using for the checkboxes. PHP Code: echo "<input type='checkbox' name='id[".$i."] value='".$arrHorses['pk_horse_id']."'>"; The second page is suppose to get info for which records to delete from the first page and execute such a query. Then display the name of the records that were selected and say they were successfully deleted. Its connecting to the database just fine. But I'm getting a "not a valid result resource" error. arg, seems to be the error I always get. Here's the important code for that page that I have thus far: PHP Code: //store the Horse_ID passed from the previous page in a variable $intDelete = $_POST['id']; //Query to delete the record passed to it from the previous page $strDeleteQuery = "DELETE FROM horses WHERE pk_horse_id = $intDelete"; ..........
View Replies !
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:
View Replies !
Deleting Record From Mysql
I am just tring to delete on record based on a link generated. The link shows up, the number of the field is shown as deleted when the link is clicked, but the entry ios still in the db. Maybe a problem with how I have the db setup? I only have one field, add_manufacturers, and it is text. It is in a table called manufacturers. Code:
View Replies !
Deleting From Mysql Table
i'm trying to replace a record in a mysql table but i'm having problems. First i've got a page to store existing film name values using: <input type="hidden" name="Name" value= "<?printf($row["Name"])?>"> The second page is supposed to delete the existing record by comparing the stored name value with the database name but it only creates a a duplicate record. Here is the code for this: Code:
View Replies !
Deleting Mysql Rows
Is there an easy or another way to delete rows? Right now I'm checkmarking the row I want to delete and then clicking on the red x for each one. It takes absolutely forever. Is there a better way?
View Replies !
Deleting Rows In Mysql
I'm struggling to find the right way to formulate a mysql query. I want to do something like Delete from thedatabase where field2 and field 3 on somerow have the same values as field2 and field 3 on someotherrow. I can't figure out how to compare the data from two different rows. Anyone have any ideas on how I can do this?
View Replies !
Deleting Rows From MySQL
This SQL query (table names changed) find a set of records I need to delete from a MySQL 4.0 table (so subqueries are probably out). SELECT tablename.id FROM tablename JOIN cards ON tablename.card_id = relatedtablename.id WHERE tablename.user_id =1 AND relatedtablename.set_id =1 Any hints on how to delete these rows? (Short of upgrading to a newer MySQL, since it's not my server.) I'd prefer to do this with a SQL statement, instead of "punting" and writing a PHP page.
View Replies !
Deleting Data From MySQL
At present when we develop CMS driven websites, when content is deleted it is marked as deleted within our MySQL database so it is never actually deleted incase, for example, it was done by accident. We do this by having a table field simply called "deleted" set to either 0 or 1. What I am asking is does anyone else do this or something similar? And if you do, what method do you undertake yourself or recommend.
View Replies !
Deleting A Table From A MySQL Database
I've looked at the manual and a few other php resources, but yet I couldn't find a simple and easy way to delete a table using php. I noticed there is a destroy() function within the MySQL class, but I'm not sure how it's used.
View Replies !
Mysql And Php5 Deleting Rows
I can't seem to delete rows from a mysql database. I have a database that I want to delete rows from based on user name. i have researched this extensively and can't seem to find anything that works.
View Replies !
MySQL Delete Only Deleting Content
I am working on a content editor for a client who wants tha ability to add new page. But he also has to be able to delete page. The pages are refered by their PID column which is set to auto increment. However, when I delete a row, for some reason, it deletes the content in the row, but not the row itself. So, I have an empy row left which gets assigned a PID when I drop the PID column and reconstruct it with the new auto_increment numbers. What could be causing this? Or is there a way to renumber the auto_increments after a page has been deleted? My coding is a little rusty right now as I am out of practice. had to have a reference manual by my site at all times. PHP Code: $sql     = "DELETE FROM $db_table WHERE PID = $id LIMIT 1"; $result = @mysql_query($sql, $db_connect) or die(mysql_error()); $drop     = "ALTER TABLE $db_table DROP COLUMN PID"; $result = @mysql_query($drop, $db_connect) or die(mysql_error()); $add    = "ALTER TABLE $db_table ADD PID INT NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST"; $result = @mysql_query($add, $db_connect) or die(mysql_error());
View Replies !
Deleting Older Entries.. (mysql)
I've a comment form.. I've allowed only 10 comments to be viewd, so when I submit new comments, I want to know how to delete older ID comments except the latest 10 comments. Means if there are 13 comments.. 13...3 shd be there and very 1st and 2nd(older) comments must be deleted.
View Replies !
Problem Deleting In A Database: Mysql
I am having a problem with deleting from a database. I have my deal_manage.php page which has a delete link so as to delete a record from the DB table (called product), the link goes to my deal_remove.php page which has my query on it to remove the product. I think the problem may be that the id# of the item is not getting through to the remove_deal.php page as when I click the delete link it goes to the remove page but the product is not deleted and i get my 'product was not deleted' message. Code:
View Replies !
Batch File Deleting And Folder Deleting
I have a folder in my web site where I used php to create and copy in files. but now I can't delete them easily. The only way I know how that is possible is through php. I get an error the following ftp error: 550 th: Permission denied I had the chmod() set to 0777 on every file and folder. But I still seem to loss control over the files when I try and do things with them through other means. I think it is because the user I use to access the files via ftp a diffrent user. So I tryed to add a function with chown() for the new files I was posting and uploading. It didn't work on those new files. so it looks like the only thing I can do is use the unlink() function which deletes the files fine. The only problem is now I have something like 100 sub directories all with files in them. I need to figure out a way to batch delete them. I can't find a script that goes through and finds all file contents including all sub directories and unlink those things. I found some that will use a for loop to list out the contents of a folder but it is just files. No sub directories. Any body got any ideas on which functions I should use or know where a script is that I can base mine off of. I am not sure how to approach this since what I tryed with chown and chmod has failed thus far. I currently have no code and am starting from scratch on this batch flushing of my directory.
View Replies !
Deleting A MYSQL Record From Within An Html Form
Just rebuilt an admin tool in PHP (originally built in asp) for a news section of a site. The problem is: My delete records php page is set out in an html form, with each news story expressed with a checkbox. normally i'd put a <a href="delete.php?id=<? echo $row->id; ?> </a> alongside the record, but i need to have it work in a form. What action should the form have, and how do i get the form to process the deletion process with the correct news story checkbox selected?
View Replies !
Deleting A Mysql Record In Active Result
I'm doing a select in wich I retrieve some values. If the value is in an array, I must delete the record. As I'm doing a "mysql_fetch_object", may I delete this record inside the loop ? when doing a mysql_query, do I have a "local" copy or just a link to the mysql query result. In the first case I may delete the record as I get an "image" of the query result, in the second case I shouldn't as the query result will be changed by the deletion of any record.
View Replies !
Updating MySQL With PHP
The page I want to update is similar to "http:www.hospiceslo.org/events.php" (read only). On my update page I've got the same table as a FORM where the client can make changes to the fields. The problem I'm having is updating the MySQL data base with the content of the form. I have no clue and would like to know where to start. Can I get some pointers to references or examples,
View Replies !
Updating MySQL
I work at a Middle School and I am developing an employee portal for our faculty to access. I am trying to create a computer lab sign up that will list all the dates and class periods available and will give them the option of selecting their userid from a drop down menu in order to reserve the lab for that period. We have alot of tech unsavy people so it has to be very simple. All I want in the drop down is the word 'Available' and their User ID (which will reserve the lab). Once the lab is reserved all I want is for their user id to be displayed instead of the drop down menu in order to indicate the reservation. I have attached the full code in a text file.
View Replies !
Updating To Mysql
I'm stuck with a problem that i cant fix or have a clue what might be wrong. I have a script installed on my site and everything works fine but the update process. Users can open new account and it all gets recorded in the database but once they register and then they want to update their account and click on submit it looks like it goes throught but it does not. Nothing gets replaced in the database and the same info is still showing.
View Replies !
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:
View Replies !
PHP MySQL Updating Table Row
I have a small database of books that a client can add, search and edit (hopefully) books; all online (something very simple). So far I've been successful in creating the adding of books and searching and retrieving the info in fields to edit; but I haven't been able to execute the edits. Here's the script I have to retrieve the database info and place them in the fields to edit (I didn't copy all the mysql connection script, it works fine): PHP Code:
View Replies !
JavaScript/PHP - Updating MySQL
i've got a form that runs a PHP script, when the user completes the database is updated and a image is shown in png format (created using GD Library). The problem with this is that I cannot add any buttons on the page and there is just an image. So I thought it would be a good idea if I could use some sort of javascript to open a smaller window so that it was only big enough for the image to appear and still have the form open in the background. Using something along the lines of: Code: <a href="http://www.a.com/show_poll.php" onclick="window.open(this.href,'friend','top=200,left=400,width=300,height=400'); return false;" onkeypress="window.open(this.href,'friend','top=200,left=400,width=300,height=400'); return false;" title="Opens a new window! [ALT + F]" accesskey="f"> <img src="images/emailafriend.jpg"/></a> Problem when I implemented this was that the database was never updated, instead it just opened the page. Here is my current code using the include() method, which is not suffiecient for my needs.
View Replies !
Updating A Row In Mysql Through A Form
I have been working on trying to not only nicely display mysql data, but also to update three fields in a database record through the php page displayed, by pressing a "Change" button next to the record. The three fields that are updatable would be "survey", "checkout", and "paid" in the table users_survey. They are tinyint(1) fields that are either 1 or 0. I have them displayed on the page as checkboxes in a form. I would like to be able to chek or uncheck these boxes, followed by pressing the "change" button next to the record, and have the record update with the new values (either 1 or 0). I am not really sure if I am approaching this correctly, but here's what I have written so far: PHP Code:
View Replies !
Updating PHP/mySql Versions
I use something called PHP Triad to provide a local PHP/mySql environment for test purposes, but obviously its PHP and mySql versions are out of date now (well, they're not the newest and don't support everything I want). How would I go about updating specifically the PHP or mySql? I'm aware you can download each of these but would they just slot right in to my existing directories, or would I need to re-install my whole set-up and get the latest Triad? What would be involved in replacing PHP/mySql- just stick it in the right folders and overwrite the old .ini file?
View Replies !
Updating Substrings In Mysql
how does one go about updating a substring in mysql e.g. I want to change all occurences of Gmbh to GMBH within a field string. BMW gmbh BMW Gmbh Mercedes Gmbh Joe Blogg Gmbh & Mercedes Ltd get changed to BMW GMBH BMW GMBH Mercedes GMBH Joe Blogg GMBH & Mercedes Ltd I know how to do this in PHP, but is there a way of doing it in MySQL natively?
View Replies !
Updating A Field In A MySQL Db
I am having trouble updating a background_id field (integer type) in a MySQL database. What I'm trying to do is use the associated background ID (in the background table) of the background that is selected by the user to assign its value to the background_id field in the member table. PHP code:
View Replies !
UPDATING Null Into MySQL
I'd like to UPDATE a datetime field ONLY IF the database holds "" null already. This works using the checkbox. However, if I do not tick the checkbox, then it tries to update the datetime field in the database with "" null. This gives the error: Error: Incorrect datetime value: '' for column 'Started' at row 1 Of course it is correct, "" is not a correct datetime value. Does anyone know how I can simply get it to do nothing if the 'Started' box is not checked? Code:
View Replies !
|