PHP passes query database specified record based on URL parameter

Source: Internet
Author: User
Keywords Web Programming PHP Tutorials
Tags .url based exit is_numeric mysql_query php programming saved

$id =isset ($_get[' id ')? $_get[' id ']: ';
if (!is_numeric ($id)) {
Exit ("Sorry, the user you visited <script>alert!"); History.back ();</script> ");
}else{


$sql = "SELECT * from Wk_member where id= ' $id '";
MySQL tutorial _query ("Update wk_member set m_hit=m_hit+1 where id= ' $id '");
mysql_query ("Update wk_works set w_browse=w_browse+1 where m_id= ' $id '");

$result =mysql_query ($sql) or Die (Mysql_error ());
if (mysql_num_rows ($result)) {
$rs =mysql_fetch_array ($result);
$no = $rs [' M_uid '];
$hit = $rs [' M_hit '];
Mysql_free_result ($result);
$sql = "SELECT * from Wk_works where m_id= ' $id '";
$result =mysql_query ($sql) or Die (Mysql_error (). $sql);
$w _dec = ' not written declaration ';
$w _head = ' images/head.gif ';
$w _support = 0;
$w _blog = ' The author has not yet uploaded the works ';



if (mysql_num_rows ($result)) {
$rs =mysql_fetch_array ($result);
$w _support = $rs [' W_support '];
$w _browse = $rs [' W_browse '];
$w _dec = $rs [' W_dec '];
$w _head = $rs [' w_lt '];
$w _blog = $rs [' W_blog '];
}

}else{
Exit ("Sorry, the user you visited <script>alert!"); History.back ();</script> ");
}
}

Database Tutorial Connection Program

mysql_connect (' localhost ', ' root ', ' 1****** ') or Die (' database server no exists! ');
mysql_select_db (' wk ') or Die (' Database error! ');
mysql_query ("SET NAMES ' GBK");//set document CharSet encode

Webmaster designated, this is nothing good to specify, is the basic MySQL query, and then get the results assigned to the corresponding variable.

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.