Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7437215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:21:52+00:00 2026-05-29T10:21:52+00:00

How Can I make numbering on mySQL results. I was trying to use $_SESSION[],

  • 0

How Can I make numbering on mySQL results. I was trying to use $_SESSION[], But I am not able. Please help me

<?php

$id=$_POST['id'];
function showmember($id){
$int=$_SESSION['int']+1;
    $query = mysql_query("SELECT id,name,sponsorid,node FROM ".memberlogtbl." WHERE locationid='".$id."' ORDER BY join_time DESC LIMIT 500");
    $total=mysql_num_rows($query);
while($sql=mysql_fetch_array($query)){
 echo "<tr style='border:1px solid #777'>
    <td>&nbsp;$int</td>
    <td>&nbsp;".$sql['id']."</td>
    <td>&nbsp;".$sql['name']."</td>
    <td>&nbsp;".$sql['sponsorid']."</td>
    <td>&nbsp;".$sql['node']."</td>
    <td>&nbsp;".(date('d/m/y : h:iA', $sql['join_time']))."</td>
   </tr>";
   showmember($sql["id"]);
}
    mysql_free_result($query);
}
showmember($id);
}
unset($_SESSION['int']);

?>

I was trying to do like below:

1 H. Andri 17667 left 12/12/2011
2 A. Kumar 32321 left 12/12/2011
3 D. Das 12121 right 1/1/2012
….. so on numbering

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T10:21:53+00:00Added an answer on May 29, 2026 at 10:21 am

    First of all, sanatise your inputs. Use:

    $id=intval($_POST['id']);
    

    This way you’ll avoid a SQL injection attack.

    Secondly, you have a weird thing going on here… You are using a recursive function instead of just preparing a nice SQL statement… I’m not sure what you’re trying to do there but it looks really weird. Why are you doing it recursively? You are theoretically executing a large number of queries instead of just one, plus you have a weird structure going on there (you get id from the table and then prepare a statement where you use that value and compare it with locationid, what is your key/index in your table? Shouldn’t it be unique?)

    Thirdly, you can simply have a variable like $i which you increase ($i++) at the end of your while loop. At the moment you’re displaying some $_SESSION variable that I’m not sure what you’re using for. It will not work because you are not passing that variable in your recursive function, so it will always be the same. You can use $_GLOBAL values instead. But anyway, the best way is to simple prepare a variable for your while loop. So before your while clause add:

    $i = 1;
    

    and then at the end of your while loop add

    $i++;
    

    and display that variable in your first table cell.

    Finally I assume that memberlogtbl has been set as a constant as you are referring to it as such (i.e. you are not treating it as a variable, $memberlogtbl).

    Overall your code is really, really confusing and potentially has a lot of mistakes in it. I would consider rewriting it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can make a single row IKImageBrowserView by setting the [imageBrowser setContentResizingMask:NSViewWidthSizable]; but in
I can make a log in for easily, so that's not the problem. What
I can make smtplib send to other email addresses, but for some reason it
I can make a new , and that seems to work. But edit/update does
I can make the compiler give me an error (Use of variable prior to
I can make query to get the Master -Chile records. But how to display
I can make get or post request using urllib, but how do I make
May you can help me... many years ago my friend gave me php script
I can make a obj to use the canvas to draw like this: MyObj.myDiv
I'm attempting to figure out how I can reset the row numbering in mysql

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.