row identifier

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • VeSn@

    row identifier

    Hello!

    I need advice on how to identify a row with particular field
    value?

    I have a table with 3 fields: id, title, date.

    I need to know the order number for the row where
    title=sometitle .
    I need it for the $start variable in next query:

    Code:
    # make a query on a table in your database
    // $start = ???;
    $query = "SELECT * FROM table LIMIT $start,1";
    $query_result_h andle = mysql_query ($query)
    or die ('The query failed! table_name must be a valid table
    name that exists in the
    database specified in mysql_select_db ');

    # make sure that we recieved some data from our query
    $num_of_rows = mysql_num_rows ($query_result_ handle)
    or die ("The query: '$query' did not return any data");

    print "The query: '$query' returned $num_of_rows rows of
    data.<br>";

    # use mysql_fetch_row to retrieve the results
    $row = mysql_fetch_row ($query_result_ handle);
    print "The name is '$row[1]'";


    What i am trying to acomplish is to get the data of the next row
    of current row in which title = sometitle.
    Any help/advice appreciated.

    --
    Vesna
    http://forum.moljac.hr OBAVEZNO SKOKNITE!
    _______________ _______________ _______________ _______________ _____
    Implementation is the sincerest form of flattery.
  • Geoff Berrow

    #2
    Re: row identifier

    I noticed that Message-ID: <4p97qvshs1n6l3 bguhkoj0i4cn696 s9a40@4ax.com>
    from VeSn@ contained the following:
    [color=blue]
    >I need advice on how to identify a row with particular field
    >value?
    >
    >I have a table with 3 fields: id, title, date.
    >
    >I need to know the order number for the row where
    >title=sometitl e.[/color]
    But you don't have a field called order number
    [color=blue]
    >I need it for the $start variable in next query:
    >
    >Code:
    ># make a query on a table in your database
    >// $start = ???;
    >$query = "SELECT * FROM table LIMIT $start,1";[/color]

    I don't know what that $start is doing there.

    --
    Geoff Berrow
    It's only Usenet, no one dies.
    My opinions, not the committee's, mine.
    Simple RFDs http://www.ckdog.co.uk/rfdmaker/

    Comment

    • VeSn@

      #3
      Re: row identifier

      Geoff Berrow <blthecat@ckdog .co.uk> u comp.lang.php:[color=blue][color=green]
      >>I need advice on how to identify a row with particular field
      >>value?
      >>
      >>I have a table with 3 fields: id, title, date.
      >>
      >>I need to know the order number for the row where
      >>title=sometit le.[/color][/color]
      [color=blue]
      >But you don't have a field called order number[/color]

      i do, but what when some rows are deleted?
      I solved it using id>$start in query.
      [color=blue][color=green]
      >>I need it for the $start variable in next query:
      >>
      >>Code:
      >># make a query on a table in your database
      >>// $start = ???;
      >>$query = "SELECT * FROM table LIMIT $start,1";[/color]
      >
      >I don't know what that $start is doing there.[/color]

      to tell the query where to start :-)

      it`s ok, I solved it.

      --
      Vesna
      http://forum.moljac.hr OBAVEZNO SKOKNITE!
      _______________ _______________ _______________ _______________ _____
      I came, I saw, I deleted all your files.

      Comment

      Working...