HIhi all,
right... ive come across a bit of a wee problem which i can't quite get my head round.
I'm writing a CMS for my clothing company. Im working on the accounting pages. I have written a page which displays all income, and also a page which displays all expence. Expences has its own table, and so does income. But they are completely different, and only have a couple of common values.
I want to write a function which will output both income and expenses in a list all in the correct order ( by date ).
Just want to know if theres a nice little SQL method for merging two tables or something...
heres my expenses function just so you have an idea of what im doing.
function getExpenceList() {
$db = mysql_connect("localhost", "sosick_website", "website") or die("Error connecting to database");
mysql_select_db("sosick_website",$db) or die(mysql_error());
$result = mysql_query("SELECT * FROM tbl_expences ORDER BY `expence_id` DESC",$db);
if ($myrow = mysql_fetch_array($result)) {
$bg = "lightbg";
do {
$expence_date = $myrow["expence_date"];
$date = date("d/m/Y", strtotime($expence_date));
$payto = strtoupper($myrow["expence_to"]);
$items = $myrow["expence_items"];
$cost = number_format($myrow["expence_cost"],2);
$income_list .= "
<tr class='$bg'>
<td>$date</td>
<td>$payto</td>
<td>$items</td>
<td id='balancetext'>£$cost GBP</td>
</tr>
";
if ( $bg == "lightbg" ) {
$bg = "darkbg";
} else {
$bg = "lightbg";
}
} while ($myrow = mysql_fetch_array($result));
}
return $income_list;
}
thanks
sam