Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Software Development
Programming
PHP echo rows in table
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Skythrust" data-source="post: 453109" data-attributes="member: 87030"><p>Over here the (new) code</p><p></p><p>[CODE=php]<meta name="viewport" content="width=device-width, initial-scale=1.0"></p><p></p><p><?php include '../Management/Configuration.php';</p><p> $stmt = SQLSRV_QUERY( $conn, $SQL_Query );</p><p> if( $stmt === false) {</p><p> die( print_r(</p><p> $System_Message, true) );</p><p> }</p><p> echo "<table> ";</p><p> while( $row = SQLSRV_FETCH_ARRAY( $stmt, SQLSRV_FETCH_ASSOC) ) {</p><p> echo "<td>";</p><p> $ImageFilter = ($row['Available'] == 0 || $row['Available'] == 31) ? '<div class="ImageON">' : '';</p><p> $useFilter = ($row['Available'] == 0 || $row['Available'] == 31) ? '<div class="tooltipON">' : '';</p><p> $useImage = $row['Data'] === NULL ? 'images/Avatar.png "height="50" width="50""' : /* 'data:image/jpeg;base64,'.base64_encode($row['Data']); */ ($row['Data']) ?></p><p></p><p> <div class="middle"><?php if ($row['Available'] == 1) { ?></p><p> <div class="textGreen"><?php echo $useFilter. '<img src="'.$useImage .'" height="50" width="50" alt="Avatar" '.$ImageFilter.''; } else if ($row['Available'] == 2) { ?></p><p> <div class="textDarkGreen"><?php echo $useFilter. '<img src="'.$useImage .'" height="50" width="50" alt="Avatar" '.$ImageFilter.''; } else if ($row['Available'] == 3) { ?></p><p> <div class="textBlue"><?php echo $useFilter. '<img src="'.$useImage .'" height="50" width="50" alt="Avatar" '.$ImageFilter.''; } else if ($row['Available'] == 4) { ?></p><p> <div class="textDarkBlue"><?php echo $useFilter. '<img src="'.$useImage .'" height="50" width="50" alt="Avatar" '.$ImageFilter.''; } else if ($row['Available'] == 5) { ?></p><p> <div class="textLightBlue"><?php echo $useFilter. '<img src="'.$useImage .'" height="50" width="50" alt="Avatar" '.$ImageFilter.''; } else if ($row['Available'] == 6) { ?></p><p> <div class="textPurple"><?php echo $useFilter. '<img src="'.$useImage .'" height="50" width="50" alt="Avatar" '.$ImageFilter.''; } else if ($row['Available'] == 7) { ?></p><p> <div class="textOrange"><?php echo $useFilter. '<img src="'.$useImage .'" height="50" width="50" alt="Avatar" '.$ImageFilter.''; } else if ($row['Available'] == 8) { ?></p><p> <div class="textYellow"><?php echo $useFilter. '<img src="'.$useImage .'" height="50" width="50" alt="Avatar" '.$ImageFilter.''; } else if ($row['Available'] == 9) { ?></p><p> <div class="textDarkRed"><?php echo $useFilter. '<img src="'.$useImage .'" height="50" width="50" alt="Avatar" '.$ImageFilter.''; } else if ($row['Available'] == 10) { ?></p><p> <div class="textSilver"><?php echo $useFilter. '<img src="'.$useImage .'" height="50" width="50" alt="Avatar" '.$ImageFilter.''; } else if ($row['Available'] == 21) { ?> </p><p> <div class="textGreenBHV"><?php echo $useFilter. '<img src="'.$useImage .'" height="50" width="50" alt="Avatar" '.$ImageFilter.''; } else if ($row['Available'] == 22) { ?></p><p> <div class="textDarkGreenBHV"><?php echo $useFilter. '<img src="'.$useImage .'" height="50" width="50" alt="Avatar" '.$ImageFilter.''; } else if ($row['Available'] == 23) { ?></p><p> <div class="textBlueBHV"><?php echo $useFilter. '<img src="'.$useImage .'" height="50" width="50" alt="Avatar" '.$ImageFilter.''; } else if ($row['Available'] == 24) { ?></p><p> <div class="textDarkBlueBHV"><?php echo $useFilter. '<img src="'.$useImage .'" height="50" width="50" alt="Avatar" '.$ImageFilter.''; } else if ($row['Available'] == 25) { ?></p><p> <div class="textLightBlueBHV"><?php echo $useFilter. '<img src="'.$useImage .'" height="50" width="50" alt="Avatar" '.$ImageFilter.''; } else if ($row['Available'] == 26) { ?></p><p> <div class="textPurpleBHV"><?php echo $useFilter. '<img src="'.$useImage .'" height="50" width="50" alt="Avatar" '.$ImageFilter.''; } else if ($row['Available'] == 27) { ?></p><p> <div class="textOrangeBHV"><?php echo $useFilter. '<img src="'.$useImage .'" height="50" width="50" alt="Avatar" '.$ImageFilter.''; } else if ($row['Available'] == 28) { ?></p><p> <div class="textYellowBHV"><?php echo $useFilter. '<img src="'.$useImage .'" height="50" width="50" alt="Avatar" '.$ImageFilter.''; } else if ($row['Available'] == 29) { ?></p><p> <div class="textDarkRedBHV"><?php echo $useFilter. '<img src="'.$useImage .'" height="50" width="50" alt="Avatar" '.$ImageFilter.''; } else if ($row['Available'] == 30) { ?></p><p> <div class="textSilverBHV"><?php echo $useFilter. '<img src="'.$useImage .'" height="50" width="50" alt="Avatar" '.$ImageFilter.''; } else if ($row['Available'] == 31) { ?></p><p> <div class="textBHVOUT"><?php echo $useFilter. '<img src="'.$useImage .'" height="50" width="50" alt="Avatar" '.$ImageFilter.''; } else { ?></p><p> <div class="textout"> <?php echo $useFilter. '<img src="'.$useImage .'" height="50" width="50" alt="Avatar" '.$ImageFilter.''; } ?></p><p> </p><p> <b><div id="NameString"><?php echo $row["Firstname"]. ' '; ?></b></div></p><p> <br><div id="TitleString"><?php echo $row["Middlename"]. ' ' .$row["Lastname"]; ?></div></p><p> </div></p><p> </div></p><p> </div></p><p> </p><p> <?php echo "</td>";</p><p>/* OLD CODE</p><p> if ($i>6){</p><p> $i=0;</p><p> echo '</tr>';</p><p> }; </p><p> $i++; </p><p>*/</p><p></p><p>// the number of results.</p><p>$noof = 19;</p><p></p><p>// the number of results in a row.</p><p>$ross = 6;</p><p></p><p>$i = 0;</p><p>for ($ii = 0; $ii < $noof; $ii++) {</p><p> $i++;</p><p> echo "{RESULT}";</p><p> if ($i % $ross == 0) {</p><p> echo "<br />";</p><p> }</p><p>} </p><p> }</p><p> echo "</table>";</p><p></p><p> sqlsrv_free_stmt( $stmt);</p><p>?>[/CODE]</p></blockquote><p></p>
[QUOTE="Skythrust, post: 453109, member: 87030"] Over here the (new) code [CODE=php]<meta name="viewport" content="width=device-width, initial-scale=1.0"> <?php include '../Management/Configuration.php'; $stmt = SQLSRV_QUERY( $conn, $SQL_Query ); if( $stmt === false) { die( print_r( $System_Message, true) ); } echo "<table> "; while( $row = SQLSRV_FETCH_ARRAY( $stmt, SQLSRV_FETCH_ASSOC) ) { echo "<td>"; $ImageFilter = ($row['Available'] == 0 || $row['Available'] == 31) ? '<div class="ImageON">' : ''; $useFilter = ($row['Available'] == 0 || $row['Available'] == 31) ? '<div class="tooltipON">' : ''; $useImage = $row['Data'] === NULL ? 'images/Avatar.png "height="50" width="50""' : /* 'data:image/jpeg;base64,'.base64_encode($row['Data']); */ ($row['Data']) ?> <div class="middle"><?php if ($row['Available'] == 1) { ?> <div class="textGreen"><?php echo $useFilter. '<img src="'.$useImage .'" height="50" width="50" alt="Avatar" '.$ImageFilter.''; } else if ($row['Available'] == 2) { ?> <div class="textDarkGreen"><?php echo $useFilter. '<img src="'.$useImage .'" height="50" width="50" alt="Avatar" '.$ImageFilter.''; } else if ($row['Available'] == 3) { ?> <div class="textBlue"><?php echo $useFilter. '<img src="'.$useImage .'" height="50" width="50" alt="Avatar" '.$ImageFilter.''; } else if ($row['Available'] == 4) { ?> <div class="textDarkBlue"><?php echo $useFilter. '<img src="'.$useImage .'" height="50" width="50" alt="Avatar" '.$ImageFilter.''; } else if ($row['Available'] == 5) { ?> <div class="textLightBlue"><?php echo $useFilter. '<img src="'.$useImage .'" height="50" width="50" alt="Avatar" '.$ImageFilter.''; } else if ($row['Available'] == 6) { ?> <div class="textPurple"><?php echo $useFilter. '<img src="'.$useImage .'" height="50" width="50" alt="Avatar" '.$ImageFilter.''; } else if ($row['Available'] == 7) { ?> <div class="textOrange"><?php echo $useFilter. '<img src="'.$useImage .'" height="50" width="50" alt="Avatar" '.$ImageFilter.''; } else if ($row['Available'] == 8) { ?> <div class="textYellow"><?php echo $useFilter. '<img src="'.$useImage .'" height="50" width="50" alt="Avatar" '.$ImageFilter.''; } else if ($row['Available'] == 9) { ?> <div class="textDarkRed"><?php echo $useFilter. '<img src="'.$useImage .'" height="50" width="50" alt="Avatar" '.$ImageFilter.''; } else if ($row['Available'] == 10) { ?> <div class="textSilver"><?php echo $useFilter. '<img src="'.$useImage .'" height="50" width="50" alt="Avatar" '.$ImageFilter.''; } else if ($row['Available'] == 21) { ?> <div class="textGreenBHV"><?php echo $useFilter. '<img src="'.$useImage .'" height="50" width="50" alt="Avatar" '.$ImageFilter.''; } else if ($row['Available'] == 22) { ?> <div class="textDarkGreenBHV"><?php echo $useFilter. '<img src="'.$useImage .'" height="50" width="50" alt="Avatar" '.$ImageFilter.''; } else if ($row['Available'] == 23) { ?> <div class="textBlueBHV"><?php echo $useFilter. '<img src="'.$useImage .'" height="50" width="50" alt="Avatar" '.$ImageFilter.''; } else if ($row['Available'] == 24) { ?> <div class="textDarkBlueBHV"><?php echo $useFilter. '<img src="'.$useImage .'" height="50" width="50" alt="Avatar" '.$ImageFilter.''; } else if ($row['Available'] == 25) { ?> <div class="textLightBlueBHV"><?php echo $useFilter. '<img src="'.$useImage .'" height="50" width="50" alt="Avatar" '.$ImageFilter.''; } else if ($row['Available'] == 26) { ?> <div class="textPurpleBHV"><?php echo $useFilter. '<img src="'.$useImage .'" height="50" width="50" alt="Avatar" '.$ImageFilter.''; } else if ($row['Available'] == 27) { ?> <div class="textOrangeBHV"><?php echo $useFilter. '<img src="'.$useImage .'" height="50" width="50" alt="Avatar" '.$ImageFilter.''; } else if ($row['Available'] == 28) { ?> <div class="textYellowBHV"><?php echo $useFilter. '<img src="'.$useImage .'" height="50" width="50" alt="Avatar" '.$ImageFilter.''; } else if ($row['Available'] == 29) { ?> <div class="textDarkRedBHV"><?php echo $useFilter. '<img src="'.$useImage .'" height="50" width="50" alt="Avatar" '.$ImageFilter.''; } else if ($row['Available'] == 30) { ?> <div class="textSilverBHV"><?php echo $useFilter. '<img src="'.$useImage .'" height="50" width="50" alt="Avatar" '.$ImageFilter.''; } else if ($row['Available'] == 31) { ?> <div class="textBHVOUT"><?php echo $useFilter. '<img src="'.$useImage .'" height="50" width="50" alt="Avatar" '.$ImageFilter.''; } else { ?> <div class="textout"> <?php echo $useFilter. '<img src="'.$useImage .'" height="50" width="50" alt="Avatar" '.$ImageFilter.''; } ?> <b><div id="NameString"><?php echo $row["Firstname"]. ' '; ?></b></div> <br><div id="TitleString"><?php echo $row["Middlename"]. ' ' .$row["Lastname"]; ?></div> </div> </div> </div> <?php echo "</td>"; /* OLD CODE if ($i>6){ $i=0; echo '</tr>'; }; $i++; */ // the number of results. $noof = 19; // the number of results in a row. $ross = 6; $i = 0; for ($ii = 0; $ii < $noof; $ii++) { $i++; echo "{RESULT}"; if ($i % $ross == 0) { echo "<br />"; } } } echo "</table>"; sqlsrv_free_stmt( $stmt); ?>[/CODE] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Software Development
Programming
PHP echo rows in table
Top