Jump to content

carbonxps

Members
  • Posts

    23
  • Joined

  • Last visited

Everything posted by carbonxps

  1. Sorry I didn't realize it was joomla specific, it's a component I added onto joomla. Honestly thought it was PHP question.
  2. Hi there, I call a variable from a component to get a users location: JRequest::getInt('CS_SESSION_LOCATIONID', null, 'COOKIE'); Only trouble is that in some case's I want to reset the value from a link. Any body got any idea how to clear CS_SESSION_LOCATIONID ? Thanks.
  3. Thanks so much, that's perfect..... Unfortunately I can't use sessions as this is going to link to other applications on different servers. Thanks again.
  4. OK I'm off on a bit of a tangent at the moment.... I thought ahead and even if I get the array to the next page I need to extract just the values I need, so I thought it would make more sense to do this first then deal with the array. for($i = 0; $i < $cart["idx"]; $i++) { print_r($cart[$i]['product_id']); echo "<BR/>"; $result=implode(',', $cart[$i]) ; echo $result; } The print r command is outputting exactly the values I want, but I can't get this into the results, logic says to me that I need to use: $result=implode(',', $cart[$i]['product_id']) ; But this gives an error: Warning: implode() [function.implode]: Invalid arguments I might be going about this all wrong, but basically I have an array called $cart which contains multiple items, all i'm trying to do is extract 1 part of the array the product_id, then I was to pass this value via url to a get variable so I can then filter a recordset based on the contents. All I need to do is have a variable on my results page like id1, id2, id3 etc. I would be very grateful for any advice. Thanks in advance..
  5. Sorry the array didn't post correctly: array(3) { ["idx"]=> int(2) [0]=> array(5) { ["quantity"]=> int(4) ["product_id"]=> string(3) "122" ["parent_id"]=> string(3) "122" ["category_id"]=> string(2) "15" ["description"]=> string(0) "" } [1]=> array(5) { ["quantity"]=> int(1) ["product_id"]=> string(2) "77" ["parent_id"]=> string(2) "77" ["category_id"]=> string(2) "19" ["description"]=> string(0) "" } }
  6. I think I'm making the array wrong, can somebody tell me how to extract the product_id into a serialize array from the following Array This is the output from var_dump $cart array(3) { ["idx"]=> int(2) [0]=> array(5) { ["quantity"]=> int(4) ["product_id"]=> string(3) "122" ["parent_id"]=> string(3) "122" ["category_id"]=> string(2) "15" ["description"]=> string(0) "" } [1]=> array(5) { ["quantity"]=> int(1) ["product_id"]=> string(2) "77" ["parent_id"]=> string(2) "77" ["category_id"]=> string(2) "19" ["description"]=> string(0) "" } } All I want to do is get the product_id to another page so I can use it in a select. So I want the the variable /array to be 122, 77 Obviously there maybe more than two items in the array. Thanks again.
  7. Hey thanks for that, I've modified the code to just use product_id: <?PHP $str = serialize($cart[product_id]); $strenc = urlencode($str); print $str . "\n"; echo"<BR?>"; print $strenc . "\n"; ?> <A href="/test/getcart.php?cartinfo=<?PHP echo $strenc; ?>">test</A> <?PHP $cartinfo = unserialize($_GET["cartinfo"]); var_dump($cartinfo); ?> The variable is: cartinfo=N%3B But output is NULL Thanks again.
  8. Hi all, new to php and struggling passing an array via url. first page: $str = serialize($cartinfo); $strenc = urlencode($str); <A href="/test/getcart.php?cartinfo=<?PHP echo $strenc; ?>">test</A> Which does add a long string to the URL so I guess to here it's fine. Second Page: <?PHP $cartinfo = unserialize($_GET["cartinfo"]); var_dump($cartinfo); ?> However all I get is: bool(false) Any advice would be great, I also tried adding $cartinfo to the session, but this didn't work either. Surely passing variables should be straight forward??? Thanks.
  9. Ah cool, I corrected this and got a similar error on $result1 so I changed that to: if(isset($result1)) So no errors now, but the table still isn't updating. As soon as I hit submit any changes lost and the page re-loads the original data. Any ideas? Sorry I'm very new to php...
  10. Thanks so much for your help. I tried this and now I get an error: Fatal error: Call to undefined function is_set() in test.php on line 68
  11. Thanks for that, I thought debugging had to be enable on the server in php.ini. I am very new to php obviously..... At least I'm getting some errors now: Notice: Undefined variable: Submit in test.php on line 68 Notice: Undefined variable: result1 in test.php on line 76 I also thought variables were declared as they were used??? Thanks again.
  12. Hi All, Can't get this code working. the statement works fine directly on the table, just not when executed from the PHP file: <strong>Multi Update</strong><br> <?php $host="localhost"; // Host name $username="user_name"; // Mysql username $password="Password"; // Mysql password $db_name="dbname"; // Database name $tbl_name="tablename"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT mik1vm_product.product_id, mik1vm_product.product_sku, mik1vm_product.product_name, mik1vm_product.product_in_stock, mik1vm_product.product_in_stock_cardiff FROM $tbl_name"; $result=mysql_query($sql); // Count table rows $count=mysql_num_rows($result); ?> <table width="500" border="0" cellspacing="1" cellpadding="0"> <form name="form1" method="post" action=""> <tr> <td> <table width="500" border="0" cellspacing="1" cellpadding="0"> <tr> <td align="center"><strong>Product Id</strong></td> <td align="center"><strong>SKU</strong></td> <td align="center"><strong>Name</strong></td> <td align="center"><strong>In Stock</strong></td> <td align="center"><strong>In Stock Cardiff</strong></td> </tr> <?php while($rows=mysql_fetch_array($result)){ ?> <tr> <td align="center"><? $product_id[]=$rows['product_id']; ?><? echo $rows['product_id']; ?></td> <td align="center"><input name="product_sku[]" type="text" id="product_sku" value="<? echo $rows['product_sku']; ?>"></td> <td align="center"><input name="product_name[]" type="text" id="product_name" value="<? echo $rows['product_name']; ?>"></td> <td align="center"><input name="product_in_stock[]" type="text" id="product_in_stock" value="<? echo $rows['product_in_stock']; ?>"></td> <td align="center"><input name="product_in_stock_cardiff[]" type="text" id="product_in_stock_cardiff" value="<? echo $rows['product_in_stock_cardiff']; ?>"></td> </tr> <?php } ?> <tr> <td colspan="4" align="center"><input type="submit" name="Submit" value="Submit"></td> </tr> </table> </td> </tr> </form> </table> <?php // Check if button name "Submit" is active, do this if($Submit){ for($i=0;$i<$count;$i++){ $sql1="UPDATE $tbl_name SET product_sku='$product_sku[$i]', product_name='$product_name[$i]', product_in_stock='$product_in_stock[$i]' , product_in_stock_cardiff='$product_in_stock_cardiff[$i]' WHERE product_id='$product_id[$i]'"; $result1=mysql_query($sql1); } } if($result1){ header("location:test.php"); } mysql_close(); ?> The page loads fine, but just doesn't update the DB. Thanks in advance for any help.
  13. OK So I've got a datepicker that sends a date in d/m/y format. My DB stores the data in Unix Timestamp Which I can convert the date to with strtotime however this does the exact date & time. All I want is the actual day. I've spent hours trying to convert this with just the day with mixed results... Thanks.
  14. Hi all, I have a what I thought was a call to the db: $db->sp("attrib_stock1"); However when I try to calculate on this field or assign it's value to a variable it fails however if I put it in a page it actually echoes out the value. If I were to say $blahblah = $db->sp("attrib_stock1"); echos $blahblah it would echo 0 (zero) but if I replace it with $db->sp("attrib_stock1"); it echoes out the value. What does $db->sp mean? can I assign this value to a variable? Thanks for any advice.
  15. Yes your absolutely correct. I thought: $db->sp("attrib_stock2") was the value from the database, but it does echo... I don't suppose anybody can break down this: $db->sp("attrib_stock2") to explain further? Thanks very much for your help.
  16. Yes it's exactly like that, It seems to be concatening the two values and adding a zero rather than adding them? $stock_count_attrib1=$db->sp("attrib_stock1"); $stock_count_attrib2=($db->sp("attrib_stock2")); $total_stock_count = ($stock_count_attrib1+$stock_count_attrib2); echo $total_stock_count ; This is pasted from the page. and the results are: 22180
  17. $stock_count_attrib1=$db->sp("attrib_stock1"); $stock_count_attrib2=($db->sp("attrib_stock2")); $total_stock_count = ($stock_count_attrib1+$stock_count_attrib2); echo $total_stock_count ; Outputs: 22180 Value of: attrib_stock1 = 22 Value of: attrib_stock2 = 18 I thought the output should be: 40? Please help. Please excuse my newbieness trying to learn...
  18. Thanks very much for all your help.... hope I can return the good some day.
  19. Can anybody help getting this Array ( [5] => Array ( [1] => Array ( [sKU] => EASY819-AC-RC [Description] => ) [3] => Array ( [sKU] => EASY819-DC-RC [Description] => ) [2] => Array ( [sKU] => EASY819-AC-RCX [Description] => ) ) [6] => Array ( [4] => Array ( [sKU] => EASY719-AB-RC [Description] => ) [5] => Array ( [sKU] => EASY719-AB-RCX [Description] => ) ) ) to output like this: Cat1 Product1 Product2 Cat2 Product3 Product4 I've
  20. OK so it is getting data: Array ( [5] => Array ( [1] => Array ( [sKU] => EASY819-AC-RC [Description] => ) [3] => Array ( [sKU] => EASY819-DC-RC [Description] => ) [2] => Array ( [sKU] => EASY819-AC-RCX [Description] => ) ) [6] => Array ( [4] => Array ( [sKU] => EASY719-AB-RC [Description] => ) [5] => Array ( [sKU] => EASY719-AB-RCX [Description] => ) ) )
  21. OK so looks like it might not be getting data: bool(false) Wierd it works fine on the database directly. No Errors at all.
  22. No nothing at all... I tried: 'SKU' => $r['product_sku'], 'Description' => $r['product_s_desc]', But it was giving a sytax error... Thanks so much for your help. I've been trying this all day...
  23. I'm struggling to get any output from this: <?PHP $sql = " SELECT DISTINCT JVPCX.`category_id`, JVP.`product_id`, JVP.`product_sku`, JVP.`product_s_desc` FROM `jos_vm_product_category_xref` JVPCX INNER JOIN `jos_vm_product` JVP ON JVPCX.`product_id` = JVP.`product_id` "; $res = mysql_query($sql); $list = array(); while ( $r = mysql_fetch_object( $res ) ) { if ( ! isset( $list[ $r->category_id ] ) ) { $list[ $r->category_id ] = array(); } $list[ $r->category_id ][ $r->product_id ] = array( 'SKU' => $r->product_sku, 'Description' => $r->product_s_desc, ); } ?> I am trying to get the following: Cat1 Product1 Product2 Cat2 Product3 Product4 etc etc. Any help would be great... Thanks in advance.
×
×
  • 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.