• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 298
  • Last Modified:

Get data from MySQL to fill in data in a webpage

Hello. I am going to create a webpage that gets data from a MySQL table on a Linux server to populate a table in a webpage.

How would I go about doing that?

0
DBDevOne
Asked:
DBDevOne
1 Solution
 
Codeit1978Commented:
First What scripting language is your page in?
0
 
DBDevOneAuthor Commented:
The language doesn't matter. I'm open for suggestions.
0
 
alain34Commented:
php is the most widely used scripting language on the linux platform for creating dynamic webpage. It is really straightforward as well. It is also platform independant, therefore you can even make it work on windows.
Check out http://www.php.net
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
Jankit141180Commented:
HELLO.

I HAVE TRIED WITH PHP. AND THE SCRIPT FOR THE SAME IS GIVEN BELOW ...

<?
//making connection to the database
$host = "192.1.1.204";//give ip of your mysql server
$user = "root"; // give user name to login mysql database
$pwd = ""; // give password of your mysql database
$db = "mydb"; // give database name

$link = mysql_connect($host , $user , $pwd) or die ("Couldn't connect to server.");
$db = mysql_select_db($db) or die ("Couldn't select the database.");

//HERE WE HAVE MADE THE CONNECTION TO THE DATABASE

//NOW MAKING QUERY FOR GETTING RECORDS from table1

$strQuery = "select * from table1";

$resultSet = mysql_query($strQuery) or die("Error occured while getting detail from table1.");

//now checking if retrieved records are more than zero
if(mysql_num_rows($resultSet)>0)
{
  //fetching result in the variable
  while($rowResult = mysql_fetch_array($resultSet))
  {
    //printing detail on the browser
    echo $rowResult[0]."<br>";
  }
}

//free sql retrieved result
mysql_free_result($resultSet);
?>

This script works fine.

Rest if you didnt get it then feel free to ask me further. I would glad to cooperate you.

With regards,
Jankit
0
 
Jankit141180Commented:
Hello

One more thing in concern with my previous post  ....

I have not included any HTML formatiing in my script.
The script will print only first column on the browserand accordingly you are requested to do formatting.

Thank You
-Jankit
0
 
UltimatCommented:
This example is a php example ( with mysql ).
This is a bit shorter and perfect for writing your first databasedriven script ( in the future it is beter to exclude the first part and put in an other file , so it is better to make updates f.e. username , otherwis you have to change it on each page - for this use include)

$hostname_db = "server";
$database_db = "databasename";
$username_db = "username";
$password_db = "pwd1";
$db = mysql_pconnect($hostname_db, $username_db, $password_db) or trigger_error(mysql_error(),E_USER_ERROR);

mysql_select_db($database_db, $db);
$query_producten = "SELECT * FROM producten ";
$producten = mysql_query($query_producten, $db) or die(mysql_error());
$row_producten = mysql_fetch_assoc($producten);

do{
   echo($row_producten['field']);
} while ($row_producten = mysql_fetch_assoc($producten));

Greetz Ultimat
0
 
DBDevOneAuthor Commented:
Thank you very much Jankit and thank you all for the comments. I appreciate it!
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now