Jump to content

Napper

Members
  • Posts

    14
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling
  • Location
    Europe

Napper's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi everybody, I working on a CMS system and was wondering how you explain to google what your most important pages are. Like in the attachement. You see it with lots of the proffessional websites that if you enter "Canon" you will get www.canon.com as a hit and then underneath that neatly arranged the quicklink for drivers, support, products, etc. How do they do that? I want that, too... Kind regards, Napper [attachment deleted by admin]
  2. It's working! It's working!!! Bucking frilliant!!! So I did what nogray suggestet, plugged the code directly into the PHP file and updated the variables with PHP instead of hunting for classes... Thanks you guys!!! This is awesome! Here is, how it looks like in my PHP file now (I know, there is one comma to much in the output, but I couldn't wait to see if it was working... <script type="text/javascript"> function toggle_alpha(target) { var divs = [<?php foreach ($phrases as $key => $line) { ?>'<?php echo $key;?>',<?php }; ?>]; for (i=0; i<divs.length; i++) document.getElementById('Searchstring_'+divs[i]).style.display = "none"; document.getElementById(target).style.display = "inline"; } </script>
  3. Nice! I thought I would need to figure this out in JavaScript only, but to combine the two... Could work - will try.
  4. Hi fennway, hi nogray, thank you for your answers. As I started to implement this I realized that I hadn't quite figured this out yet after all. Your solutions work fine for the problem described but it is a bit more complex than I thought after all. Let me elaborate: First of, I do not always have all the letters around. The system checks the database for Keywords and if it finds "A"s it will write a div id "A" and put all the keywords there, and so forth, but if there are no "F"s then it will not write the "F" id, so my menue could look like this A - B - C - D - F - K - L - P - Q - R - S - Z Then I have a sort of Keyword Grouping PHP function, so if I have keywords like "color red", "color green", "color blue" it will make a special case of it, changing my Menue like this A - B - C - Color - D - F - K - L - P - Q - R - S - Z All this is done in PHP. Now I essentially want people to be able to click on A and see the As, click on B, hide the As see the Bs, etc. Hence my idea of giving all of those created divs a class "Keywords" and to first hide all of those, then display the one I want with obj=(document.all) ? document.all[target] : document.getElementById(target); obj.style.display = 'inline'; I had that crazy notion that there might be a getEmelemtsByClass(class) function, but there isn't. Browsing the web, I stumbled upon some ideas, but I can't really piece it together, for me to work. I've been trying to put it together, but it's essentially trial and error without real knowledge. Can you see what I am heading for? function hideshow(hideclass,showelement) { var a = []; var re = new RegExp('\\b' + hideclass + '\\b'); var els = document.getElementsByTagName("*"); for(var i=0,j=els.length; i<j; i++) if(re.test(els[i].hideclass)){obj.style.display = 'hide'; <-- As far as I understand it this is where I should tell the script to hide the found item but how?; }; obj=(document.all) ? document.all[showelement] : document.getElementById(showelement); obj.style.display = 'inline'; } Can you help me? Kind regards, Napper
  5. Hi everybody, I am a bit ashamed to post this but I _know_ that there is a better way than what I have come up here. As you can see, I am more from the PHP side, but sometimes JavaScript is unavoidable. Essentially what I want is to hide all divs with an id starting with "Searchstring_" and then showing the one in the target area. Practical implementation is, that if you click on "A" on the webpage all "A"s unhide, if you click on "B" the "A"s hide again and the "B"s unhide. So... this is what I came up with... function toggle_alpha(target) { obj=(document.all) ? document.all['Searchstring_A'] : document.getElementById('Searchstring_A'); obj.style.display= 'none'; obj=(document.all) ? document.all['Searchstring_B'] : document.getElementById('Searchstring_B'); obj.style.display= 'none'; obj=(document.all) ? document.all['Searchstring_C'] : document.getElementById('Searchstring_C'); obj.style.display= 'none'; obj=(document.all) ? document.all['Searchstring_D'] : document.getElementById('Searchstring_D'); obj.style.display= 'none'; obj=(document.all) ? document.all['Searchstring_E'] : document.getElementById('Searchstring_E'); obj.style.display= 'none'; obj=(document.all) ? document.all['Searchstring_F'] : document.getElementById('Searchstring_F'); obj.style.display= 'none'; obj=(document.all) ? document.all['Searchstring_G'] : document.getElementById('Searchstring_G'); obj.style.display= 'none'; obj=(document.all) ? document.all['Searchstring_I'] : document.getElementById('Searchstring_I'); obj.style.display= 'none'; obj=(document.all) ? document.all['Searchstring_J'] : document.getElementById('Searchstring_J'); obj.style.display= 'none'; obj=(document.all) ? document.all['Searchstring_K'] : document.getElementById('Searchstring_K'); obj.style.display= 'none'; obj=(document.all) ? document.all['Searchstring_L'] : document.getElementById('Searchstring_L'); obj.style.display= 'none'; obj=(document.all) ? document.all['Searchstring_M'] : document.getElementById('Searchstring_M'); obj.style.display= 'none'; obj=(document.all) ? document.all['Searchstring_N'] : document.getElementById('Searchstring_N'); obj.style.display= 'none'; obj=(document.all) ? document.all['Searchstring_O'] : document.getElementById('Searchstring_O'); obj.style.display= 'none'; obj=(document.all) ? document.all['Searchstring_P'] : document.getElementById('Searchstring_P'); obj.style.display= 'none'; obj=(document.all) ? document.all['Searchstring_Q'] : document.getElementById('Searchstring_Q'); obj.style.display= 'none'; obj=(document.all) ? document.all['Searchstring_R'] : document.getElementById('Searchstring_R'); obj.style.display= 'none'; obj=(document.all) ? document.all['Searchstring_S'] : document.getElementById('Searchstring_S'); obj.style.display= 'none'; obj=(document.all) ? document.all['Searchstring_T'] : document.getElementById('Searchstring_T'); obj.style.display= 'none'; obj=(document.all) ? document.all['Searchstring_U'] : document.getElementById('Searchstring_U'); obj.style.display= 'none'; obj=(document.all) ? document.all['Searchstring_V'] : document.getElementById('Searchstring_V'); obj.style.display= 'none'; obj=(document.all) ? document.all['Searchstring_W'] : document.getElementById('Searchstring_W'); obj.style.display= 'none'; obj=(document.all) ? document.all['Searchstring_Q'] : document.getElementById('Searchstring_Q'); obj.style.display= 'none'; obj=(document.all) ? document.all['Searchstring_R'] : document.getElementById('Searchstring_R'); obj.style.display= 'none'; obj=(document.all) ? document.all['Searchstring_S'] : document.getElementById('Searchstring_S'); obj.style.display= 'none'; obj=(document.all) ? document.all['Searchstring_T'] : document.getElementById('Searchstring_T'); obj.style.display= 'none'; obj=(document.all) ? document.all['Searchstring_U'] : document.getElementById('Searchstring_U'); obj.style.display= 'none'; obj=(document.all) ? document.all['Searchstring_V'] : document.getElementById('Searchstring_V'); obj.style.display= 'none'; obj=(document.all) ? document.all['Searchstring_W'] : document.getElementById('Searchstring_W'); obj.style.display= 'none'; obj=(document.all) ? document.all['Searchstring_X'] : document.getElementById('Searchstring_X'); obj.style.display= 'none'; obj=(document.all) ? document.all['Searchstring_Y'] : document.getElementById('Searchstring_Y'); obj.style.display= 'none'; obj=(document.all) ? document.all['Searchstring_Z'] : document.getElementById('Searchstring_Z'); obj.style.display= 'none'; obj=(document.all) ? document.all[target] : document.getElementById(target); obj.style.display = 'inline'; } Pretty ugly! How can I - how shall I put it - condense this? Kind regards, Napper
  6. Hi Sasa! Thanks for the quick help. This is almost working the way I need it. I will post my complete code once it is done (still a few quirks, because the actual code is more complex...) Still, this is already doing wonders. Problem definetly solved! Kind regards, Napper
  7. What can I say Barand? Beautiful! I was just fiddling around with Zivs array_walk idea, when your post poppled up. I rebuilt the function now to be case-insensitive: <?php $phrases = array(); foreach ($array_all_keywords as $line) { if (stripos($line, 'a')===0) { $phrases['A'][] = $line; } elseif (stripos($line, 'b')===0) { $phrases['B'][] = $line; } elseif (stripos($line, 'c')===0) { $phrases['C'][] = $line; } elseif (stripos($line, 'd')===0) { $phrases['D'][] = $line; } elseif (stripos($line, 'e')===0) { $phrases['E'][] = $line; } elseif (stripos($line, 'f')===0) { $phrases['F'][] = $line; } elseif (stripos($line, 'g')===0) { $phrases['G'][] = $line; } elseif (stripos($line, 'h')===0) { $phrases['H'][] = $line; } elseif (stripos($line, 'i')===0) { $phrases['I'][] = $line; } elseif (stripos($line, 'j')===0) { $phrases['J'][] = $line; } elseif (stripos($line, 'k')===0) { $phrases['K'][] = $line; } elseif (stripos($line, 'l')===0) { $phrases['L'][] = $line; } elseif (stripos($line, 'm')===0) { $phrases['M'][] = $line; } elseif (stripos($line, 'n')===0) { $phrases['N'][] = $line; } elseif (stripos($line, 'o')===0) { $phrases['O'][] = $line; } elseif (stripos($line, 'p')===0) { $phrases['P'][] = $line; } elseif (stripos($line, 'q')===0) { $phrases['Q'][] = $line; } elseif (stripos($line, 'r')===0) { $phrases['R'][] = $line; } elseif (stripos($line, 's')===0) { $phrases['S'][] = $line; } elseif (stripos($line, 't')===0) { $phrases['T'][] = $line; } elseif (stripos($line, 'u')===0) { $phrases['U'][] = $line; } elseif (stripos($line, 'v')===0) { $phrases['V'][] = $line; } elseif (stripos($line, 'w')===0) { $phrases['W'][] = $line; } elseif (stripos($line, 'x')===0) { $phrases['X'][] = $line; } elseif (stripos($line, 'y')===0) { $phrases['Y'][] = $line; } elseif (stripos($line, 'z')===0) { $phrases['Z'][] = $line; } else { $phrases['#'][] = $line; } } echo '<pre>', print_r($phrases, true), '</pre>'; ?> A bit more tricky however, is the next bit. I want the programm to bundle Strings that start the same (basically strings that are the same until the first emtpy space) in order to manipulate of how they are displayed. Let's say you have that array: <?php $ar = array ( 'A stitch in time saves nine', 'Birds of a feather flock together', 'All that glisters is not gold', 'type Hat', 'Bat and ball', 'Color red', 'Type trouser', 'A fool and his money are soon parted', 'Color yellow', 'color green', 'type baggy' ); ?> And you want to find all the Colors and types, except that you don't know that the strings you are looking for start with "Color " or "Type" you just want all the instances that start the same bundled together. The occurance of strings that start the same is user dependent, so I don't know, which words to search for. Trying to figure this out right now. Any ideas?
  8. Hi everybody, I am not getting anywhere with this. Could somebody throw me a pointer into the right direction? I have an array with a whole bunch of phrases. To make it easier for my user to navigate through this huge list I want to do split that array based on the first characters of the words. So I need a function that goes through the array and collects all the text strings that _start_ with "A" and puts them into a new array. I also have a special case where I need to find all the text strings that start with "Color ". What function would be best to use here? Greetings, Napper
  9. Well, as far as I understand it you naturally need to define a value for $id first, which should happen on the page before the one you want the user details to be on. (The idex page that lists all the users, or whatever). I did that by defining passing on the variable in the link in this manner: <a href=\"user_details.php?user_id=<? echo \"$id\";?>\"> which would look like this in HTML (given user 345 was clicked): <a href=\"user_details.php?user_id=345\"> Following this link would lead you to the website user_detail.php and while passing on the value 345 for your user_id. This in turn should then be sufficient to filter the MySQL database for the detail-information on user 345. Uh, one other difference I found (but as I said, I do not know much about this either) is that I am mentioning the database again in my \"where\" statement (mainly because I draw information out of different tables). So that looks then like this: $query=\"SELECT * FROM contacts WHERE contacts.id=\'$id\'\"; Either way, before to long I hope a senior member will tell you what *really* to do... Reg. Napper
  10. Yo dude, okay I am not too sure if I can help you since I am at the very, very beginning of my journey to master php/mysql but I happened to have had the same problem like you today. Situation was that I was passing on some variable from one site to the other and wanted to base the selection of database entries on these variables. After 4 hours of trial and error I finally found something that worked for me. Essentially I all you need to do (I hope) is adding some of them funny little \' signs (me foreigner. me not know word for \') around your variable, sorta in this fassion: $query=\"SELECT * FROM contacts WHERE id=\'$id\'\"; Did the trick for me. Oh, well. Hope it helps. Reg. Napper
  11. Okay - maybe I have already figured it out myself. Do search engines in general follow whatever link there is, lets say on the starting page, and then read the information of the site. Meaning, do search engines recognize links of the format http://www.domain.com/shop/category.php?ca...tegory_id=test1 as being a different site as http://www.domain.com/shop/category.php?ca...tegory_id=test2 and if so, do they index them?
  12. Hello again, I am pleased to report that I finally managed to get this whole MySQL thing going - also thanks to this page and its tutorials. I am working on a small catalogue-like web page now (I am saying catalogue-like because you cannot actually order anything from it, you can just view items). Either way, after running a few test pages I realized that I will (given proper variable use and database setup) not need too many actual pages to program this site, since all of the content can be stored in tables. However, this brought me to the question of how people are going to actually find the information? If I have one or two entrence points to the page than I can pass on variables, etc. to create views to the items asked for but what about stuff like search engines (google for example). How will they know that I have that-and-that product in my catalogue since the pure HTML page does not actually exist? I hope somebody can shet some light on this issue for me. Reg. Napper
  13. Thank you very much for your help. I finally managed to install phpMySQL and am adding my tables and entries now. Since I had most of this already prepared on paper this is one heluva breakthrough! Thanks again! Napper
  14. Hi everybody! I am sorry to ask this kind of question, it seems to be so obvious that no tutorial really ever bothers to mention it. Here is my situation: I am working on a website, have good knowledge of HTML and reasonable knowledge of both JS and PHP, so the next stop obviously would be to implement some form of MySQL Database, especially since my customer is planning to build a little online product exhibition. My website providor has set up a MySQL Database on our server and I have username and password handy. Most of my knowledge I have from tutorials but so far I have not been able to grasp one all deciding concept of MySQL: Where do ya enter them code? Every tutorial I have encountered so far just starts with this happy-world \"now let\'s connect to the database. Type in...\" without giving me the faintest hint of where to type it in. I understand that the later query commands will be integrated into a PHP site but what about them data-base building, data-entering kind of things? Where do I punch in: mysql_query(\"CREATE TABLE users ( firstname VARCHAR(20), surname VARCHAR(20), location VARCHAR(20))\"); and similar? I hope somebody can give me a hint here. It just CAN\'T be the DOS promt! It CAN\'T be... Reg. Napper
×
×
  • 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.