Jump to content

Tutorial on Getting Mysql to display automatically...?


j152

Recommended Posts

I understand how to create an .html form that processes via a .php script to display a mysql database, but what I'm seeking is an online tutorial or a brief explanation of a command that I can use to make the mysql database automatically display whenever I visit a certain web page.

 

Instead of creating an .html page, would the webpage have to be a .php page that runs and displays information while also automatically formatting it on screen with my header and footer? 

 

And in order to display the correct row, would it have to be based on a user's cookie / session info?

 

I think I'm on the right track, but any tips that might get me going in the right direction would be greatly appreciated.

 

Thanks!

Link to comment
Share on other sites

using php:

 

$dbhost = 'localhost';
$dbuser = 'username';
$dbpass = 'password';
$maindb = 'databasename';

mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($maindb);

    $sql = 'SELECT * FROM column';
    $sqlresult = mysql_query($sql);

    while ($row = mysql_fetch_array($sqlresult))
    {
      $variable = $row['item'];      

      echo $variable;
    }

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.