Jump to content

ToonMariner

Members
  • Posts

    3,342
  • Joined

  • Last visited

Everything posted by ToonMariner

  1. Always validate your html if there is a problem with forms (always validate it anyway!)
  2. Hi people, Bear with me on this is as its a little complicated to explain. I have a parent div wich contains a variable number of child divs. Each child div has a series of form elements. All this depicted here: [code] <div id="cont"> <div class="elecont" id="cX">   <input type="file" name="file[X]" id="file[X]"/>   <input type="text" name="title[X]" id="title[X] />   <input type="text" name="alt[X]" id="alt[X]" /. <div> ... </div> [/code] there can be any number of the child divs with id="cX" in the parent div and X is a numeric variable. Now you may have guessed that this is a gallery script or similar. What I have is a link to add and remove these child divs which works fine apart from that when any inputs are given info - particularly the file input box - this value is lost when any other child divs are added/removed. What I need to do is loop through the elements of the form. If the id of that element contains '[X]' then I need to take the name/value pair and store it into an array. The array should be 2-d with X being the first key and the other part of the element id being the second key. i.e. if i had the follwoing 2 child divs: [code] <div id="cont"> <div class="elecont" id="c2">   <input type="file" name="file[2]" id="file[2]"/>   <input type="text" name="title[2]" id="title[2] />   <input type="text" name="alt[2]" id="alt[2]" /. <div> <div class="elecont" id="cX">   <input type="file" name="file[5]" id="file[5]"/>   <input type="text" name="title[5]" id="title[5] />   <input type="text" name="alt[5]" id="alt[5]" /. <div> </div> [/code] I would need to construct an array that would be: Array ( 2=> Array (file=> val, title=> val, alt=> val),           5=> Array (file=> val, title=> val, alt=> val)) I use 2 & 5 to illustrate that the numbers need not be sequential. Once I have this array and have added/removed one the child divs I need to loop through the array and set the corresponding values of those elements. I know I need to use regex to get the correct element name[X] split in to name and X but not sure how to do that nor how to use those in creating the keys for teh array. If all that made sense and if you can find them maybe you can hire the A-Team.... Sorry, chain of thought went ;) Any help would be really appreciated.... This is the code I am currently trying yo use.... [code] function grabValues() { var myArr=[]; var el = document.forms['galform'].elements; var regex = new RegExp(/(\D)\[(\d)\]/); for(var i=0;i<el.length;i++) {   if (el[i].name && el[i].name.match(regex))   {   switch (el[i].type)   {     case 'text':     case 'file':     myArr[regex[2]][regex[1]] = el[i].value;     break;     case 'textarea':     myArr[$2][$1] = el[i].innerHTML;     break;     default:   }   document.getElementById('test').innerHTML += el[i].name+" type = "+el[i].type+"\r\n";   }   //el[i].name.match(/\[.\]/g) ? myArr[myArr.length]=[el[i].name,el[i].value] : null; } //return myArr; //document.getElementById('test').innerHTML = myArr; } [/code]
  3. $tipo= $_GET['clas']; $sql = "select id,clase,tema,ritmo,autor,arreglo,fecha,kar,nuevo,archivo from temas where CLASE like '" . $tipo . "' HERE order by " . $sort; you may want to use '%" . $tipo . "%' I still concatenate vars in a double quoted string so that I can see them a little easier in my chosen editor you don't have to for it to work but its just a habit (i think a good one) of mine
  4. if you are using a form that people fill in and are passing that information between pages then the method of the form dictates which method you use to retrieve that data.. <form action"script.php" method="get"..... will send info via the url - which will look like http://www.here.com/script.php?foo=a&bar=b <form action"script.php" method="post"..... will leave a clean ulr (no ?foo=a...) in the script that is recieving these varaibles you can either use $_GET['foo'] to get foo from the url or $_POST['foo'] from the headers... finally if you have the info you can simply put it in the a tag <a href="script.php?foo=a"> then get it using $_GET['foo']
  5. After scrapping with hacks just as dbrimlow has. I know design sites so that I don't use them anymore - haven't used hacks/workrounds for months now. You can - if you take your time and plan well - negate the need to use anything other than css and get your sites lokking pretty damn similar in all the popular browsers.  Admittedly you may missout on a few bits here and there BUT it makes your site look so much more professional and clean.
  6. $key_words = explode(' ',$_GET['keywords']); thats assuming you use the get method and the tet field in your form is called 'keywrods'
  7. try doing this on the basis of the parent element. If all your menu links are in a div like so.. <div id="menu"><a href"....... then you can use this in your style sheet #menu a, #menu a:visited, #menu a:link { font:12px Verdana, Helvetica, sans-serif; color: #166503; width:150; margin-left: 6px; text-decoration: none; filter:Glow(color=#4FFF25, strength=5); } #menu a:hover { font:12px Verdana, Helvetica, sans-serif; color: #FF0000; width:150; margin-left: 6px; text-decoration: none; filter:Glow(color=#FC8322, strength=5); } these styles will only ever apply to a tags that are a decendant of any element with an id of menu. Similarly you can do the same for other sections of you site.... You just need to isolate elements that contain the links you wish to alter and use that elements id (or class) to manipulate them.
  8. [code]<?php error_reporting(E_ALL); include('db.php'); $query = mysql_query("SELECT * FROM `vids` ORDER BY `setname`"); $cat = null; while($row=mysql_fetch_array($query)) { $title = $row['title']; $descr = $row['descr']; $img = $row['img']; $views = $row['views']; $setname = $row['setnamelong']; if (is_null($cat) || strcomp($cat,$setname) !=0) { $cat = $setname; echo <<<HTML <h1>$setname</h1><br /> <img src="$img" width="100" height="100" /><br /> <h1>$title</h1><br /> $descr </td>   </tr> </table><br /><br /> HTML; } else { echo <<<HTML <img src="$img" width="100" height="100" /><br /> <h1>$title</h1><br /> $descr </td>   </tr> </table><br /><br /> HTML; } } ?> [/code] BUT i fear you will get some very poorly formed html in there.....
  9. $tag = '<a href="www.url.com/index.html">'; $url = ereg_replace('/<a href="(?!")">/','\1',$tag);
  10. If you have it read the date - time chapter in 'PHP and MySQL Web Devlopment' In there it points out a few pitfalls in using php to do date/time calculations. I still maintain it is better to let mysql do those for you. Far superior functionality like accounting for leap years and using the gregorian calendar - which IMO is better when dealing with dates outside the unix timestamp range.
  11. TOP TIP - don't use timestamp for peoples birthdays! What if some born in 1969 (are they still alive!!!) wanted to use it???? You are better off using the built-in time/date datatypes of which ever database you are using - they are better than those offered in php. Calculation between dates is also better in the database domain - according to some tets I read of course!!!!!
  12. The only think I can see that might be an issue is this line....   $upfile = "$g_rooturl/images/banners/".$mod_file; you see in the error message you get '//images'... the '//' may be the issue. change the line above to   $upfile = $g_rooturl . "images/banners/" . $mod_file; see if that helps.
  13. all this is done for you by your hosts. They will have sent you ftp account details, probably a control panel account too. Go and look in there and it shoudl give you some idea of where you are.  Otherwise you will need some live help (at least that will be the quickest way!)
  14. echo your query to the screen and comment out the execution of the query - then check it in phpmyadmin - it may point out something more. This will probably be a case of some single or double quote issue...
  15. LOL Sorry I have ben around for too long!!! I learnt that many moons ago - and its stuck. But hey you learn new stuff.
  16. from the manual Note: Prior to PHP 4.0.2, the following applies: require() will always attempt to read the target file, even if the line it's on never executes. The conditional statement won't affect require(). However, if the line on which the require() occurs is not executed, neither will any of the code in the target file be executed. Similarly, looping structures do not affect the behaviour of require(). Although the code contained in the target file is still subject to the loop, the require() itself happens only once. apology accepted ;)
  17. include will include your file whenever the flow of code calls it. require will include your file regardless... eg. if ($string == 'yep') { include('file.php); } will only include your file if $string is 'yep'. if ($string == 'yep') { require('file.php); } will include it no matter what $string is.
  18. include('connect.php'); I assume this contains all teh login stuff for the database - put the mysql_connect and mysql_select_db in that file too - then you don't need to put it in every page! seems an awfully convoluted method of doing things IMO
  19. if this is on a live serer that is hosting your site you will already have apache (or god-forbid IIS). to find out upload a filewith JUST this in it into your root directory. <?php phpinfo(); ?> call it info.php and then simply goto your site and ad info.php to the url. This will give you all the info about your installation, which server app you have (hopefully apache) whether mysql is available etc etc. delete the file when you have done - you don't need to let everyone see your servers details!!!
  20. where id = what????? that is your problem!
  21. You could only allow posts where $_SERVER['REMOTE_ADDR'] is available - that way you could back trace. Even if they spoof an ip address you will get another measure of how they are circumventing your system - and then prevent that.
  22. add overflow: auto; to the decalaration.. If this is going to be used more than once you should change from an id to a class like so [code]<div class="content_top"></div>[/code] and the css [code] .content_top { width:580px; height:10px; background-image:url(images/content_top.gif); background-repeat:no-repeat; overflow:auto; } [/code]
  23. First off - if you are designing a fixed width site design to less than 800px (I use 765px); There are STILL millions using 800 x 600 screens resolution.... The reason that the borders do not touch is that you have used padding on the main body div that contains all these 'sub divs' #main-body {   text-align: left;   margin: 0 0 0 150px;   padding: 0;   border: 1px solid #09507e;   border-right: 0; } #main-body div {   text-align: left;   margin 0;   padding 10px;   border: 1px solid #09507e; } try that
  24. dont use spans or id's id's are for those elements that are unique use this... [code]<?php ini_set('arg_separator.output', '&amp;'); ?> <ul> <li><a href="/gateway.php?url=pets" title="Pets">Pets</a></li> <li><a href="/gateway.php?url=jewelry" title="Jewelry">Jewelry</a></li> <li><a href="/gateway.php?url=electronics" title="Electronics">Electronics</a></li> <li><a href="/gateway.php?url=personalitems" title="Personal Items">Personal Items</a></li> <li><a href="/stolengateway.php" title="Stolen Items">Stolen Items</a></li> <li><a href="/gateway.php?url=miscitems" title="Misc Items">Misc Items</a></li> <li><a class="orange" href="/postfound/found1.php" title="Post Found Items">Post Found Items</a></li> <li><a class="green" href="/postlost/lost1.php" title="Post Lost Items">Post Lost Items</a></li> <li><a href="/advancedsearch.php" title="Advanced Search">Advanced Search</a></li> <?php if ($_SESSION['controller'] == true) { ?> <li><a href="../forum/index.php" title="Forum">The Forum</a></li> <?php } ?> </ul> [/code] and the css.. [code] a:link.orange { color:#CC6633; text-decoration:none; background-color:#FFFFFF; font-weight:bold; } a:hover.orange { text-decoration:underline; } [/code]
×
×
  • 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.