Jump to content

JsusSalv

Members
  • Posts

    113
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

JsusSalv's Achievements

Member

Member (2/5)

0

Reputation

  1. Thank you everyone for the help. Although a tad tougher to manipulate I am testing Sasa's recursive function with great results. Thank you!
  2. Sasa, is there any way to not make your code into a function? I'm finding the code to be more difficult to manipulate as a function. Is there any other way to make this work without being a function?
  3. Sasa: To add other db column info I would need to write the code like so: function my_div($array,$start,$atrName,$ident=0){ echo str_repeat(" ",$ident),'div '.$atrName.'="'.$start.'">'; if (isset($array[$start])) { echo "<br />"; foreach ($array[$start] as $i) my_div($array,$i['attribute_value'],$i['attribute_name'],$ident+1); //add what part of $i (item) i want } if (isset($array[$start])) echo str_repeat(" ",$ident); echo "/div> !-- end.$start --><br />"; } my_div($my_arr,'siteContainer','id'); However, I don't like that I have to hardcode the values, 'siteContainer','id', to get this to work: my_div($my_arr,'siteContainer','id'); Is there are workaround for that? I would like for it all to be dynamic.
  4. Sasa...you are awesome!!! This works as I had hoped it would. Thank you. I'm perplexed at how simple it looks yet it is so powerful! I owe you a latte my friend! How would I allow other database column info to trickle in there? For example, I have another column entitled 'attribute_name'. Would I append to the following? $my_arr[$item['parent_container_name']][] = $item['attribute_value'].$item['attribute_name']; Probably not but I've tried different configurations and I can't get other columns to spit out appropriately. Again, thank you for your help...much appreciated!!!
  5. Two works fine. But if there are divs that are nested within other divs then I need to account for that. I guess I'm looking for a better way to code this. Here are the db array results: The two arrays contain the same info except that $subcontainers has an extra column for listing which element is its parent element. Each array results is wrapped around div tags: foreach($containers as $parent){ echo '<div id="'.$parent['attribute_value'].'"></div>'; } Array results: echo '<pre>' . print_r($containers , true) . '</pre>'; ==> Array ( [attribute_value] => siteContainer ) Array ( [attribute_value] => header ) Array ( [attribute_value] => logoContainer ) Array ( [attribute_value] => logo ) Array ( [attribute_value] => logoText ) Array ( [attribute_value] => links ) Array ( [attribute_value] => contactInfo ) Array ( [attribute_value] => body ) Array ( [attribute_value] => longDiv ) Array ( [attribute_value] => shortDiv ) Array ( [attribute_value] => headerText ) Array ( [attribute_value] => greetings ) echo '<pre>' . print_r($subcontainers , true) . '</pre>'; ==> Array ( [parent_container_name] => siteContainer [attribute_value] => header ) Array ( [parent_container_name] => header [attribute_value] => logoContainer ) Array ( [parent_container_name] => header [attribute_value] => logo ) Array ( [parent_container_name] => contactInfo [attribute_value] => logoText ) Array ( [parent_container_name] => header [attribute_value] => links ) Array ( [parent_container_name] => header [attribute_value] => contactInfo ) Array ( [parent_container_name] => siteContainer [attribute_value] => body ) Array ( [parent_container_name] => body [attribute_value] => longDiv ) Array ( [parent_container_name] => logoText [attribute_value] => shortDiv ) Array ( [parent_container_name] => shortDiv [attribute_value] => headerText ) Array ( [parent_container_name] => body [attribute_value] => greetings )
  6. I've provided the working code and the results $containers is from a database query that returns the attribute values: siteContainer header logoContainer logo links contactInfo logoText shortDiv headerText body longDiv greetings Bu you are right, the nested loops is working well. However, I wanted something more dynamic than having to manually create ten nested foreach loops.
  7. Good point! I'm actually pulling info from a database via two classes. $containers = DISPLAY::displayParentElements($blah); $subcontainers = DISPLAY::displayChildElements($blah); I then place the resultsets into foreach loops: foreach($containers as $parent) { //extract info, etc... $parentDiv = $parent['parentDiv']; echo '<div id="'.$parentDiv.'">'; foreach($subcontainers as $child) { //extract info, etc... $childDiv = $child['childDiv']; echo '<div id="'.$childDiv.'">'; foreach($subcontainers as $grandChild) { //extract info, etc... $grandChildDiv = $grandChild['grandChildDiv']; echo '<div id="'.$grandChildDiv.'">'; foreach($subcontainers as $greatGrandChild) { //extract info, etc... $greatGrandChildDiv = $greatGrandChild['greatGrandChildDiv']; echo '<div id="'.$greatGrandChildDiv.'">'; echo '</div>'; } echo '</div>'; } echo '</div>'; } echo '</div>'; } The results will look like this (ignore the attribute values as they are just test names): <div id="siteContainer"> <div id="header"> <div id="logoContainer">/div> <div id="logo"></div> <div id="links"></div> <div id="contactInfo"> <div id="logoText"> <div id="shortDiv"> <div class="headerText"></div> </div> </div> </div> </div> <div id="body"> <div id="longDiv"></div> <div id="greetings"></div> </div> <div> Basically, I take the resultset and create div tags for each record. The fun comes in iterating through each result and checking to see if it's a child of another element. If it is then it is echo'd between the parents div tags. The multiple foreach loops do this for as many records that are returned until there are none left to check. Would a recursive function work best in this situation? If so, any examples? I have not worked with recursives yet but have look at info online.
  8. Hello: I have several nested foreach loops like so: foreach($this1 as $that1) { //extract info, etc... foreach($this2 as $that2) { //extract info, etc... foreach($this3 as $that3) { //extract info, etc... foreach($this4 as $that4) { //extract info, etc... foreach($this5 as $that5) { //extract info, etc... } } } } } This is a monster. Is there a way to write a 'for' loop that can iterate through as many nested foreach loops as needed? I don't mind creating a bunch of these foreach loops but somehow I feel that there is a better way. My main priority is to keep the nested order. Thank you!
  9. This one is pretty cool as well: phpJobScheduler http://www.phpjobscheduler.co.uk/
  10. Firstly, get a better host. Secondly, I don't have any scripts for you but check out some of these links for ideas that people have implemented: http://www.weberdev.com/get_example-4498.html http://syn.ac/tech/13/creating-php-cronjobs-without-cron-and-php-cli/ WebBasedCron might help: http://www.webbasedcron.com/ Wordpress plugin: http://www.affordable-internet-marketing.com/2008/01/wordpress-plugin-cron-jobs/ Wish I could help more.
  11. If you want to check manually, just use the following: http://search.dmoz.org/cgi-bin/search?search=domain.com Of course, substitute domain.com for whatever domain you want to check. For example: http://search.dmoz.org/cgi-bin/search?search=phpfreaks.com Are you after a PHP script that will do the above dynamically and return a value? You could take the above link and create a PHP script that will return a value based on whether a value was returned or not. Give a bit more info on what you're trying to do exactly so we can post better ideas/code. Thanks!
  12. Sometimes you need to give IP access to the server that is trying to connect remotely to the database. check out this link and also read the comments at the bottom: http://dev.mysql.com/doc/refman/5.1/en/access-denied.html Host I use has a section for my usernames where I can state which IP addresses can access that particular username's access to database server. So check with your host/server if there is an area to enter allowed IP addresses. Try this Google search as well: "mysql allow ip access" http://www.google.com/search?q=mysql+allow+ip+access&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a Hope it helps a bit.
  13. I would like to figure out how to get the eval(); working. But this seems to have worked pretty well: ob_start(); echo include('file/name/here.php'); ob_end_flush(); I am very thankful to all the suggestions! roopurt18, Thorpe, thank you greatly!
  14. Well, it does transfer the contents of the file into the proxy file. But the CSS doesn't style anything, yet, I can see the code in the stylesheet. Hmmm....
  15. That is probably the easiest idea I've seen!!!! Gonna try it now. Thanks Thorpe!
×
×
  • 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.