Jump to content

connect to database table


josh48202

Recommended Posts

i need help connecting to 1 specific database table

 

im already connected to mysql using this code

 

<?php

mysql_connect("localhost", "XXXXX", "YYYYY") or die(mysql_error());

echo "Connected to MySQL<br />";

mysql_select_db("VVVVV") or die(mysql_error());

echo "Connected to Database";

?>

 

what else do i need to connect to the table?

Link to comment
Share on other sites

This is the standard way of getting a result set:

mysql_connect("localhost", "XXXXX", "YYYYY");
mysql_select_db("VVVVV");
$result = mysql_query("SELECT * FROM tablename");

while($row = mysql_fetch_assoc($result)) {

print $row['columnname'];
print $row['columnname2'];

}

 

That's all that can be explained in a normal post. For more information, you really have to do research on how MySQL queries are formed and such.

 

http://www.sqlzoo.net/

 

And there are a billion tutorials on MySQL and PHP.

Link to comment
Share on other sites

You can't "connect" to a table. Now that you are connected to a mysql database, you can run various queries on it- including selecting data from a table, inserting or updating the data in the tables, deleting tables and much more. You should read some php+mysql tutorials the will teach you how to do all of the things that I've mentioned above. Just start reading (links).

 

Orio.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.