Delete Records
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
See Related Forum Messages: Follow the Links Below to View Complete Thread
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?
DELETE 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:
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:
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:
DNS Records
Hey everyone, I'm trying to get a DNS record of an IP using PHP's checkdnsrr() and getmxrr(). I used echo checkdnsrr($REMOTE_ADDR); and echo getmxrr($REMOTE_ADDR); but I receive an error that the PHP build does not support it, but I am using PHP 4.0.5 and in the manual, it shows that PHP 3 and 4 supports the two commands. Any help?
Next N Records
how do I create a "next n records" interface? I want to initially output a specific number of rows, and have a next/previous scenario where the user can click on either and scroll forward or back through the records. I'm currently outputting all rows through mysql_fetch_array: Code:
HOW TO GET HOW MANY RECORDS YOU HAVE IN DB
I finally discover the way how to get what I need. Let's look to my code: ----------------------- CODE ------------------------> $res = @mysql_query("SELECT COUNT(*) AS ToT FROM table_name"); $dato = mysql_fetch_array($res); echo($dato[ToT]); ----------------------- CODE ------------------------> With this code you will get how much records do you have in DB. PS: Whan you think that everything is over and that you are at bottom of trying push harder to see what is under.
Last 5 Records
is there an easy way to grab the last 5 distinct records from an unindexed database? (php/mysql)
Number Of Records
I want to find out how many records, but I am using LIMIT in mySQL so if set the limit to 20 and I have 56 records then it will display 20 instead of 56. I have been using: mysql_num_rows What should I be using?
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?
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'"); } } } ?>
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:
Retrieving Records With Between
I am trying to convert my asp website to php. So far so good, but I am having a problem with my SQL Statement that needs to us the Between. Here is what I am using: $sql = "Select * From tblTrack Where DateEntered Between $start and $end"; the vars start and end come from the same form. I don't have a problem when I hard code the dates, but when I use the variables, it won't retrieve anything.
PHP/MySQL Records Per Row
Is there any way to have the records pulled from a mysql database display like this in a table: record1 | record2 record3 | record4 etc: I've been thinking about this for about three months and have yet to come to a good solution.
Inserting Records
I'm trying to insert as many as records as possible but less than 100 into a table. First, i get the count inorder how many to add and then depending on the count, i get so many blank form fields to enter. Now, I noticed something really strange. 1.Only the last entered record is inserted into the table. 2.For example, when I type a name, Let us assume "WORLD", only w is inserted into the table and the rest is not.It is the same with all the form fields.whether, i'm trying to enter text or a number,only the first character is inserted.This sounds weird. Could somebody pls tell me why is this peculiar behaviour Here is the code:
Insert Records
When I try to insert a records in the database "socios", it doesn't inserted at all. Code:
Different Hyperlinks To Different Records
I'm displaying few records from a mysql table - pretty straight forward one. For each record i display on the form, i want to add a link to it.so, each link would display a different page(an html). PHP Code:
Displaying Some Records Once Only
I'm building a database via mysql/php which brings back records of events. My problem is that I only want to show the Venue for the event once and then list the events for that venue. ie Code:
Deleting Records
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:
How Do You Sort Records?
I have a db table "person" that I can sort by title, first_name, last_name, or city with no problems at all because "title", "first_name", "last_name", and "city" are columns in the table. The requirement is to ALSO sort by department NAME. Problem is, I can't do that in the "person" table because the column is "department_id" which is a foreign key constraint to the department table. How do I sort the person records by department_name based on this? I am using PHP 4.3.2 and MySQL 4.0.10 Now, second problem and even more of a problem: The requirement is to ALSO sort by state NAME and country NAME. The fields "state" and "country" in the "person" table contain only an abbreviation of state and country; the corresponding full name of each state and country are found in respective XML files in /xml/state.xml and /xml/country.xml
Compare Records
is it possible to write a query to compare records in 2 tables, like if the number of records in the 2 tables are equal the query should return 1 if not equal the query should return 0. this can also be done in php like, get the number of records from one table and get number of records in another table, compare it and do the operation. but i wanted to know if its possible to do the compare records using the query itself. for example, if one table has 5 records, this should be compared with another table, if this table has 5 records, then the result of the query should be 1 else 0. if i use joints, it will return all the 5 records. so not sure how to make this in a query. anyone have any idea ?
Display Records
I want it to display all the records meeting the criteria specified in the script, but it only shows one records and should show about ten. any thoughts or pointers to get it to display more than one record. Code:
DESC Records
i want to make all the records be shown in a decending order, i've tried using: $sql = 'SELECT * FROM `repair` ORDER BY `repair` . `id` DESC';
Count Records
How can I count how many records are in a table that match a news_id? I have this at the moment, but it doesn't seem to work. Code:
Retreiving All Records From Sql Db
IM trying to get cost values out of the db with a specific ID which is assigned to an item ID but i only get the last record in the database. $lala = mysql_query("SELECT `cost` FROM `table` WHERE `ID` = '1'"); while ($la = mysql_fetch_row($lala)){ $start = 0; $overall = $start+=$la[0]; } echo("$overall"); ...
Return Last 3 Records
I want to return the last 3 records added to my table called towns. sql = "select * from towns limit 3" This only returns the first three rows, I want the last 3. My primary key field is townID.
Getting ALL My Records To Display
In this code, almost everything is working perfectly, but for my second query, I have six records that I want displayed in their own table like I have. I know that a loop would probably work, but I am just really not sure how to go about this. I would like the code to display a table of each of the records. Code:
Deleteing From Records
Ive created a mailing list using php3, and i'm trying to make an unsubscribe, so far i have it set up to mail me with the email of the person(s) wishing to unsubscribe, and i have to do it manually. Code:
Printing Records With A Twist
I have a problem that I have been working on for weeks and I cannot get it to work. I thought someone might have done this or could be of assistance. I have name and football positions in a database. I want to retrieve those names print them on the screen. The twist is, I have a certain number of positions (3 QB, 4 RB, 6 WR, etc.). If I have only 1 QB I want to leave 2 blank lines before I print the RB position and if I have 2 RB, I want to leave 2 blank lines before I print the WR Position, etc. Name, QB Blank Line Blank Line Name, RB Name, RB Blank Line Blank Line Name, WR If anyone has a way to loop through the recordset and do these, I would really appreciate it. It is probably pretty easy but I am new at PHP and I have just not had any luck.
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!!!
Displaying # Of Records In A Table
Can anyone throw me a link to some prefab code, or a tutorial on how I can get a page to display the number of records that meet a certain criteria. example: I have a page that stores information on audio FX. I'd like to include a feature that would let the users know how many items are in a particular section. Player (10) Items (5) Weapons (0) etc. All help appreciated,
Finding Records Within The Last 48 Hours?
I can't seem to find anything on querying to find records dated within the last 48 hours. Not just two days/calendar dates, but 48 actual hours. I'm hoping to do something like: SELECT record FROM table WHERE postdate > (NOW - 48hrs) does that make sense?
Limited Records Showing
When I read from mysql database it shows all the records. How can i make them show by 5 each page?
Counting Records In A Table
Ok, I am trying to count the number of records in one of my tables. Seems simple. BUT! its not working. It returns a 2 no matter how many records are in there. Heres the code. <?php $sql = "SELECT count(*) from cam"; $result = mysql_query($sql); ?> I would think this would work. I have also tried mysql_num_rows, and max(), and sum()... a little help would be appreciated, and why is it returning a 2?
Counting Number Of Records
I am trying to do 2 things. First, i want to count all the records that i get when i query the db. Second i want run a loop to display all of the info. The loop works fine, (it displays all the results) but when i try to count the records, it only echo's 1. Here is the code i'm using. PHP Code:
Updating Multiple Records
I have a form that lists query results (members, attributes) side by side, and allows someone to change the given attribute via a pick-list. I'd like to know how all of the member attributes (one for each member listed in the query results) can be updated at once. I have no problem implementing this when just one record is being updated, but as soon as there is more than one record I get into trouble. Here's a little diagram of what I'm trying to do: ------------------------------------------ Name | Attribute ------------------------------------------ Member1 | Pick List Member2 | Pick List Member3 | Pick List " etc " | " etc " ------------------------------------------ | Update |
Displaying Records, But Not Identical Ones.
I have a table with several rows. One column is "State", where, of course, a state is listed. I'd like to query the database and list all states in the rows, but I don't want multiple instances of the same state? How can I prevent it from showing:
Finding Unique Records
I have a text file with so many records. I need to find the unique name from the record. Format of text file...
Returning Unique Records
I'm fairly new to PHP and MySQL. I have a MySQL table that contains information on members of a club. I'll oversimplify and say the fields are first name, last name, and email address. Some members may share the same email address, say a husband and wife. So I might have two records, one for the husband and one for the wife, with the same email address. I need to return records from the table that only return unique email addresses. It doesn't matter which record I return when there is a duplicate email address, but I only want one record for each unique email address. I can use "SELECT DISTINCT email FROM Members", which gets me one record for each unique email address but omits the name fields. How do I write a SELECT statement that returns the other fields while only returning one record for each unique email address?
Updating Multiple Records
As my subject tells, my problem is to update multiple records simultanously. The post form in html contains in some cases the possibility to update, say, 4 email addresses (all with the field name "email"). How to process the input for such an update query? Yet, I numerated the email field names simply by stitching the counter in the loop on the field name (while generating the html form). Is this a good way to do it? And how to process the update?
Listing Records As Well As Insert
I'm getting all the data from a row of a table into a list box. On selecting a record in the list box, the corresponding records has to be displayed in the second list box. And now, i have 2 text boxes where the user can enter some text and then can insert into the table. In brief, i have 3 tables:thema, unterthema, artikel: Thema(Thema_id, Thema_name) Unterthema(Unterthema_id, thema_id, unterthema_name) Artikel(artikel_id, unterthema_id, artikel_name, artikel_content) So, at first, i'm displaying the records from thema_name in a list box. Now, when the user selects the record, the second list box has to be filled with unterthema_name. Now, the user can enter some text and it will be inserted into the fields(artikel_name and artikel_content).
Print Non Duplicate Records
I want to search a table and display the records which are not duplicated in a different field of the same table. For instance I can print the duplicate records with this piece of code:
Imports Only 1000 Records To Db
When I import records to database from an text file or excell file using PHPMYADMIN, only 1000 records are entered. I have 3000 records in file, but 1000 upload ...
Next/previous Records (not Pages)
I have a perl script (DBMan) running which can be viewed at http://embassylinks.com (select Cyprus as Guest for testing) The perl script uses a flat file, but I am switching to MySQL, so I am writing my own PHP viewing script. I want to have the same navigation on the php script as the perl script. I already have the "pages" navigation (i.e. Prev 1 2 3 Next) for the table of records nearly worked out, but I still need to do the "record" navigation (i.e. Record 1 of 120) for the individual records when clicking on the hyperlink in the table to display the individual record. The best way to understand what I mean is to look at the 2 scripts above and see the actual examples. Can anyone point to a sample script or offer some ideas for the "record navigation". I am looking for something like the "first prev next last" record links that most databases display.
|