Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

help Needed

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

help Needed

Postby nbrown » Mon Jul 07, 2003 6:58 am

I am trying to display these results from a search like three images ontop and three images below... what am I doing wrong

--------------------

<?
$CVSFile=file("lineup.csv");

reset ($_POST['num']);
$i=0;
while (list ($key, $val) = each ($_POST['num'])) {
$i++;
$array6[$i]=$val;
}

if (count($array6) >= 6)
{
$numer=6;
} else {
$numer=count($array6)+1;
}

for ($i=1; $i < $numer ; $i++)
{
$test=$array6[$i];

$data=explode("," , $CVSFile[$test]);
$data['0']=trim($data['0']); // Last name
$data['1']=trim($data['1']); // First name
$data['2']=trim($data['2']); // Middle name
$data['3']=trim($data['3']); // Booking Number
$data['4']=trim($data['4']); // Jacket number
$data['5']=trim($data['5']); // Age
$data['6']=trim($data['6']); // DOB
$data['7']=trim($data['7']); // Sex
$data['8']=trim($data['8']); // Race
$data['9']=trim($data['9']); //Height
$data['10']=trim($data['10']); //Weight
$data['11']=trim($data['11']); //Hair
$data['12']=trim($data['12']); //Eyes
$data['13']=trim($data['13']); //Beard
$data['14']=trim($data['14']); //Mustache
$data['15']=trim($data['15']); //Cmplexion

echo "<table width=100% border=0 cellspacing=0 cellpadding=0> ";
echo "<tr><td><img src=\"http://livecast.tzo.com/img/".$data['3']."f.jpg\" border=1 width=175 height=150><br><font size=2 face=arial color=000000># $data[3]</td>";
echo "</tr>";
echo "</table>";
}

?>
nbrown
New php-forum User
New php-forum User
 
Posts: 4
Joined: Wed Jul 02, 2003 5:44 pm
Location: Clinton TN

Postby liquedus » Mon Jul 07, 2003 8:57 am

your beginning tag should start with <?php and not just <?

:P

i hope
liquedus
php-forum Active User
php-forum Active User
 
Posts: 266
Joined: Tue Apr 08, 2003 5:18 am
Location: Ottawa, Canada

Postby bezmond » Mon Jul 07, 2003 9:40 am

<? will usually work anyway.

Andrew
User avatar
bezmond
Moderator
Moderator
 
Posts: 312
Joined: Sat Apr 05, 2003 4:33 am
Location: Mansfield, UK

<? works

Postby nbrown » Mon Jul 07, 2003 9:42 am

that is not the problem... :)

I need to display the results "six images" ina layout like three images on top and three images below..
nbrown
New php-forum User
New php-forum User
 
Posts: 4
Joined: Wed Jul 02, 2003 5:44 pm
Location: Clinton TN

Postby Redcircle » Mon Jul 07, 2003 10:02 am

So you need it to display two rows of three. What is it displaying right now?
User avatar
Redcircle
Moderator
Moderator
 
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA

single Verticle ROW

Postby nbrown » Mon Jul 07, 2003 10:04 am

It show found data in a single verticle row..
nbrown
New php-forum User
New php-forum User
 
Posts: 4
Joined: Wed Jul 02, 2003 5:44 pm
Location: Clinton TN

Postby Redcircle » Mon Jul 07, 2003 10:59 am

sorry.. trying to understand your code. What does $_POST['num'] do? Is that an array? Please post the form you are using to do the post.
Code: Select all
if(is_array($_POST['num']))
{
  $array6 = array();
  foreach($_POST['num'] as $key=>$value)
  {
  $array6[]=$value;
  }
}
//that is a much simpler way to write the same code


Your keys should be zero based.

$test = $array[$i]; not sure what you are doing here.

$data=explode("," , $CVSFile[$test]);
instead try
$data=explode("," , $CVSFile[($i-1)]);
User avatar
Redcircle
Moderator
Moderator
 
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA

Postby Oleg Butuzov » Mon Jul 07, 2003 10:06 pm

Nathan i will send you files today...
=)))

dont worry =)
Oleg Butuzov
Last Samuray
Last Samuray
 
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Postby Oleg Butuzov » Mon Jul 07, 2003 10:55 pm

Nathan,

three first row
three second row

custumaize under your leyout

Code: Select all
<?
$CVSFile=file("lineup.csv");

reset ($_POST['num']);
$i=0;
while (list ($key, $val) = each ($_POST['num'])) {
   $i++;
$array6[$i]=$val;   
}

if (count($array6) >= 7)
   {
   $numer=7;
} else {
   $numer=count($array6)+1;
}

$id=0;

echo "<table border=0>";
for ($i=0; $i < 2; $i++){
echo "<tr>";
for ($num=1; $num < 4 ; $num++)
{
   $id++;
   $test=$array6[$id];
   
$data=explode("," , $CVSFile[$test]);
   $data['0']=trim($data['0']);   // Last name
   $data['1']=trim($data['1']);   // First name
   $data['2']=trim($data['2']);   // Middle name
   $data['3']=trim($data['3']);
   $data['4']=trim($data['4']);
   $data['5']=trim($data['5']);   // Age
   $data['6']=trim($data['6']);   // DOB
   $data['7']=trim($data['7']);   // Sex
   $data['8']=trim($data['8']);   // Race
   $data['9']=trim($data['9']);   //Height
   $data['10']=trim($data['10']); //Weight
   $data['11']=trim($data['11']); //Hair
   $data['12']=trim($data['12']); //Eyes
   $data['13']=trim($data['13']); //Beard
   $data['14']=trim($data['14']); //Mustache
   $data['15']=trim($data['15']); //Cmplexion
   
echo "<td><table border=0 cellspacing=0 cellpadding=0> ";
echo "<tr><td rowspan=5><center><img src=\"http://livecast.tzo.com/img/".$data['3']."f.jpg\" width=175 height=150></center></td>";
echo "<td>Date of birth $data[6]</td>";
echo "</tr>";
echo "<tr><td>Hair color ";

if ($data['11'] == "BLD") {echo "Bald"; }
elseif ($data['11'] == "BLK") {
   echo "Black";
   }
elseif ($data['11'] == "BLO") {
   echo "Blond";
   }
elseif ($data['11'] == "GRY") {
   echo "Gray";
   }
elseif ($data['11'] == "RED") {
   echo "Red";
   }
elseif ($data['11'] == "BRO") {
   echo "Brown";
   }
else    {
   echo "UnKnown";
   }

echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Eyes color ";

if ($data['12'] == "BLU") {echo "Blue"; }
elseif ($data['12'] == "HZL") {
   echo "Hazel";
   }
elseif ($data['12'] == "GRN") {
   echo "Green";
   }
elseif ($data['12'] == "GRY") {
   echo "Gray";
   }
elseif ($data['12'] == "BRO") {
   echo "Brown";
   }
else    {
   echo "UnKnown";
   }


   
echo "</td></tr>";
echo "<tr>";
echo "<td>Height $data[9]<br> Weight $data[10]</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Race ";
if ($data['8'] == "A") {echo "Asian"; }
elseif ($data['8'] == "B") {
   echo "Black";
   }
elseif ($data['8'] == "H") {
   echo "Hispanic";
   }
elseif ($data['8'] == "W") {
   echo "White";
   }
else    {
   echo "UnKnown";
   }


echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td><center>$data[0] $data[1] $data[2]</center></td>";
echo "<td></td>";
echo "</tr>";
echo "</table></td>";   
}
echo "</tr>";
}
echo "</table>";
?>
Oleg Butuzov
Last Samuray
Last Samuray
 
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am


Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.