PHP Help

Got something cool to share with AppGini users? Feel free to post it here!
Post Reply
rpierce
Veteran Member
Posts: 266
Joined: 2018-11-26 13:55
Location: Washington State

PHP Help

Post by rpierce » 2024-03-31 04:14

Hi Fellow AppGini Users,
I have a question that is more of a PHP technical question rather than an AppGini specific one. However, the data I'm working with is from my AppGini application and is a simple (seemingly) effort to improve the output of a PHP table.

I'm simply trying to add row numbers to the table produced from data in one of the tables. I thought I had it figured out. When using Xampp it works great. But when I run the same php code on the real server the numbering skips the first record. I have included the php code and a screen shot illustrating the first record without numbering. This forum has always helped me solve problems and I am hoping someone has a suggestion or two.

The people who will be viewing this file have no access to my AppGini application so I can't really use that interface to illustrate this data.

This seems so simple but I don't know where else to look for help.

Thank you as always!
RAY
orientation.JPG
orientation.JPG (48.96 KiB) Viewed 780 times

Code: Select all

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">

    <title>Orientation</title>   

	<!-- CSS only bootstrap

	<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-0evHe/X+R7YkIZDRvuzKMRqM+OrBnVFBL6DOitfPri4tjfHxaWutUpFmBp4vmVor" crossorigin="anonymous">-->
<style>

h1 { font-size:1.5em; text-align: center}
td	{padding: 5px 15px 0px 10px;
	font-size: 1.25em;}
th {background-color: LightCyan; font-size: 1em; padding: 5px 15px 5px 10px; text-align: center;}
p {font-size: .75em; text-align: center}

</style>
</head>

<body  align="center">

    <h1>Orientation Completions</h1>
    <p>1 Year Look Back</p>

    <table  align="center" border="1px solid black"; style="border-collapse: collapse">
           <tr>
                <th>#</th>
                <th>First Name</th>
                <!--<th>Last Name</th>-->
                <th>Completion Date</th>
            </tr>
        </thead>
        <tbody>		

            <?php

            $servername = "localhost";
            $username = "USER";
            $password = 'PASSWORD';
            $database = "DATABASE";

            //create connection
            $connection = new mysqli($servername, $username, $password, $database);
			
            //check connection
            if ($connection->connect_error) {
                die("Connection Failed: " . $connection->connect_error);
            }
// Set counter at 0
			$i = 0;
            // read all rows from database table
            $sql = "SELECT * FROM completions WHERE timecompleted >= 1704110077";
            $result = $connection->query($sql);

            //read data of each row
            WHILE($row = $result->fetch_assoc()){ 
                echo "<tr>
                <td>"  . $i++ . "</td>
                <td>"  . $row["firstname"] . "</td>
                <td>"  . $row["Completion_Date"] . "</td>
            </tr>";       
            }
            ?>
        </tbody>
    </table><br>
</body>
</html>


User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1869
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: PHP Help

Post by jsetzer » 2024-03-31 11:37

Code: Select all

$i = 1;
Or

Code: Select all

<td>"  . (++$i) . "</td>
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.14 Revision 1665 + all AppGini Helper tools

rpierce
Veteran Member
Posts: 266
Joined: 2018-11-26 13:55
Location: Washington State

Re: PHP Help

Post by rpierce » 2024-03-31 14:31

Jan,

Thank you so much!! I kind of knew you'd be helping me... again. :)

Post Reply