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 97989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T00:06:37+00:00 2026-05-11T00:06:37+00:00

I just had some basic php questions to further my understanding as I learn,

  • 0

I just had some basic php questions to further my understanding as I learn, that I could not find easy answers to

  1. I have a php ajax application that generates a table of mysql rows. I would like to know if there is a way to get php to generate neat html, as it seems neat enough as I echo it out, but when ‘viewing source’ the html is a huge jumbled block with no line breaks or anything. Is there a trick to doing this?

  2. What is the best way to limit table output for a mysql database, so only the first 10 records or so are displayed, and there are automatically generated next and previous links to go between records?

  3. When outputting information with php from a mysql database, what is the best way to handle booleans? What is the easiest way to display the words ‘yes’ or ‘no’ or a tick or a cross? edit: I do not mean should I use words or pictures, but rather how to show either in response to a boolean

  • 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. 2026-05-11T00:06:37+00:00Added an answer on May 11, 2026 at 12:06 am

    Question 1

    You need to separate the PHP code and the HTML output. The easiest thing to do, as a newbie, is :

    • Fill a var named $tab with your entries.

    • Create a file called "my_tab_template.php" including your xHTML code, using very few PHP to unpack $tab and only with the PHP alternative syntax.

      <table>    <?php foreach ($tab as $line) : ?>       <tr>          <?php foreach ($line as $cell) : ?>            <td><?php echo $cell ?></td>          <?php endforeach; ?>       </tr>     <?PHP endforeach; ?> </table>   
    • Include my_tab_template.php right after you have filled $tab.

    Don’t worry about optimization and performances, this will certainly not be your website bottleneck as you starting to code and you will make some things far more troublesome 😉

    Then, in your next project, when you will feel fine doing this, try to learn about the MVC pattern (a little search on SO may help). Don’t listen to people talking about templating systems, and else. Don’t try to start running a 150 cc before passing your driving licence.

    Question 2

    This is not a PHP question. What you want to do is to limit the output from your database. You can do that using the "LIMIT" SQL keyword.

    You can use :

    • LIMIT 10 : this will limit your query to the 10 first row (= LIMIT 0,10)

    • LIMIT X, Y : this will limit your query to Y rows, starting from the row X

    Remember to sort your query result with "ORDER BY" before using LIMIT to avoid nasty surprises.

    And there is no automatic pagination in PHP. There are some PHP libraries that does the dirty job for you, but before you use them, I recommand to hack your own solution first to understand the mechanism. It’s just about checking vars and using "LIMIT", really.

    Then you may have a look to PEAR where a standard way to do it exists. But don’t try too hard to find it, you’d better code it yourself first.

    Question 3

    If your database store a boolean, therefore it will output "0" for false, anything else (most probably "1") for true. Just test it :

    if ($my_bool)      echo "True"; else    echo "False"; 

    In PHP, there is a shortcut to say that, but you have no obligation to use it. Anyway, it’s good to know it exists. Meet the boolean operator :

    echo  $my_bool ? "True"  : "False" ; 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 165k
  • Answers 165k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer There are a couple of variants of a rename command,… May 12, 2026 at 12:33 pm
  • Editorial Team
    Editorial Team added an answer There is currently no way to build CLS-compliant assemblies from… May 12, 2026 at 12:33 pm
  • Editorial Team
    Editorial Team added an answer You might want to look at Google Protocol Buffers or… May 12, 2026 at 12:33 pm

Related Questions

Ok, have a bunch of questions that I have been thinking about the past
I'm trying to do some very basic time math - basically, given inputs of
I have been interested in learning Rails for some time now and feel now
I just downloaded Zend Server Community Edition for windows and found that it did

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.