Home > Backend Development > PHP Tutorial > 类写错了,如何只读一组数据

类写错了,如何只读一组数据

WBOY
Release: 2016-06-13 12:57:29
Original
973 people have browsed it

类写错了,怎么只读一组数据
class_img.php

<br>
	<?php <br />
<br>
<br>
<br>
class PicInfo<br>
{ <br>
	       // $sql= "select * from userinfo where username='$name' "; //书写sql <br>
	public function PicInfo($sql)<br>
	{<br>
            require_once("db_config.php"); //包含配置信息. <br>
	        $result= mysql_query($sql, $conn); // 执行查询语句<br>
	        $this->picInfo = mysql_fetch_array($result); //返回查询结果到数组<br>
		    $num_rows = mysql_num_rows($result);<br>
			mysql_query("set names UTF8");<br>
	        mysql_close($conn); //关闭数据库连接 <br>
	        $this->getInfo($num_rows); //调用传递信息的方法.<br>
	    } <br>
	    // 获取信息传递给属性的方法<br>
	<br>
	    private function getInfo($num_rows){ <br>
	        $this->pid = $this->picInfo["PID"]; <br>
	        $this->b_img = $this->picInfo["B_img"];	<br>
	        $this->m_img = $this->picInfo["M_img"];<br>
			$this->s_img = $this->picInfo["S_img"];<br>
			$this->indicate = $this->picInfo["Indicate"];<br>
			$this->type = $this->picInfo["type"];<br>
		   	$this->row = $this->picInfo['row']=$num_rows;<br>
	    } <br>
	      <br>
	    //返回每个属性的public 方法. <br>
		   public function getRow(){ <br>
		<br>
	        return $this->row; <br>
	    } <br>
	    public function getPid(){ <br>
		<br>
	        return $this->pid; <br>
	    } <br>
	      <br>
	    public function getB_img(){ <br>
	        return $this->b_img; <br>
	    } <br>
	       <br>
	    public function getM_img(){ <br>
	        return$this->m_img; <br>
	    } <br>
		  public function getS_img(){ <br>
	        return$this->s_img; <br>
	    } <br>
		  public function getIndicate(){ <br>
	        return$this->indicate; <br>
	    } <br>
		  public function getType(){ <br>
	        return$this->type; <br>
	    } <br>
	<br>
	}<br>
	<br>
	class edit_img<br>
	{<br>
	public function edit_img($sql)<br>
	{<br>
          require_once("db_config.php"); //包含配置信息. <br>
<br>
	        $result= mysql_query($sql,$conn); // 执行查询语句<br>
	     	$row=mysql_affected_rows(); //返回查询结果到数组<br>
			if($row
			{<br>
				echo "<script>alert('没插入数据!')</script>";<br>
				}<br>
				else{<br>
					echo "有".$row."组数据受到影响"; <div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template