Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Get exact row from database table

Guest
Jul 31, 2009 Jul 31, 2009

This is part of my source code that displays one row from getQuest recordset. Always first.

<body>

<p><?php echo $row_getQuest['content']; ?></p>
<p>: <?php echo $row_getQuest['prom1']; ?></p>
<p><?php echo $row_getQuest['prom2']; ?></p>
<?php echo $row_getQuest['dos1']; ?>(); <?php echo $row_getQuest['dos2']; ?> (); <?php echo $row_getQuest['dos3']; ?> (); <?php echo $row_getQuest['dos4']; ?>(); <?php echo $row_getQuest['dos5']; ?> (); <?php echo $row_getQuest['dos6']; ?> (); <?php echo $row_getQuest['dos7']; ?> ().

</body>

Can i change it so, that on this page it always displayed row with exact position in the table - for example second or 15th - independently of row contents and rows deletition, moving or changing in table?

TOPICS
Server side applications
948
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Jul 31, 2009 Jul 31, 2009

Set auto increment int id in database for each record then filter recordset where id = entered value.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 31, 2009 Jul 31, 2009

But if I add 5 rows to table, then delete all of them and add 5 again - auto incremented id will 6 for first in table and 10 for last. If i delete all and add 5 again it will be 11...15 and so on. As I said - I cannot rely on row contens - because I'm planning to delete and add data from that table frequently. Or other solution could be to allways keep id from 1 to [amount of rows]. I do not know how this is done.

Or am I wrong about id?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Jul 31, 2009 Jul 31, 2009

Then add a id row in your database, not auto increment, and in insert record add a field where you can id the record. Then filter recordset based on your inserted record id. It's the same concept in that you're id-ing your record and filtering the recordset based on the id.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 31, 2009 Jul 31, 2009

Yeah, I think it is the only way, but still seems a little freaky to me that there are no simple (or any) solutions to pick some row depending only on the position in table. I'll leave it unanswered - I think the answer might be helpful in some situations. But anyway - thank You.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 31, 2009 Jul 31, 2009
LATEST

What exactly do you mean by a row's position in a table? Rows in tables are not stored in any particular position.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines