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

  • SEARCH
  • Home
  • 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 7855073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:16:26+00:00 2026-06-02T20:16:26+00:00

I am writing a web application in PHP which will store employee data and

  • 0

I am writing a web application in PHP which will store employee data and generate employee ID cards to PDF. I am using FPDF for creation of PDFs and that works fine. I am having a problem with showing results from MySQL database.

I have to generate PDF with 4 employee ID cards and I am not sure how to get them from the database. So far I am using LIMIT option in the query to get only 4 results and i will have an if statement based on mysql.php?id=1 id which will define the limit. It is a little messy but there are not going to be more than 80 employees.

This is my code:

$id = $_GET['id'];

if ($id == 1) {
$limit_start = 0;
$limit_end = 4;
}

$result=mysql_query("SELECT users.tajemnik, users.dateCreated, users.showmeID,     
users.workerName, users.dateCreated, users.workerPlace, users.workerSID, uploads.userID, uploads.data, uploads.filetype
 FROM users INNER JOIN uploads ON users.showmeID = uploads.userID ORDER BY workerName DESC LIMIT $limit_start, $limit_end") or die (mysql_error());
mysql_query("SET NAMES 'utf8'") or die('Spojení se nezdařilo');

while($row = mysql_fetch_array($result)){

$workerName = $row["workerName"];
$workerPlace = $row["workerPlace"];
$workerSID = $row["workerSID"];
$tajemnik = $row["tajemnik"];
$showmeID = $row["showmeID"];
$mysqldatetime = strtotime($row['dateCreated']);
$image = $row["data"];

$phpdatetime = date("d.m.Y",$mysqldatetime);

}

This will get me the first result from the query. I need to get information from all 4 rows and have them stored in variables like $workerName1, $workerName2 etc. I hope it makes sense what I am trying to do.

Thank you for your replies!
V.

  • 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-06-02T20:16:27+00:00Added an answer on June 2, 2026 at 8:16 pm

    I need to get variables like $workerName1, $workerName2 etc

    Nope, you don’t.
    You actually need an array.

    So, first, get yourself a function

    function sqlArr($sql){
      $ret = array();
      $res = mysql_query($sql) or trigger_error(mysql_error()." ".$sql);
      if ($res) {
        while($row = mysql_fetch_array($res)){
          $ret[] = $row;
        }
      }
      return $ret;
    }
    

    then write a code

    mysql_query("SET NAMES 'utf8'") or die('Spojení se nezdařilo');
    $sql = "SELECT users.tajemnik, users.dateCreated, users.showmeID, users.workerName, 
                   users.dateCreated, users.workerPlace, users.workerSID, uploads.userID, 
                   uploads.data, uploads.filetype
            FROM users 
            INNER JOIN uploads ON users.showmeID = uploads.userID 
            ORDER BY workerName DESC LIMIT $limit_start, $limit_end";
    $data = sqlArr($sql);
    

    Now you have all your data in the $data array.
    So, you can loop over it or access single values like

    echo $data[0]['tajemnik'];
    

    or

    foreach($data as $row) {
      //do whatever you want with database row
      echo $row['tajemnik'];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a web application which retrieves a lot of data using AJAX
I'm writing a web application in PHP which needs to store images and image
I'm currently writing a web application which uses forms and PHP $_POST data (so
I'm writing a php web application using Yii and need to use C++ (will
I am writing one web application using PHP/CodeIginter. Now, I want to add a
I'm writing a PHP web application which is capable of analyzing requested resources before
I'm working on writing a web application using php & mysql, and was wondering
I'm a bit obsessed now. I'm writing a PHP-MYSQL web application, using PDO, that
I am writing a stateful web application in PHP in which the state potentially
I'm writing a PHP application which uses a number of SOAP web services to

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.