Jump to content

piznac

Members
  • Posts

    261
  • Joined

  • Last visited

Contact Methods

  • MSN
    piznac@hotmail.com

Profile Information

  • Gender
    Not Telling

piznac's Achievements

Member

Member (2/5)

0

Reputation

  1. Yeah I assumed that would be the first question I would get. I am doing a lot more to this query after the fact when building this array. This particular part is an add on after the fact,.. so Im trying to avoid re-writing everything. Ok sounds solid,. thank you!
  2. Hello all! I have this array of objects: Array ( [0] => stdClass Object ( [first_name] => test [last_name] => test [title] => test [id] => 34 [type] => 4 [manager] => 4 [email] => p@yahoo.com [date] => 2014-09-21 07:23:12 [status] => 2 [approval_date] => 2014-09-21 07:31:10 [assessment_id] => 1 [supervisor_approval] => 1 [manager_approval_date] => 2014-09-21 07:31:27 [mainmanger] => 3 ) [1] => stdClass Object ( [first_name] => test [last_name] => test [title] => test [id] => 34 [type] => 4 [manager] => 4 [email] => p@yahoo.com [date] => 2014-09-20 07:39:55 [status] => 2 [approval_date] => 2014-09-20 07:40:41 [assessment_id] => 3 [supervisor_approval] => 1 [manager_approval_date] => 2014-09-20 07:41:07 [mainmanger] => 3 ) [2] => stdClass Object ( [first_name] => jimmy john john [last_name] => john [title] => Lorad and Master [id] => 32 [type] => 4 [manager] => 3 [email] => j@j.com [date] => 2014-09-21 07:38:50 [status] => 2 [approval_date] => 2014-09-19 07:39:25 [assessment_id] => 2 [supervisor_approval] => 1 [manager_approval_date] => 2014-09-19 07:39:25 [mainmanger] => 0 ) ) Where "id" = the user ID. If there are two or more entries for a user, I want to remove all but the most recent by the "approval_date",... So for the above example it would return: Array ( [0] => stdClass Object ( [first_name] => test [last_name] => test [title] => test [id] => 34 [type] => 4 [manager] => 4 [email] => piznac@yahoo.com [date] => 2014-09-21 07:23:12 [status] => 2 [approval_date] => 2014-09-21 07:31:10 [assessment_id] => 1 [supervisor_approval] => 1 [manager_approval_date] => 2014-09-21 07:31:27 [mainmanger] => 3 ) [1] => stdClass Object ( [first_name] => jimmy john john [last_name] => john [title] => Lorad and Master [id] => 32 [type] => 4 [manager] => 3 [email] => j@j.com [date] => 2014-09-21 07:38:50 [status] => 2 [approval_date] => 2014-09-19 07:39:25 [assessment_id] => 2 [supervisor_approval] => 1 [manager_approval_date] => 2014-09-19 07:39:25 [mainmanger] => 0 ) ) I'm having a hard time wrapping my head around this concept, so I don't have any example code. And I don't really need or expect someone to code this for me,. just a push in the right direction would be awesome.
  3. Geez such a simple solution and it never dawned on me,.. thanks a bunch man!
  4. I have several arrays similar to this one: [2] => Array ( [0] => Array ( [player] => piznac [playerId] => 1 [positionRow] => 0 ) [1] => Array ( [player] => [playerId] => [positionRow] => ) [2] => Array ( [player] => Player 3 [playerId] => 3 [positionRow] => 1 ) [3] => Array ( [player] => [playerId] => [positionRow] => ) ) How would I re-sort this array by the 'positionRow' key with still keeping the empty arrays. Something like this: [2] => Array ( [0] => Array ( [player] => piznac [playerId] => 1 [positionRow] => 0 ) [1] => Array ( [player] => Player 3 [playerId] => 3 [positionRow] => 1 ) [2] => Array ( [player] => [playerId] => [positionRow] => ) [3] => Array ( [player] => [playerId] => [positionRow] => ) )
  5. Wow, holy crap I could have sworn I tried that. But a quick script later and now it worked fine. public function testImageConvert() { $query = $this->db->query("SELECT Picture FROM `ItemPicture` LIMIT 1"); if($query->num_rows() > 0) { $row = $query->row(); file_put_contents('test.jpg',$row->Picture); } return false; } Thanks for the help!!! - I must have done something strange last time I tried this.
  6. Hi! I got stuck with a project utilizing a DB full of images in a BLOB format. It's a basic shopping cart and I looped through the images with something like this: <img src="data:image/jpeg;base64,<?php echo base64_encode($content); ?>" width="100" /> Where $content equals the Blob data. As I thought, this is laggy as can be(trying to loop and re size is a nightmare slow.). So I want to write a script to convert them all to images and then save to file. And then of course write a line to a new table to use(since I always use the link in DB and image in file system technique, I have no knowledge on this Blob thing). I have tried many things, however I can't seem to get any images to save as actual files(There seems to be tons of articles on saving as Blob and re displaying image, but not on saving it back to file.). Sadly my pc just crashed so I don't have any of the code where I tried. I don't need it written, just a nudge in the write direction I can write everything up until the actual save to this directory portion. Just need that nudge with that part. Thanks for anyone's time for this!! **Edit - Just noticed my sig. None of that data is correct at this point. I can provide that data if needed. php 5.XX of course.
  7. Ok cool,. Ill check that out,. thanks.
  8. array_filter looks like a good option, but I don't understand how to make a callback to show the values. Am I getting closer? lol
  9. How can I limit a foreach loop based on the value of an array. I tried something like this and it didn't work: foreach($options as $key => $value) { if($key != 'sortby' || $key != 'sortdirection') { $this->db->where($key,$value); } } This what I'm sending it: array('lad_id' => $ladid, 'sortby' => 'score', 'sortdirection' => 'ASC') I saw that I could do something like this: array_slice($options, 0, 2) However I wont know the numbers, I would like to limit it by the array values. Is there a way to do this? Thank you.
  10. Im a bit confused by the last comment. I want to have option categories for each product and options for each category. What is is displaying right nwo is this: Top Draft Stop NO Top Draft Stop HOOD-recommended for exterior mount aplications 3 FT Top Draft Stop Curtain Color Orientation NO Hood Where it should display: Top Draft Stop NO Top Draft Stop 3 FT Top Draft Stop HOOD-recommended for exterior mount aplications NO Hood Curtain Color Orientation
  11. Ok I will start the research process,. thanks for the tips,. if you have any more Im all ears!
  12. Yeah thats what I figured you guys would say lol. Would something like this work <?php function pro_options($id){ // Construct our join query $query = "SELECT * ". "FROM pro_op_main , prod_op ,prodsub_op ". "WHERE pro_op_main.pro_id = '$id' && pro_op_main.op_id = prod_op.op_id && prod_op.op_id = prodsub_op.prod_subid"; $result = mysql_query($query) or die(mysql_error()); // Print out the contents of each row into a table while($row = mysql_fetch_array($result)){ echo $row['prod_op.name']. " - ". $row['prod_op.desc']; echo "<br />"; echo $row['prodsub_op.name']; echo "<br />"; } } ?>
  13. Sorry was tabbing and hit the eneter key by accident,. please check again.
  14. I have three tables: Table A contains all product id and a option id. Table B contains all option types,. ie name,desc,option id, product id. Tabke c contains the actual sub options ie name,desc, add price, option id, sub option id. Products Table A Table B Table C pro_id ------------prod_id Name Name option_id--------option_id----option_sub_id desc desc image price image Ok what Im trying to do is list custom options of a given product. I may have gone about this backwards or just plain strange, but here is what Im hoping to do: Based on a product Id var: Table B.name Table B.desc <br> Then list each option based of Table B.option_id: Table C.name Table C.desc ANd repeat this Table B.name Table B.desc <br> Then list each option based of Table B.option_id: Table C.name Table C.desc Table C.name Table C.desc Table C.name Table C.desc Table B.name Table B.desc <br> Then list each option based of Table B.option_id: Table C.name Table C.desc Now Im confised,. here is what I have tried: <?php function pro_options($id){ $sql = "SELECT * FROM `pro_op_main` WHERE `pro_id` = '$id' "; $result = mysql_query($sql); $row = mysql_fetch_array($result); $num_rows = mysql_num_rows($result); do{ $opid = $row['op_id']; //get subid data $sql2 = "SELECT * FROM `prod_op` WHERE `op_id` = '$opid' "; $result2 = mysql_query($sql2); $row2 = mysql_fetch_array($result2); $num_rows2 = mysql_num_rows($result2); do{ $op_id = $row2['op_id']; $opname = $row2['name']; $op_id2 = explode(" ",$op_id); foreach($op_id2 as $key){ //get option values $sql3 = "SELECT * FROM `prodsub_op` WHERE `prodsub_op_id` = '$key' "; $result3 = mysql_query($sql3); $row3 = mysql_fetch_array($result3); $num_rows3 = mysql_num_rows($result3); echo "$opname<br />"; echo $row3['name']; } }while($row2 = mysql_fetch_array($result2)); }while($row = mysql_fetch_array($result)); } ?> && <?php function pro_options($id){ $sql = "SELECT * FROM `pro_op_main` WHERE `pro_id` = '$id' "; $result = mysql_query($sql); $row = mysql_fetch_array($result); $num_rows = mysql_num_rows($result); //make array of results id do{ $opid = $row['op_id']; $opidarray = explode(" ",$opid); print_r($opidarray); foreach($opidarray as $id){ $sql2 = "SELECT * FROM `prod_op` WHERE `op_id` = '$id' "; $result2 = mysql_query($sql2); $row2 = mysql_fetch_array($result2); $num_rows2 = mysql_num_rows($result2); do{ echo "<br />"; echo "<b>"; echo $row2['name']; echo "</b>"; echo "<br />"; echo $row2['desc']; echo "<br />"; $id2 = $row2['op_id']; $op_sub_id = explode(" ",$id2); foreach($op_sub_id as $newid){ //get option values $sql3 = "SELECT * FROM `prodsub_op` WHERE `prodsub_op_id` = '$newid' "; $result3 = mysql_query($sql3); $row3 = mysql_fetch_array($result3); $num_rows3 = mysql_num_rows($result3); do{ echo "<br />"; echo $row3['name']; echo "<br />"; }while($row3 = mysql_fetch_array($result3)); } }while($row2 = mysql_fetch_array($result2)); } }while($row = mysql_fetch_array($result)); ?> What this is returning is correct but the table c results are not returning under the correct table B headers. Can you guys understand this?
×
×
  • 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.