Re-Order Values in PHP Data loops.
Posted: Mon Apr 02, 2012 10:11 am
I need some good PHP programming help with my little problem I am having. I have a MySQL table that has 5 columns plus a ID column and thousands and thousands of rows of data.
Please look at the image I have attached

I have created a PHP loop that pulls the information from the table database but I need the columns to go in order, I can not change the order of the MySQL database.
Is there away to do this so every row comes out in order and the all have a string attached to each value....
Please look at the image I have attached

I have created a PHP loop that pulls the information from the table database but I need the columns to go in order, I can not change the order of the MySQL database.
Code: Select all
<?
$SQLv = "SELECT * FROM tblvalues;";
if ($objDb->query($SQLv) == true)
{
$iCount = $objDb->getCount( );
for ($i = 0; $i < $iCount; $i ++)
{
$Id = $objDb->getField($i, "Id");
$c1 = $objDb->getField($i, "c1");
$c2 = $objDb->getField($i, "c2");
$c3 = $objDb->getField($i, "c3");
$c4 = $objDb->getField($i, "c4");
$c5 = $objDb->getField($i, "c5");
//I need the code to go here (look at the table image ID row 1) and below is the example
// $value1 = "2"; $c2
// $value2 = "4"; $c5
// $value3 = "20"; $c4
// $value4 = "22"; $c3
// $value5 = "23"; $c1
?>
<?= $value1; ?>
<?= $value2; ?>
<?= $value3; ?>
<?= $value4; ?>
<?= $value5; ?>
<? } } ?>