Jump to content

babaz

Members
  • Posts

    11
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

babaz's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. thanks....dat helped! also tried for ($x=0;$x<$size;$x++) { if(isset($unique[$x])) { echo $unique[$x]; echo "<br>"; } } and worked fine....
  2. as an exaple try running this code and see wot happens: <?php $dirty = array('danish','mukesh','braden1','shadab','bev','braden1','kirsten','john'); $clean = array_unique($dirty); for($i=0; $i<count($clean); $i++) { echo $clean[$i] . "<br />"; } ?>
  3. thats not the problem, ive tried that. with that line of code it prints out, 1,2, and then the error notice. it does not print out 3.
  4. ok so i have an array which has duplicate values in it. i used array_unique() to remove duplicate values. the array had values 1,2,2,3. after the following code: $unique = array_unique($suggest); $size = count($unique); for ($x=0;$x<=$size;$x++) { echo $unique[$x]; echo "<br>"; } it prints out 1,2 and then gives an error, "Notice: Undefined offset: 2 in E:\wamp\www\Copy of pro2\Classes.php on line 1074" and then finally 3. any ideas how i can solve this. im assuming that array_unique() assigns the index 0,1,3 of the duplicate value array to unique array at the same indexs 0,1,3. since the index 2 of duplicate array is a duplicate value it is ommited but the unique array does not have an array at index 2.
  5. i wanted to choose 5 random numbers from 0-20. each number represents an index in an array. is there a way to pick out 5 random items from the array. say if random number generator piked a number 22, the last item in the array is at index 20, it wud then have to go to index 0. thanks!
  6. i have created an object in one page. it has a submit button which upon clicking opens a new page. is it possible to access that created object and its data members in that second page? here is the code for creating the object in the first page. $viewcart = new Cart(); $viewcart->GetProductCart($user);
  7. thanks mate for correcting my silly mistakes...... cheers! it works fine now!
  8. but it does not cause any errors when it is used in AllProducts function.
  9. hello, im trying to read the database and store values into an array list. when i run the script it says undefined variable prodcode, name, price in the function prod details. any help pliz. appreciate the help. thnaks! require("dbfunctions.inc.php"); $count; class Product { // The following are the attributes of the Product class, that is, var $prodcode = array(); var $name = array(); var $price = array(); /* CONSTRUCTOR Every class has at least one constructor method. We create an instance of a class using the class's constructor */ function AllProducts() { $qry = "Select ProdCode, Name, Price, Image from products"; //execute query $products = execute_query($qry); if (!$products) {die('query failed.'); } $i = 0; global $count; $count= mysql_num_rows($products); while ($line = mysql_fetch_array($products, MYSQL_ASSOC)) { $prodcode =array ($line['ProdCode']); //$name[$i] = $line['Name']; //$desc[$i] = $line['Desc']; //$price[$i] = $line['Price']; //$category[$i] = $line['Category']; $i++; } } // Method to print the Shopping Cart details to the screen function ProdDetails() { global $count; echo $count; echo $count; for ($i = 0; $i <= $count; $i++) { //echo "<tr><td>"; echo "<br>Product Code: <a href=DisplayProduct.php?prodcode=" . $prodcode[$i]. ">" .$prodcode[$i]. "</a>"."<br>"; echo "Product Name: ".$name[$i]." <br>". "Price: FJD$ " .$price[$i]."<br>"; } } // Method to print the Shopping Cart details to the screen function getProdCode() { echo "Product Code: " . $this->prodcode . "<br>"; } } // END OF CLASS
  10. hi, am new to this site. im working on a school project which requires us to build an online shopping site. have everything under control except for one thing. when a customer views an item, the site should suggest other items that other customers purchased with the item the curent customer is viewing. any suggestions as to how i should implement this? i will be using php and sql. thanks....
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.