NameSilo

SQL help please.

Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
SpaceshipSpaceship
Watch

Coolprogram

Established Member
Impact
7
I would like an example of how I would start off an SQL code. please help me with this. I have been wanting to know for quite some time so please help me.
Thanks,
-CP
 
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
PHP:
<?php
$sql = "SELECT * FROM table_name WHERE field='something'";
/* Above is a very common sql query used in verified that username is equal to the username in the database. */

$sql = "INSERT INTO table_name (name) VALUES('name')";
/* Above is a insert data into a database query */

$sql = "UPDATE table_name SET name='somethingelse'";
/* Above is a update value in database query */

$sql = "DELETE FROM table_name WHERE name='something'";
/* Above is a delete all the values where name is equal to something */

Following all these are
mysql_query($sql);
// That command processes the sql query
?>

Good Luck

- Steve
 
1
Close
Thaks a lot man I needed to know that.I only have 1 more question for you, that is how do i make a database??
-CP
 
0
Close
It would be something like

PHP:
<?php

$sql = "CREATE TABLE example(
id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), name VARCHAR(30), age INT)";
/* Above creates a table with AUTO INCREMENT (Or addes one everytime you add result) for field id. aswell as creates field name, and age. */

?>

I suggest you install PHPMyAdmin. It would make the creating of tables just that much easyer.

- Steve
 
0
Close
to create a database, it's simply
PHP:
<?php
mysql_query('CREATE DATABASE databasename');
?>
 
0
Close
Just a note most users do not have the correct permissions to create a database. The creation of a database on hosting packages is ussually carried out using their control panel rather than a query you personally execute.
 
0
Close
okay thank guys, I have 1 more question though...How would I do connect to MySQL??
Thanks,
-CP
 
Last edited:
0
Close
mysql_connect(<database host>, <database user name>, <database password>);

-Bob
 
0
Close
Thanks man, I really needed to know that. 'cause now I can connect some stuff to a data base. TY TY.
-CP
 
0
Close
DomainEasy: flexible LTO options. Close more domain deals with financing.

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Switch between accounts
You can now stay logged in to more than one NamePros account in the same browser. Click your avatar, then "Accounts in this browser", to...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back