PHP joins MySQL

Source: Internet
Author: User
Tags joins vars

<?php

  • echo "This is a test</br>";
  • echo "ASDFASDFADSF";
  • $mysql _server_name="localhost:3306"; //Database server name
  • $mysql _username="root"; //Connect database user name
  • $mysql _password="Rootpass"; //Connect database password
  • $mysql _database="dbname"; //Database name
  • //Connect to database
  • $conn =mysql_connect ($mysql _server_name, $mysql _username,
  • $mysql _password);
  • //SQL statement that extracts information from a table
  • $strsql ="Select Val from tsys_hashtable where ' key ' = ' vmall_version '";
  • //Execute SQL query
  • $result =mysql_db_query ($mysql _database, $strsql, $conn);
  • //Get query Results
  • $row =mysql_fetch_row ($result);
  • echo ' <font face= ' Verdana > ';
  • echo ' <table border= ' 1 "cellpadding=" 1 "cellspacing=" 2 ">";
  • //Display field name
  • echo "</b><tr></b>";
  • For ($i = 0; $i <mysql_num_fields ($result); $i + +)
  • {
  • echo ' <td bgcolor= ' #000F00 ><b> '.
  • Mysql_field_name ($result, $i);
  • echo "</b></td></b>";
  • }
  • echo "</tr></b>";
  • //Navigate to the first record
  • Mysql_data_seek ($result, 0);
  • //Loop out record
  • While ($row =mysql_fetch_row ($result))
  • {
  • echo "<tr></b>";
  • For ($i = 0; $i <mysql_num_fields ($result); $i + +)
  • {
  • echo ' <td bgcolor= ' #00FF00 > ';
  • echo $row [$i];
  • echo ' </td> ';
  • }
  • echo "</tr></b>";
  • }
  • echo "</table></b>";
  • echo "</font>";
  • //Release Resources
  • Mysql_free_result ($result);
  • //Close connection
  • Mysql_close ($conn);
  • ?>

PHP joins MySQL

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.