PHP MySQL Query database

Source: Internet
Author: User
Tags mysql query php mysql php mysql query
The code is as follows Copy Code

Session_Start ();
$conn =mysql_connect (' localhost ', ' root ', ' root ') or Die (' Database connection error ');
mysql_select_db (' demo ', $conn);
mysql_query ("Set names ' GBK '");
$US =$_session[' username '];
$selequery =mysql_query ("SELECT * from blog where author= ' $US ' ORDER by id desc") or Die ("Query failed");
?>

<?php while ($selerow =mysql_fetch_array ($selequery)) {

?>
<form action= "" method= "Post" name= "Modform" >
<table width= "100%" border= "1" >
<tr>
&LT;TD width= > Author:</td>
<td><?php echo $_session[' username '. " &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ". $selerow [' redate '];? ></td>
</tr>
<tr>
&LT;TD width= > Message title:</td>
<td><?php echo $selerow [' title '];? ></td>
</tr>
<tr>
<td> Message Content:</td>
<td><?php echo $selerow [' content '];? ></td>
</tr>
<tr>
&LT;TD colspan= "2" align= "center" ><input type= "Submit" value= "Modify" name= "sub" ></input></td>
</tr>
</table>
</form>
<br>

<?php}?>

<!--<?php
For ($i =1 $i < $selerow =mysql_num_rows ($selequery); $i + +) {
if ($i < $selerow =mysql_num_rows ($selequery)) {?>

<table><tr><td><?php echo $selerow [' title '];? ></td></tr></table>
<HR color= "Red" ><?php
}else{?>
<table></table>
<?php
}}



/*
drop table if exists ' blog ';
CREATE TABLE ' blog ' (
' ID ' int (a) NOT NULL auto_increment,
' Author ' varchar NOT NULL,
' title ' varchar NOT NULL,
' Content ' text,
' redate ' date not NULL,
Primary KEY (' ID ')
) Engine=innodb auto_increment=5 default CHARSET=GBK;

------------------------------
--Records of blog
------------------------------
insert INTO ' blog ' Valu Es (' 1 ', ' admin ', ' i ', ' <p> woo hoo </p> ', ' 2010-07-31 ');
INSERT INTO ' blog ' Values (' 2 ', ' admin ', ' V ', ' <p> my </p> ', ' 2010-07-31 ');
INSERT INTO ' blog ' Values (' 3 ', ' admin ', ' my ', ' <p> go to authoritative property law </p> ', ' 2010-07-31 ');
INSERT INTO ' blog ' Values (' 4 ', ' 111111 ', ' big arms ', ' <p> ' curved million </p> ', ' 2010-07-31 ');
 */

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.