Jump to content

yonny

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

yonny's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. try this <?php $url="http://natty.com/p/bh-fitness-class-indoor-magnetic-exercise-bike-2-years-parts-/detail/b004r2wuak/fitness-spinning.html"; preg_match_all("/\/\w{2,20}-\w{2,20}.html/", $url, $matches); print"<pre>"; print_r($matches); print"</pre>"; $last = $matches[0][0]; $take_out = array('/', '-', '.html'); $put_in = array('', ' ', ''); $last = str_replace($take_out, $put_in, $last); print"$last"; ?> it outputs this Array ( [0] => Array ( [0] => /fitness-spinning.html ) ) fitness spinning
  2. Im glad it is working for you. When you enable multiple choice in your forms, you need to process multiple values of the same element. So you create an array of selected values by adding the brackets at the end of the element name. Then just iterate through them after post.
  3. instead of <input type="checkbox" name="name" value="{name}"> try this <input type="checkbox" name="name[]" value="{name}" /> then $checks=$_POST['name']; while (list ($key,$val) = @each ($checks)) { print"$val <br>"; }
  4. You are welcome. I'm glad it worked out.
  5. try this. i have not tested it but... <?php $query_meni = "SELECT * FROM meni WHERE lang_id = '$jezik'"; $result = mysql_query($query_meni); $count = mysq_affected_rows(); if($count >0 ): print"<ul class=\"main_menu\">"; /// open main menu while($row_meni = mysql_fetch_array($query_meni)): $link = $row_meni['id_meni']; $show = $row_meni['naslov']; print"<li><a href=\"index.php?page=$link\">$show</a>"; $query_subject = "SELECT * FROM subjects WHERE meni_id = '$row_meni[id_meni]' AND lang_id = '$jezik' ORDER BY pozicija ASC"; $result1 = mysql_query($query_subject); $count1 = mysql_affected_rows(); if($count1 == 0): print "</li>"; /// close list else: print"<ul class=\"subnav\">"; /// start sublist before 2nd while loop while($row_subjects = mysql_fetch_array($query_subject)): $link1 = $row_subjects['subject_id']; $show1 = $row_subjects['naslov']; print"<li> <a href=\"index.php?subject=$link1\">$show1</a></li>"; endwhile; print"</ul>"; /// end sublist after while loop endif; print"</li>"; /// close list at endif endwhile; print"</li>"; ///close parent endif; print"</ul>"; /// close main ?>
  6. this is the code you posted on another post <li><a href="#">Home</a></li> <li><a href="#">About Us</a></li> <li><a href="#">Web Design</a> <ul class="subnav"> <li><a href="#">Corporate</a></li> <li><a href="#">Small Business</a></li> <li><a href="#">HTML Templates</a></li> <li><a href="#">Joomla Templates</a></li> </ul> </li> so to make it work with what you have // make your sql_query // count the affected rows // if not 0 start the menu by printing <ul> // start your first loop print "<li><a href=\"$some_link\">$some_column</a>"; \\ do not close <li> yet because you dont know if it has a submenu // do the second sql query // count the affected rows // if 0 rows then print "</li>"; \\ to close that one and move on with the next // else (not 0 rows) then print "<ul class=\"subnav\">"; // now run your second while loop print"<li><a href=\"$sub_page\">$submenu_item</a></li>"; //etc <li><a href="#">Small Business</a></li> <li><a href="#">HTML Templates</a></li> <li><a href="#">Joomla Templates</a></li> // endwhile; print"</ul>"; endif; print"</li>"; //and repeat if for some reason you need to link to anchors in the same page you need to set the mainmenu link to "#" as opposed to "website_file.php#" and the submenues to "#anchor" instead of "website_file.php#anchor" or they will not work. i used PHP_SELF to check if I was inside the page or not. so if the page I was in was about.php and i had anchors in it i would print"<li><a href=\"#123\">$submenu_item</a></li>"; if it was not about.php i would print"<li><a href=\"about.php#123\">$submenu_item</a></li>";
  7. Hi, I have done these menus before and I think you need to start with a <ul> before any while loop. While inside the first loop for the fist menu print <li> link </li> then if the second sql query has a result the second <ul> that starts the submenu needs to print before the second while loop. The second while loop needs to print only <li> link </li>. once that loop is done close the second </ul> ending the submenu. After you closed the first loop then close </li> and </ul>. [attachment deleted by admin]
  8. I made a menu with an array of directories and files. the code is in my post here http://www.phpfreaks.com/forums/index.php?topic=327381.0, I cleaned it and fixed all the issues I had since then. It puts out a menu like the one in the attachment. Good luck. [attachment deleted by admin]
  9. I know almost nothing about javascript, only that it runs on the client side. Sorry.
  10. hi, i just did something like that but it was a dirty hack that i'm trying to get people help me clean. i posted it here today http://www.phpfreaks.com/forums/index.php?topic=327381.0 see if it would apply to what you wanted to get done mine outputs something like this # Adults * Adults Orange * Adults Purple * Adults Yellow # Dragons * Dragons Orange * Dragons Purple * Dragons Yellow # Instructors * Instructors Black * Instructors Red # Juniors * Juniors Orange * Juniors Purple and keeps growing as folders get added. this is reading a directory and subdirectories. i dont know where you are getting your data from but i have done the same with mysql and it was much much simpler. good luck
  11. I do some php , mostly with built in functions tho. i am helping a friend redo his website, he teaches karate. i used a blog as the engine and some css template for the pages. menus and content are pulled from the blog mysql. it is really easy to change and update the site. but i spent allllll day and night working on the members area of it. i know you guys could have done it in one hour flat, perhaps sooner, but i wanted to ask you guys for pointers on how to accomplish what i did easier and cleaner. I wanted to make the members area easier to maintain and update, so i decided to just scan the directories recursively for changes and create jquery menus and submenus from there. sounded pretty easy when i started. I had a big-time issue integrating the menu into the existing main menu so I had to put it as a menu of its own somewhere else. Mostly due to my inability to cleanly insert the <ul> s needed for the submenus. ended up with this # Adults * Adults Orange * Adults Purple * Adults Yellow # Dragons * Dragons Orange * Dragons Purple * Dragons Yellow # Instructors * Instructors Black * Instructors Red # Juniors * Juniors Orange * Juniors Purple from this [/usr/local/www/data3/testsite/members/adults/orange/images] => Array ( [0] => forward bow side.jpg [1] => ._forward bow side.jpg [2] => forward bow front.jpg [3] => ._forward bow front.jpg ) [/usr/local/www/data3/testsite/members/adults/orange/videos/flv] => Array ( [0] => side kick.flv [1] => palm heel.flv [2] => inward parry.flv [3] => outward parry.flv ) [/usr/local/www/data3/testsite/members/adults/orange/documents] => Array ( [0] => doc-testdocument.txt ) [/usr/local/www/data3/testsite/members/adults/orange/certificates] => Array ( [0] => cert-testcertificate.txt ) [/usr/local/www/data3/testsite/members/adults/purple/videos/flv] => Array ( [0] => axe kick.flv ) [/usr/local/www/data3/testsite/members/adults/purple/certificates] => Array ( [0] => cert-testcertificate.txt ) [/usr/local/www/data3/testsite/members/adults/purple/documents] => Array ( [0] => doc-testdocument.txt [1] => ._doc-testdocument.txt ) [/usr/local/www/data3/testsite/members/adults/yellow/images] => Array ( [0] => horse stance.jpg [1] => ._horse stance.jpg [2] => meditation stance.jpg [3] => ._meditation stance.jpg [4] => right neutral bow.jpg [5] => ._right neutral bow.jpg [6] => attention stance.jpg [7] => ._attention stance.jpg [8] => left neutral bow.jpg [9] => ._left neutral bow.jpg ) [/usr/local/www/data3/testsite/members/adults/yellow/videos/flv] => Array ( [0] => back kick.flv [1] => drag step.flv [2] => form one.flv [3] => cover.flv [4] => front kick.flv [5] => downward block.flv [6] => hammer fist.flv [7] => hand sword.flv [8] => inward block.flv [9] => moving blocking set.flv [10] => outward block.flv [11] => roundhouse kick.flv [12] => step drag.flv [13] => step thru.flv [14] => vertical punch.flv [15] => switch.flv [16] => straight punch.flv [17] => upward block.flv [18] => back fist.flv [19] => blocking set.flv [20] => extended outward block.flv ) [/usr/local/www/data3/testsite/members/adults/yellow/certificates] => Array ( [0] => cert-testcertificate.txt ) [/usr/local/www/data3/testsite/members/adults/yellow/documents] => Array ( [0] => doc-testdocument.txt ) [/usr/local/www/data3/testsite/members/adults] => Array ( [0] => donotdelte.txt ) as you can see it is matter of creating a menu from members folders named after a class, a belt color, a type of resource, etc. so that when there is the need to add any of them the jquery menu and submenus would update themselves. no need to mess with html, php, mysql, blog etc. just drag and drop. so to speak. well here is the code i used, i big portion of it borrowed, please help me understand how to make it better. I will hit the books and stuff, I just got to know at this time. thanks in advance. <?php $basedir = "/usr/local/www/data3/testsite/members"; // directory to scan $filearray= array(); $directory= array(); $placecount = 0; $directory[] = "/"; do { $dh = opendir($basedir . $directory[$placecount]); while (($file = readdir($dh)) !== false) { if(filetype($basedir . $directory[$placecount] . $file) == 'dir' AND (($file != '.') AND ($file != '..'))) { $directory[] = $directory[$placecount] ."". $file."/"; } elseif(filetype($basedir . $directory[$placecount].$file) != 'dir') { $filearray[] = $directory[$placecount];//.$file; only output dirs } } closedir($dh); $placecount +=1; } while($placecount != count($directory)); // Sort the array natsort($filearray); $filearray=array_unique($filearray); $filearray=array_values($filearray); foreach ( $filearray as $key => $value ) { //remove unwanted files if(!eregi("._|jpg|doc|txt|png|avi|flv|swf|certif|images|thumb|videos",$value)): $var2 .="|$value"; endif; } $var3=explode("|", $var2); $count_var=sizeof($var3); Preg_match_all("/\/\w{2,20}\//", $var2, $matches2);// match single folders ie /folder/ $matches2=array_unique($matches2[0]);//group $matches2=array_values($matches2);//reset keys function sortByLength($a,$b){ return (strlen($a) - strlen($b)); } usort($matches2,'sortByLength');//sort by length $first_folder = end($matches2); // get the longest string foreach ($matches2 as $name => $folders) { $single_folders .= "aa $folders bb|";// turn into string } $longest_folder=strlen($first_folder); $single_folders=substr($single_folders,0,-1); $count_matches2=sizeof($matches2); print"<ul>\n"; foreach($var3 as $key => $val): $val_to_show=trim(ucwords(str_replace("/", " ", $val))); if(strlen($val) > 2): $link .="<li><a href=\"?to_get=$val\">$val_to_show</a>\n"; endif; endforeach; /* how $link is displayed <ul> </li> </ul><li><a href="?to_get=/adults/">Adults</a> <li><a href="?to_get=/adults/orange/">Adults Orange</a> <li><a href="?to_get=/adults/purple/">Adults Purple</a> <li><a href="?to_get=/adults/yellow/">Adults Yellow</a> <li><a href="?to_get=/dragons/">Dragons</a> <li><a href="?to_get=/dragons/orange/">Dragons Orange</a> <li><a href="?to_get=/dragons/purple/">Dragons Purple</a> <li><a href="?to_get=/dragons/yellow/">Dragons Yellow</a> <li><a href="?to_get=/instructors/">Instructors</a> <li><a href="?to_get=/instructors/black/">Instructors Black</a> <li><a href="?to_get=/juniors/">Juniors</a> <ul> <li><a href="?to_get=/juniors/orange/">Juniors Orange</a> <li><a href="?to_get=/juniors/purple/">Juniors Purple</a> <li><a href="?to_get=/juniors/yellow/">Juniors Yellow</a> */ preg_match_all("/<li><a href.*to_get.*>\w{1,20}<\/a>/",$link, $single_folders_matches); //match parent subfolders $count_single_folder_matches=sizeof($single_folders_matches[0]); foreach($single_folders_matches[0] as $key => $old): $link1=$link; $new="</li> </ul> $old <ul></li>"; //print"$link1"; unset($link); $link = str_replace($old, $new, $link1); endforeach; print"$link"; print"</li></ul></li><li>"; ?>
×
×
  • 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.