MySQL and website

Is it possible to create a database in MySQL Workbench and apply it to website? For example, database of website users.

Your question is vague enough in its definition that I can answer “Yes”, but that probably won’t help you much. What do you mean by “apply it to website”? What language / framework are you building your website in?

1 Like

It is PHP.

Effectively you are asking if you can create a database in MySQL Workbench, and use PHP to display its data on a website.

Again, “Yes”. But it’s still a very broad subject. Please have a look at PHP’s own documentation on MySQL integration.

Thank you for your reply. Maybe my question was not correct. It’s because I haven’t learned MySQL yet. It seems to me very difficult. And to create a database in MySQl Workbench is my homework at university. Lecturer said to make it. So I am thinking how to make it. If I am learning PHP and creating a website maybe I can make a database in my website, even though I have no idea how to make it. I want to hear some recommendations from programmers.

Well, it is different from phpMyAdmin which many use, so it may take a bit getting used to it.

Ideally you have both Workbench and a localhost running PHP set up on your computer.

IMHO a good place to start is to open Workbench click on MySQL Doc Library, and then, after reading (or skimming) the earlier chapters click on
5. Getting Started Tutorial

It may take you a while to get to the point where you don’t need to reference the steps every time (it did me) but it worked for me.

If you get stuck or don’t understand something, just ask.

Yes, it is possible in MY SQL Workbench and apply to PHP website.
here is an example of this and it may help you.
In MY SQL with PHP, Creating a database having two parameters True and False, if DB creation success then True otherwise False if unsuccessful.
Syntax: bool mysql_query( sql, connection );

<?php
$dbhost = 'localhost:3036';
   $dbuser = 'root';
   $dbpass = 'rootpassword';
   $conn = mysql_connect($dbhost, $dbuser, $dbpass);   
   if(! $conn )
   {
      die('Could not connect: ' . mysql_error());
   }
   echo 'Connected successfully';
   $sql = 'CREATE Database test_db';
   $retval = mysql_query( $sql, $conn );
   if(! $retval )
   {
      die('Could not create database: ' . mysql_error());
   }
   echo "Database test_db created successfully\n";
   mysql_close($conn);
?>

Your feedbacks are always appreciated.

@Jason_Clark - Please don’t teach someone who’s new to PHP/MySQL to use deprecated extensions :frowning: seems like a good idea to start them out on the right foot, instead :smiley:
Here’s an article discussing the merits of using PDO http://www.sitepoint.com/migrate-from-the-mysql-extension-to-pdo/
It’s even a bit old, but the need to switch is obviously even more true today than it was then.

@Katze do you already know PHP or are you just learning that as well?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.