mysql_affected_rows

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • xyrhou
    New Member
    • Mar 2010
    • 14

    mysql_affected_rows

    i found this mysql_affected_ rows in php.net but there is no example for SELECT.

    i want to select the last save image then preview it by calling its url at the database.. is it possible with mysql_affected_ rows? or should i go for mysql_data_seek ()?

    Im still a newbie and still exploring the wonders in php.. though im guilty that i just copy and paste code and try to understand its function..

    i cant find a mysql_affected_ rows with SELECT.. the samples are DELETE etc..

    thank you for reading my post.

    hope you can help me with these..

    thanks..
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    As the documentation says, it only works on INSERT, UPDATE, REPLACE or DELETE operations. For a SELECT operation, see mysql_num_rows( ).

    Comment

    • xyrhou
      New Member
      • Mar 2010
      • 14

      #3
      one more question sir.

      i want to select the last row that was inserted at the database by selecting it in
      Code:
      <?php
      include("connection.php");
      	$sql = mysql_query("SELECT * FROM image WHERE ImgID = '" . $ImgID . "'") or die(mysql_error());	
      	
              $row = mysql_fetch_array($sql);
      
      echo "<img src=view.php?image=". $row['url'] . "&amp;mode=resize&amp;size=350x500 />";
      
      ?>
      but i only want to select the last row..

      can you please help me with these?

      i want to output the last image that was save in the database..

      image is the table with fields ImgID, ImgTitle and url.

      image is the table

      Comment

      • xyrhou
        New Member
        • Mar 2010
        • 14

        #4
        i finally got it.. ^_^

        i just add ORDER BY ImgID DESC LIMIT 1

        sorry for the newbie trouble..

        Thanks ^_^

        Comment

        • Markus
          Recognized Expert Expert
          • Jun 2007
          • 6092

          #5
          We were all newbies once :)

          Comment

          Working...