This is PHP4 Code! $result = @mysql_query("UPDATE some_table SET image_filename = '', something_else = 4 WHERE indexer = $destid "); Example Update From An HTML Form <!——————————–> <!——————————–> <!—– ADD TO DATABASE FORM —–> <!——————————–> <!——————————–> <h2>Add To Database</h2> <?php if ( (isset($_POST[‘action’])) && ($_POST[‘action’] == "add_to_database") ) { $field1 = @mysql_real_escape_string($_POST['field1']); $field2 = @mysql_real_escape_string($_POST['field2']); […]
Category: Queries
PHP4 INSERT
This is PHP4 Code! $result = @mysql_query("INSERT INTO text_messages ( some_id, email_address ) VALUES ( $some_id, '$email' )"); DateTime Now Now(), Get Auto ID Of New Record $sql = "INSERT INTO some_table (list_name, user_id) VALUES ('$list_name', $user_id)"; @mysql_query($sql); $my_variable = mysql_insert_id(); The mysqli_insert_id() function returns the ID generated by a query on a table […]
PHP4 .SELECT General
This is PHP4 Code! w3schools.com SQL Guide Simple Get A Result $query = @mysql_query("SELECT user_name, password FROM member_profile WHERE email_address = '$user_name_login' AND password = '$password_login'"); $result = @mysql_fetch_array($query); $result_display_username = $result[‘user_name’]; $result_username = strtolower($result[‘user_name’]); Does Record Exist $query = @mysql_query("SELECT * FROM my_table WHERE some_field = $some_field AND some_field2 = $some_field2 AND some_field3 = […]
PHP4 DELETE
$result = @mysql_query("DELETE FROM some_table WHERE email_address='$email'"); Delete old records by date $result = @mysql_query("DELETE FROM messages_sent WHERE created_date < DATE_SUB(NOW(), INTERVAL 30 DAY)"); //Also: //INTERVAL 1 MONTH //INTERVAL 1 HOUR //etc Delete table Truncate is the fastest method to delete all data in a table as the table is dropped and re-creaed. $result = […]