[PHP-DB] grid unsetting vars

2004-09-09 Thread Sancerni Veronica
We'll I've got a query based on mysql_fetch_object to show the results of the previous 
search and print them out in tables. Then I got the the $grid idea for printing an 
array in a horizontally columned table from the book php cookbook from o'reilly (quite 
useful) then I print it all insed the grid, but when it is supposed to send the 
selected objects with a checkbox to the next page. It doesn't while everything works 
just fine without the grid. #sigh# I've tried to see what's the grid doing to my 
checkboxes that i the end they don't send anything at all bu i cant see what. Does 
anyone?
...
while ($inb = mysql_fetch_object($resultInfs))
{
//trying to put it right --- values ---
if (!empty($inb->pix)) 
   $ipix="";
   } else {
 $ipix="";
 }
  if (!empty($inb->infType)) {
   $ity="$inb->infType,";
  }
  if (!empty($inb->infName)) {
   $inm="$inb->infName";
  }
  if (!empty($inb->infRef)) {
   $irf="$inb->infRef";
  }
  if (!empty($inb->infMeas)) {
   $ims="$inb->infMeas";
  }
  if (!empty($inb->infSerial)) {
   $isr="SERIAL N°: $inb->infSerial";
  }
  if (!empty($inb->infDescription)) {
   $ids="DETAILS: $inb->infDescription,";
  }
  if (!empty($inb->infArtw)) {
   $irt="$inb->infArtw,";
  }
  if (!empty($inb->infCover)) {
   $irc="$inb->infCover,";
  }
  // T.T $value deosn't go as $_POST for orderdata.php!!!
  $value = $inb->infID;
//for function, hope as objects
$infs[ ] = $ipix.' '.$ity.' '.$inm.' '.$irf.' '.$ims.' '.$isr.' '.$ids.' '.$irt.' 
'.$irc.' '.$value;
}
///changes to function from phpckbk
function grid_horizontal($array, $size) {
// compute  width %ages
$table_width = 100;
$width = intval($table_width / $size);
 $grid = "$tr";
 // define how our  and  tags appear
// sprintf() requires us to use %% to get literal %
$tr = '';
$td = "%sAdd to Cart!";
// open table
// loop through entries and display in rows of size $sized
// $i keeps track of when we need a new table tow
$i = 0;
foreach ($array as $e) {
$grid .= sprintf($td, $e);
$i++;
// end of a row
// close it up and open a new one
if (!($i % $size)) {
$grid .= "$tr";
}
}
// pad out remaining cells with blanks
while ($i % $size) {
$grid .= sprintf($td, ' ');
$i++;
}
// add , if necessary
$end_tr_len = strlen($tr) * -1;
if (substr($grid, $end_tr_len) != $tr) {
$grid .= '';
} else {
$grid = substr($grid, 0, $end_tr_len);
}
// close table
$grid .= '';
return $grid;
}
//final results printing
$grid = grid_horizontal($infs, 3);
print $grid;
 
If the grid can not work with a sending to another php (that is with my checkboxes, 
how could i print them ordered then?


-
Créez gratuitement votre Yahoo! Mail avec 100 Mo de stockage !
Créez votre Yahoo! Mail

Le nouveau Yahoo! Messenger est arrivé ! Découvrez toutes les nouveautés pour 
dialoguer instantanément avec vos amis.Téléchargez GRATUITEMENT ici !

[PHP-DB] error on count()

2004-09-07 Thread Sancerni Veronica
hello, this is problably newbie question, but I can not understand why my count() 
function doesn't work. I need to count how many items has a determinated customer 
ordered ever.
 
1. I tired to get the array like this:
 $una = $check["uname"];
function orderquantity ($una) {
  $pss = mysql_query("SELECT OID FROM orders WHERE una = '".trim($una)."'") or die 
(mysql_error("Query error on Order search"));
  while($pisao=mysql_fetch_array($pss)) {
  return count($pisao);
  }
}
$okuan = orderquantity();
 
2. and like this:
 $una = $check["uname"];
function orderquantity ($una) {
  $pss = mysql_query("SELECT OID FROM orders WHERE una = '".trim($una)."'") or die 
(mysql_error("Query error on Order search"));
   return count($pss);
}
okuan = orderquantity();
 
None of them gave me a valid value, is it because the OID is an int value?


-
Créez gratuitement votre Yahoo! Mail avec 100 Mo de stockage !
Créez votre Yahoo! Mail

Le nouveau Yahoo! Messenger est arrivé ! Découvrez toutes les nouveautés pour 
dialoguer instantanément avec vos amis.Téléchargez GRATUITEMENT ici !

[PHP-DB] split query per $_POST???

2004-08-26 Thread Sancerni Veronica
Could anyone, please, help me with this one. If I add the insert inside the loop it 
inserts as many orders in the order table as products have been chosen. There is 
really no way to split this?  

I have a problem with a script that gets the ID's of the selected products from the 
previous script and shows them with mysql_fetch_object. Now I'd like to insert them in 
the db, but when I pass every value to $vars and insert them it inserts only one of 
the selected products. I tried a change with mysql_fetch_array, with split and 
implode, ...useless. How can I get the products to be apart without breaking the 
values, ie, put name of all the selected products in name field in the db, put serial 
number of the selected products in serial field in the db, etc?:
...
while($isc = mysql_fetch_object($antw)){
if (!empty($isc->pic)) {
echo ("");
}
if (!empty($isc->Meas)) {
echo ("$isc->infMeas");
}
if (!empty($isc->Name)) {
echo ("$isc->Name, ");
}
if (!empty($isc->Ref)) {
echo ("$isc->Ref,");
}
$ipic = $isc->pic;
$iMeas = $isc->Meas;
$iName = $isc->Name;
$iRef = $isc->Ref;
}
...
$dem = "INSERT INTO orders VALUES('$ipic','$iMeas','$iName','$iRef');
...

By the way how can I get them apart in the previous page by rows of 3 products each in 
the table?:
...
echo ("");
if (!empty($inb->pic)) {
echo ("");
} else {
echo ("");
}
if (!empty($inb->Type)) {
echo ("$inb->Type,");
}
if (!empty($inb->Name)) {
echo ("$inb->Name");
}
if (!empty($inb->Ref)) {
echo ("$inb->Ref");
}
if (!empty($inb->Meas)) {
echo ("$inb->Meas");
}
if (!empty($inb->Ref)) {
echo ("$inb->Ref");
}
if (!empty($inb->Serial)) {
echo ("SERIAL N°: $inb->Serial");
}
if (!empty($inb->Description)) {
echo ("DETAILS: $inb->Description,");
}
if (!empty($inb->Artw)) {
echo ("$inb->Artw,");
}
if (!empty($inb->Cover)) {
echo ("$inb->Cover,");
}
echo ("");




-
Créez gratuitement votre Yahoo! Mail avec 100 Mo de stockage !
Créez votre Yahoo! Mail

Le nouveau Yahoo! Messenger est arrivé ! Découvrez toutes les nouveautés pour 
dialoguer instantanément avec vos amis.Téléchargez GRATUITEMENT ici !