last inserted row number.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • n8kindt
    New Member
    • Mar 2008
    • 221

    #16
    Originally posted by canabatz
    this code is working for me ,but i want it to display only the last inserted row ,position ,now i can display all the rows and the position ,but i need to show the user only his last bid position ,please help me figure this one out!!

    Code:
    $q = "(SELECT * FROM `bidding_details` where bid_id=$bid_id and sortbid = '1' order by bid_price desc) union all (SELECT * FROM `bidding_details` where bid_id=$bid_id and sortbid = '0' order by bid_price desc) order by sortbid desc, bid_price desc";
    $result=mysql_query($q) or die('Failed selecting applications: ' . mysql_error());
    $num1=mysql_num_rows($result);
    $rown = 0; 
    while($row = mysql_fetch_assoc($result)) 
    { 
        $rown++; 
        echo $row['bid_price']. ' is pos: ' . $rown . '.<br>'; 
    	
    }
    thank you
    ok, you're going to need to add a column to your table and designate it as a timestamp. when you create a new column in phpmyadmin it will give you the option of designating it as a timestamp and the mysql server will generate the current timestamp for you when a new row is inserted-just like the auto increment method you use for your primary key. you can also manually generate it in php using time() (or mktime() if not using the current date). once that is set up correctly, just sort your results by the timestamp field.

    Comment

    • canabatz
      New Member
      • Oct 2008
      • 155

      #17
      too complicated for me!

      this code i posted is giving me this result

      6.00 is pos: 1.
      5.00 is pos: 2.
      4.05 is pos: 3.
      4.04 is pos: 4.
      4.03 is pos: 5.
      4.02 is pos: 6.

      4.05 is the last bid inserted ,the id of this bid is the highest bid !

      what im try to solve is to display to the user this:

      your bid price of 4.05 is at position 3.

      i dont want to display all the results from all the users! only the last inserted!!

      thanx

      Comment

      • canabatz
        New Member
        • Oct 2008
        • 155

        #18
        please ,please ,someone?

        this is the only thing i got left to fix to open my site!!

        Comment

        • Dormilich
          Recognized Expert Expert
          • Aug 2008
          • 8694

          #19
          what about assigning a user id to the bid?

          Comment

          • canabatz
            New Member
            • Oct 2008
            • 155

            #20
            there is reg_id to the bid also!

            there is ,reg_id ,username ,bid_price , bid_date ,an email .

            i want the code to do like that:

            select from the table for all the result.

            start COUNT from the top ORDER by BID_PRICE DESC.

            find the SESSION_USERNAM E and look if the highest ID of the last bid_price entered by him

            if the Highest ID == session_usernam e stop count!

            echo $count $username!

            thats it!!

            Comment

            • canabatz
              New Member
              • Oct 2008
              • 155

              #21
              no help!!

              i searched all the web and none have any idea how to solve this!!

              can some one find a way to get the effected row numbe from a select query?

              take it as a challenge ,maybe it will help others !!

              please help ,than you!!

              Comment

              Working...