MySQL dynamic link to fetch the right row

前端 未结 2 1053
别跟我提以往
别跟我提以往 2021-01-23 23:03

I have a MySQL-database with x rows. Now I want to interpret a link, fetch the right row and print this values.

E.g. Link: .html?row=3 -> Opens site which fetch row 3

2条回答
  •  梦谈多话
    2021-01-23 23:46

    If it really has to be by row number (which can change depending upon the where or order by clauses), you can use the limit clause:

    SELECT * 
    FROM Tabelle1
    LIMIT 1000,1;
    

    A much better design is to have a unique key, and select a row based on that:

    SELECT * 
    FROM Tabelle1
    WHERE `id` = 1000;
    

    Since you didn't include the schema of the table, I just made up a column name as an example.

    To get the value passed to your php script, you can use:

    $row_num = $_REQUEST['row'];
    

提交回复
热议问题