I'm having issues registering and then updating a value for specific items
in an array. I've read through the manual and MARC but I can't seem to find
the right answer. Here's what I'm trying to do...
Basic Backgroung: This is a "view cart" page. Depending on products that
they have selected I pull information from a MySQL database to give details
about their product. To do so I have set up a loop (duh) and on each pass
of the loop I add information to the session array. Here's the code...it
will make more sense...
First...I clean the arrays so that I don't have conflicting data...this is
done first thing on the page after session_start();
session_start();
session_register('subtotal');
session_unregister('kitem');
session_unregister('kquan');
session_unregister('kscale');
session_unregister('kdetail');
session_unregister('kdriver');
session_unregister('ksponsor');
session_unregister('kcompany');
session_unregister('kprice');
Then comes the loop which adds data to the now empty arrays...
for ($index = 0; $index < $indexLimit; $index++)
//connect and query MySQL database
include ("connect.php");
$result = mysql_query("SELECT * FROM ar
LEFT JOIN company on ar.company_id=company.company_id
LEFT JOIN scale on ar.scale_id=scale.scale_id
WHERE ar.item_number = '".$i[$index]."'\n");
//sort through results
if ($myrow = mysql_fetch_array($result))
{
do
{
if ($quan != 0 && $quan != "" && $quan != "0")
{
//the following vars will be used on the order form as hidden
fields.
$kitem[$index] = $myrow[item_number];
$kquan[$index] = $quan;
$kscale[$index] = $myrow[size];
$kdetail[$index] = $myrow[details];
$kdriver[$index] = $myrow[driver_name];
$ksponsor[$index] = $myrow[sponsor];
$kcompany[$index] = $myrow[value];
$kprice [$index] = $myrow[price];
}
}
while($myrow = mysql_fetch_array($result));
}
And then finally I reset my session variables (arrays) like this...
session_register('kitem');
session_register('kquan');
session_register('kscale');
session_register('kdetail');
session_register('kdriver');
session_register('ksponsor');
session_register('kcompany');
session_register('kprice');
I get mixed and varied results...usually the items show up twice or don't
show up at all. Please help if you can see anything that is being done
wrong. Thanks...
-Jordan
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php