Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Defaulting a limit to display

Avatar of pingeyeg
pingeyeg asked on
PHPSQL
19 Comments1 Solution256 ViewsLast Modified:
Is there a way to make a default limit unless otherwise specified via a sql statement?  I am using JQuery and AJAX to change the limit to list on the page and I would like for 10 to be the default limit unless the user changes this.

if($_GET['act'] == 'getNum') {
            $number = $_GET['change'];
            
            $getUsers = sprintf("SELECT id, username, answer_point, howto_point
                  FROM login
                  LIMIT %d", $number);
            $showUsers = mysql_query($getUsers) or die("Users not showing because: " . mysql_error());
                  while($u = mysql_fetch_array($showUsers)) {
                        if(!empty($u['answer_point']) AND !empty($u['howto_point'])) {
                              $points = $u['answer_point'] + $u['howto_point'];
                                    echo "      <div class='performer'>
                                                            <div class='user'>{$u['username']}</div>
                                                            <div class='points'>$points</div>
                                                      </div>
                                                ";
                        }
                  }
      }
ASKER CERTIFIED SOLUTION
Avatar of Ionut A. Tudor
Ionut A. TudorFlag of Romania imagePHP Programmer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 19 Comments.
See Answers