Home arrow PHP arrow Page 9 - PHP 101 (part 4) - Look, Ma...It's Alive!

Nuking The People - PHP

One of the most compelling things PHP has going for it is it support for a wide variety of databases. And this week, PHP 101 is going to take advantage of that database support to create dynamic data-driven Web sites. This primer covers different techniques to select, insert and delete records, together with some tips to track and squash bugs when building SQL-driven sites.

  1. PHP 101 (part 4) - Look, Ma...It's Alive!
  2. Dumped!
  3. Hello Database!
  4. Different Strokes...
  5. ...For Different Folks
  6. What's In A Name?
  7. New Friends
  8. Today's Special
  9. Nuking The People
  10. Oops!
By: Vikram Vaswani and Harish Kamath, (c) Melonfire
Rating: starstarstarstarstar / 4
September 01, 2000

print this article


Finally, now that you've added a million users, it's time to do a little routine maintenance. This example demonstrates how to use the DELETE statement to wipe out a user and his list of sites. Again, the basic principles remain the same, with only the query string changing.

<?php // has the form been submitted? if($submit) { // connect to the database $conn = mysql_connect("localhost", "test", "test"); mysql_select_db("php101",$conn); $result = mysql_query("select title1,url1,title2,url2,title3,url3 from url_list where uid = '$username'",$conn); // check username $num_rows = mysql_num_rows($result); // if no rows are returned, the username is invalid. if(!$num_rows) { ?> <html> <head> <basefont face=Arial> </head> <body> <center> <font size="3">User not found</font><br> <a href="nuke.php4">Click here to try again</a> </center> </body> </html> <?php } else { // if username is valid, delete the bookmarks. $result = mysql_query("delete from url_list where uid = '$username'",$conn); ?> <html> <head> <basefont face=Arial> </head> <body> <center> <h3>Success!</h3> <?echo $username; ?>'s book marks have been deleted! </center> </body> </html> <?php } } else { // if form has not been submitted ?> <html> <body> <form action="nuke.php4" method="POST"> <table> <tr> <td> Username </td> <td> <input type="text" name="username" length=10 maxlength="30"> </td> </tr> <tr> <td colspan="2" align="center"> <input type="submit" name="submit" value="Delete Bookmarks"> </td> </tr> </table> </form> </body> </html> <? } ?>

>>> More PHP Articles          >>> More By Vikram Vaswani and Harish Kamath, (c) Melonfire

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates


Dev Shed Tutorial Topics: