Jump to content

display record number


fazzfarrell

Recommended Posts

Can any one point me in the right direction.

I have a database with 300 products with 6 sections, so product numbers 1-100 belong to Dogs, 101-150 belong to cats etc.

I have set up a link on a page that will go to the next record in that section, and it also displays the amount of records in that section.

What I want to do is have it saying record 1 of 100, when you click on the link it will then be record 2 of 100 etc.

I can display the record ID, but of course on the second section it will dis play record 101 0f 49

Any one help?!
Link to comment
https://forums.phpfreaks.com/topic/34870-display-record-number/
Share on other sites

Did nt quite get this, but noe I have added this

[code]
<?php

    if($_GET['ID'])

    {

        $page = $_GET['ID'];

    }else{

        $page = 1;

    }?>[/code]

This gets the page number from the ID, I am at the moment trying to change it so if the ID no is > 1 numbering will start at 1

any ideas?
Link to comment
https://forums.phpfreaks.com/topic/34870-display-record-number/#findComment-164473
Share on other sites

Create another table in your database for your sections. Include a section ID and maybe a section name.

Now fo your products create a column which holds the section id.
[code]
$section_id = $_GET['section'];
$query = "SELECT * FROM table1, sections WHERE table1.section_id=sections.section_id AND section=$section_id ORDER BY table1.section_id ASC";
$result = @mysql_query($query);
$num = mysql_num_rows($result); // number of products in specified section.

// Returns products from only 1 section at a time
[/code]

A link would look like this,
http://www.domain.com/page.php?section=1&product=67

Hope this helps.
Link to comment
https://forums.phpfreaks.com/topic/34870-display-record-number/#findComment-164505
Share on other sites

Errmmm?

I have one table with all the products in, numbered 1 - 300.

The way the dat call in at the mo is one section at a time anyway, so I have no problem with that. It is the next and previous buttons, they all work and only calls the data in I want.

If I click the result from the first section it brings up record 1 of 10, but if i click the second section it say record 11 of 10. It is just the number of the record I have a problem with I want it to see the first record as 1 and when you click 'next' it will be record 2 and so on although the ID is 11

ta
Link to comment
https://forums.phpfreaks.com/topic/34870-display-record-number/#findComment-164515
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.