leatherback;10986286 wrote:You really need to read the posts here. I gave you an example code for this, but you keep moving things around & removing brackets. If a code gives you an error message, it is not a matter of just removing things untill it works..
Anyway, here it is:
$NoOfEntries=false;
$SQL = "SELECT * FROM Entry WHERE UserID = '$userID' AND (EntrySelect=4 AND (EntryBalanceSheet=1) OR (EntryBalanceSheet=2))";
$result = mysql_query($SQL) or die(mysql_error());
$num_rows = mysql_num_rows($result);
if ($num_rows > 0 )
{
$NoOfEntries=true;
while($row = mysql_fetch_array($resultspointer))
{
$rows[] = $row;
}
}
// then producing output somewhere else
if ($NoOfEntries === true)
{
// initiate table
echo "<tbody>";
foreach($rows as $row)
{
$sheetinfo = $row['entryBalanceSheet'] =="1" ? "Intangible" : "Tangible";
echo"
<tr>
<td>".$row['entryID']."</td>
<td>".$row['entryDate']."</td> <!-- Add imputs from database -->
<td>".row['entryName']."</td>
<td>".$sheetinfo."</td>
</tr>";
} // end foreach loop
echo "</tbody>";
} // end: Results found
else
{
echo "No entries";
}
Hi, I found it easier putting the entrys into variables because I hit a couple of bumps in the road doing it the way you suggested and I couldnt figure them out.
The first problem was, getting the total figure for $row[EntryValue].
The only way I could get this to work was by putting it into variables like so
if (EntrySelect==4 && EntryBalanceSheet==1);
{
$Intangible= $Intangible + $EntryValue;
}
Ontop of this I had to Make some of the fugure show in negative, like so
if ($EntryRW==1)
{
$EntryValue = "-". $EntryValue;
}
Thats all regarding the totals. The next hurdle I hit was the view/edit buttons,
previously I had
<?php printf('<a href="FixedAssetAddRate.php?id=%d&action=Add"><img title="Add Depreciation Rate" src="css/button/plus.png"/></a>', $row['EntryID']);?>
Which worked great, it goes to the correct url and carries over the $entryID to the next page, allowing me to use the $get method to display the information for the given ID. doing it in the echo statement which you showed yesterday, it wasnt carrying over the Entry ID to the next page.
Anyway, I'm entirely open to suggestions, If you think its easier writing it up without the variables, then that would be great. Or if you think it would be easier just keeping the variables and creating a different sort of loop.
Anyway, please help, I'm in a rutt,
Regards
Michael