By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,731 Members | 1,104 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,731 IT Pros & Developers. It's quick & easy.

how to establish relation between html and mysql

P: 3
hi,
i am new to mysql and i had to do a project using mysql.so can u please help me in finding out how to establish relation between html and mysql.its urgent.thankyou.
Dec 31 '07 #1
Share this Question
Share on Google+
6 Replies


eWish
Expert 100+
P: 971
There really is not a relationship between MySQL and HTML directly. You will need a programming language like Perl , PHP or other to get your data then create your HTML code with the results of your query embedded. This question would be better suited in the forum of the programming language you are using. What language are you using? Then I will move your post for you.

--Kevin
Dec 31 '07 #2

gits
Expert Mod 5K+
P: 5,317
hi ...

welcome to theScripts ...

there is no simple or better straight way from mysql to a html-page ... you need a serverside-script at least (PHP, ASP, JSP, whatever you want there ...) to connect to the DB and create html-content from the query-results ...

kind regards
Dec 31 '07 #3

P: 3
There really is not a relationship between MySQL and HTML directly. You will need a programming language like Perl , PHP or other to get your data then create your HTML code with the results of your query embedded. This question would be better suited in the forum of the programming language you are using. What language are you using? Then I will move your post for you.

--Kevin
thankx a lot for responding for my query.
actually i am using php,so now can u help me
Dec 31 '07 #4

P: 10
It's been a while since my PHP, so I had to refresh the memory with a google. I found this sample code from

http://www.apluskb.com/scripts/How_c...nswer2330.html

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
  3. if (!$link) {
  4.    die('Could not connect: ' . mysql_error());
  5. }
  6. echo 'Connected successfully';
  7. mysql_close($link);
  8. ?> 
The if is just to die if a connection to the database fails. The important part is the $link variable & connection.
Dec 31 '07 #5

Markus
Expert 5K+
P: 6,050
It's been a while since my PHP, so I had to refresh the memory with a google. I found this sample code from

http://www.apluskb.com/scripts/How_c...nswer2330.html

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
  3. if (!$link) {
  4.    die('Could not connect: ' . mysql_error());
  5. }
  6. echo 'Connected successfully';
  7. mysql_close($link);
  8. ?> 
The if is just to die if a connection to the database fails. The important part is the $link variable & connection.
And to select a database..

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. mysql_connect('localhost', 'mysql_user', 'mysql_password') or die(mysql_error());
  3. echo 'Connected successfully<br />';
  4. mysql_select_db('database_name') or die(mysql_error());
  5. echo 'Database connected.');
  6. mysql_close($link);
  7. ?> 
Dec 31 '07 #6

P: 3
And to select a database..

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. mysql_connect('localhost', 'mysql_user', 'mysql_password') or die(mysql_error());
  3. echo 'Connected successfully<br />';
  4. mysql_select_db('database_name') or die(mysql_error());
  5. echo 'Database connected.');
  6. mysql_close($link);
  7. ?> 
thankx a lot for the help
Jan 8 '08 #7

Post your reply

Sign in to post your reply or Sign up for a free account.