i have an array that is in a while loop to parse the information in a database. Problem is, there is 4 arrays, one of them only displays the first character from the field. i wrote a test page using the same loop and it gets the whole string. the array in question is $time[$i]
here is the code i am using:
mysql_connect("localhost", "username", "xxxxxx");
mysql_select_db("database");
$query = "SELECT * FROM trouble";
$result = mysql_db_query("database", $query);
$numrows = mysql_numrows($result);
echo ("<center>");
while ( $i < $numrows) {
$time[$i] = mysql_result($result, $i, time);
$trouble[$i] = mysql_result($result, $i, trouble);
$tech[$i] = mysql_result($result, $i, tech);
$num[$i] = mysql_result($result, $i, num);
$i++;
}
krsort($num);
foreach($num as $var1 => $var2){
echo ("
<br>
<form method=\"POST\" action=\"add.php\">
<table width=\"400\" border=0 bgcolor=999999>
<tr>
<td>
$time[$var1]
</td>
<td align=right>
<b>$tech[$var1]</b>
</td>
<td align=right width=\"10%\">
<input type=\"submit\" name=\"add\" value=\"add\"></input>
</td>
</tr>
<tr><td colspan=3><hr></td></tr>
<tr>
<td colspan=3>
$trouble[$var1]
</td>
</tr>
</table>
<input type=\"hidden\" name=\"index\" value=\"$num[$var1]\"></input>
</form>
");
}
in the above code snippet $time[$var1] only displays the first character of the string (ie "T");
this code works though and displays all of the string(ie "Thursday January 30 2003 02:35 ":
<?php
mysql_connect("localhost", "username", "xxxxxx");
mysql_select_db("krisarnold");
$query = "SELECT * FROM trouble";
$result = mysql_db_query("krisarnold", $query);
$numrows = mysql_numrows($result);
echo ("<center>");
while ( $i < $numrows) {
$time[$i] = mysql_result($result, $i, time);
$trouble[$i] = mysql_result($result, $i, trouble);
$tech[$i] = mysql_result($result, $i, tech);
$num[$i] = mysql_result($result, $i, num);
$i++;
}
krsort($num);
foreach($num as $var1 => $var2){
echo "$time[$var1]<br>";
}
mysql_close();
?>
i cant distinguish at all what is making one work and the other not. hopin maybe someone here can lend a helping hand