Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I need help learning mysql, inorder to set up a php4 message board

Status
Not open for further replies.

karouck

ISP
Feb 16, 2002
2
US
I have the most current stable form of mysql, and I have been tinkering with the admin and the mysql prompt (the thing that looks like dos) and I am having trouble figureing out what to do to connect to the sever I am hosting a site under. I want to upload phpmyadmin to work with it to set up a good mulit forum multi threaded messageboard for a clan site I am running. I just need some help figureing out what I must do to connect. and if you know how to install a message board, that would be even better, because I would like to know how to do it.
thank you
Karouck
 
You need a scripting language to act between your webserver and MySQL. PHP is a good choice. If you haven't done so already, get PHP installed on your webserver. The main site (php.net) has some very comprehensive guidance for installing PHP and running scripts. The key functions for using data from a MySQL database are
Code:
mysql_connect
,
Code:
mysql_query
, and
Code:
mysql_fetch_assoc
. A very simple example is below:
Code:
<HTML>
<HEAD>
<TITLE>Your page!</TITLE>
</HEAD>
<BODY>
<TABLE>
<?php
if ($linkup=mysql_connect('',yourusername,yourpassword)) {
  mysql_select_db(&quot;yourdb&quot;);

  $sql = &quot;SELECT * FROM yourtable&quot;;

  if (!$r=mysql_query($sql)) {echo mysql_error();} else {

    $headerrow=false;

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

      if (!$headerrow) {
        echo &quot;<TR>&quot;;
        while (list($k,$v)=each($row)) echo &quot;<TH>&quot;.$k.&quot;</TH>&quot;;
        echo &quot;</TR>\n&quot;;
        $headerrow=true;
        reset($row);
      }
      echo &quot;<TR>&quot;;
      while (list($k,$v)=each($row)) echo &quot;<TD>&quot;.$v.&quot;</TD>&quot;;
      echo &quot;</TR>\n&quot;;
    }

    mysql_free_result($r);

  }
}
?>
</TABLE>
</BODY>
</HTML>

-Rob
 
thank you very much., sorry for the late reply, been away on vacation.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top