Page 1 of 1

PHP Help

Posted: 2024-03-31 04:14
by rpierce
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!
orientation.JPG (48.96 KiB) Viewed 285 times

Code: Select all

<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="">


	<!-- CSS only bootstrap

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

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}


<body  align="center">

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

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


            $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>

Re: PHP Help

Posted: 2024-03-31 11:37
by jsetzer

Code: Select all

$i = 1;

Code: Select all

<td>"  . (++$i) . "</td>

Re: PHP Help

Posted: 2024-03-31 14:31
by rpierce

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