I have two databases - one is an Access 97 database that I can connect to with ODBC and the other is a MySQL database that I have created. I cannot modify the Access database but have full control over the MySQL database. I'm trying to introduce on-line order tracking by querying orders from the Access database and using an internal webpage to allow our staff to set a status and delivery date for each item in the order. In the Access database orders are uniquely identified by a TransactionNumber, BranchID and TillID. Here's the code so far:
<?php
# Now fetch the products for this transaction.
# odbc_num_rows() doesn't work with the MS Access driver when performing SELECT
# queries so this function is needed to obtain the correct number of rows
# that were returned from the $proddata query.
function num_rows($proddata) {
ob_start();
(int)$number=odbc_result_all($proddata);
ob_clean();
return $number;
}
# Now perform the products loop.
$num = num_rows($proddata);
$i = 0;
while ($i < $num) {
$row = odbc_fetch_row($proddata,$num);
$PLU = odbc_result($proddata,'PLU');
$Description = odbc_result($proddata,'Description');
$Retail = odbc_result($proddata,'Retail');
$tracksalesnumber = odbc_result($proddata,'SalesNumber');
$ordertrackid = $trackingid;
$DeliveryDate = mysql_result($detaildata,$num,'DeliveryDate');
$StatusText = mysql_result($detaildata,$num,'Status');
$DeliveryDate = mysql_result($detaildata,$num,'DeliveryDate');
$StatusText = mysql_result($detaildata,$num,'Status');
if($DeliveryDate == '') {
$Delivery = "<input type='text' name='delivery$num' size=10 value='dd/mm/yyyy' />";
} else {
$Delivery = "<input type='text' name='delivery$num' size='10' value='$DeliveryDate' />";
}
if($StatusText == '') {
$Status = "<select name='status".$num."'>
<option value='0'>Please select...</option>
<option value='1'>In progress</option>
<option value='2'>Awaiting stock</option>
<option value='3'>In stock</option>
<option value='4'>Delivery arranged</option>
<option value='5'>Delivered</option>
<option value='6'>Delayed</option>
</select>";
} else {
$trackid = mysql_result($trackdata,$num,'StatusInternal');
$Status = "<select name='status".$num."'>
<option value='$num' selected='selected'>$trackid</option>
<option value='1'>In progress</option>
<option value='2'>Awaiting stock</option>
<option value='3'>In stock</option>
<option value='4'>Delivery arranged</option>
<option value='5'>Delivered</option>
<option value='6'>Delayed</option>
</select>";
}
echo "<tr>
<td width='800' bgcolor='#000000' height='1' colspan='7'></td>
</tr>
<tr>
<td width='10' bgcolor='#ffffcc'></td>
<td width='60' align='center' bgcolor='#ffffff'><font face='arial' size='2'>$PLU</font></td>
<td width='300' align='center' bgcolor='#ffffff'><font face='arial' size='2'>$Description</font></td>
<td width='60' align='center' bgcolor='#ffffff'><font face='arial' size='2'>£".sprintf('%01.2f',$Retail)."</font></td>
<td width='90' align='center' bgcolor='#ffffff'>$Delivery</td>
<td width='270' align='center' bgcolor='#ffffff'>$Status</td>
<td width='10' bgcolor='#ffffcc'></td>
</tr>";
$i++;
}
?>
The problem is there will not be an entry in the ordertracking database if it is the first time the user has requested the details, so I get the following error from the products loop:
Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 5 in C:\Inetpub\wwwroot\ordertracking\data.php on line 226
Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 5 in C:\Inetpub\wwwroot\ordertracking\data.php on line 227
Warning: mysql_result() [function.mysql-result]: Unable to jump to row 1 on MySQL result index 5 in C:\Inetpub\wwwroot\ordertracking\data.php on line 229
Warning: mysql_result() [function.mysql-result]: Unable to jump to row 1 on MySQL result index 5 in C:\Inetpub\wwwroot\ordertracking\data.php on line 230
I could use 'error_reporting(0);' but I'm thinking there must be a better way around this?