View Single Post
  #7 (permalink)  
Old 01-16-2004, 05:44 PM
compusolver's Avatar
compusolver compusolver is offline
WebProWorld Member
 

Join Date: Sep 2003
Location: Oklahoma
Posts: 94
compusolver RepRank 0
Default

After you've got your database created (which it sounds like you have) try something like this:

Code:
  
<?
  // assumes $server,$user,$password and $dbname have been defined
  @mysql_pconnect($server,$user,$password);
  mysql_select_db($dbname);
  $tablename = "countries";
  $sql = "CREATE TABLE $tablename (
    country char(2) NOT NULL primary key,
    display char(50) not null
  )";
 mysql_query($sql) or die("ack! query failed");
 $display = addslashes("AFGHANISTAN"); // in case there were single quotes, etc.
 $sql = "INSERT INTO countries (country,display) VALUES ('AF','$display')";
 mysql_query($sql) or die("ack! query failed");
?>
Please don't be too hard on John (jwm5411). If you're just playing around on your own site, this is a great way to learn, but all too often web designers try to learn on a clients 'nickel'. If you're doing this for a client, please do heed John's advice.
__________________
- Hank Castello
www.CompuSolver.com
www.SmBizHosting.com
Hosting, eCommerce Gateways & affordable subcontract programming/consulting
Reply With Quote