Forum Moderators: coopster

Message Too Old, No Replies

deleting entries in a database

how to delete entries

         

flying monkey

3:40 am on Dec 1, 2003 (gmt 0)

10+ Year Member



ive got the reading and writing to a database working but want to delete entries............how would this be done?

figment88

4:34 am on Dec 1, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



you just issue a delete query such as

$sql="delete from TABLE";
$result = mysql_query($sql);

TABLE above is just a placeholder for the name of your specific table.

If you want to selectively delete use a WHERE clause.

flying monkey

11:34 pm on Dec 1, 2003 (gmt 0)

10+ Year Member



well im using an access database

figment88

12:03 am on Dec 2, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



well then replace mysql_query with how you implement select and insert queries. The main point is that delete is just another type of SQL query.

flying monkey

2:49 am on Dec 2, 2003 (gmt 0)

10+ Year Member



it gives me a erorr saying "[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression."

but when i tell it to display the variable with the number to delete it prints out the right number

figment88

2:57 am on Dec 2, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I saw your post on the other board

you have:
$SQL_Exec_String = "Delete From People Where ID = '$id'";

since $id is in single quotes access thinks you are giving it a character variable instead of a numeric one like it is in the database. Hence type mismatch.

try:
$SQL_Exec_String = "Delete From People Where ID = $id";

you realize many of your problems stem from trying to stick a square peg in a round hole. Most people who work with access (or sql server) stay in the microsoft way of doing things and code in ASP. People who code in PHP tend to use mySQL, PostGress, or other databases so there is no need for ODBC.

flying monkey

3:05 am on Dec 2, 2003 (gmt 0)

10+ Year Member



hmmmmmmm. thanks. the seggestion u made seemed to work thanks

flying monkey

3:17 am on Dec 2, 2003 (gmt 0)

10+ Year Member



what is a condition is not met and want to skip that one function only and run the rest of the program....how whould this be done

flying monkey

3:18 am on Dec 2, 2003 (gmt 0)

10+ Year Member



what if a condition is not met and want to skip that one function only and run the rest of the program....how whould this be done

figment88

3:44 am on Dec 2, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



well that's kind of the basis of all software programming.

if some condition is met then do something is called a control structure(If-Then). There are other control structures such as If-Then-Else, For, Do-While, etc.

Check out the manual entry:
[us2.php.net...]