Jump to content

Giddy Rob

Members
  • Posts

    63
  • Joined

  • Last visited

    Never

Everything posted by Giddy Rob

  1. Thanks guys, yeah, kinda figured that out just after i posted this. Seems to work ok if you use a textarea to show the code. Just styled it so it doesnt look like one. Any problems doing it this way? Cheers
  2. Hi, bit stuck on how to find and replace "<" and ">" with "<" and ">". I basically have a database record that outputs to screen and I need the code in the <code> tags to be rendered to the screen. I therefore need it to go through the whole array variable from the db and change the symbols just inside the code tags. Please be aware that the code tags might happen more than once here's an example below <p>blah blah blah</p> <p>blah blah blah</p> <p>blah blah blah</p> <code> <h1>hello</h1> </code> <p>blah blah blah</p> <p>blah blah blah</p> <p>blah blah blah</p> <code> <h1>hello</h1> </code> the desired output would be: <p>blah blah blah</p> <p>blah blah blah</p> <p>blah blah blah</p> <code> <h1>hello</h1 </code> <p>blah blah blah</p> <p>blah blah blah</p> <p>blah blah blah</p> <code> <h1>hello</h1 </code> help on this would be great Cheers Rob
  3. hmmmmm, helps if i specify the file to be saved first time done this so hey
  4. Hi, I have found a nice little script to write to the xml file for google, but it appears not to be updating the file. Could someone please let me know what might be wrong as this is the first time I've tried to do this. $dom = new DomDocument('1.0', 'utf-8'); $dom->load('../sitemap.xml'); // if it's a string, $dom->load($xmlFile) if is a file // create the new node element $node = $dom->createElement('url'); // build node $node->appendChild($dom->createElement('loc', $title)); $node->appendChild($dom->createElement('lastmode', date(Y-m-d))); $node->appendChild($dom->createElement('changefreq', 'monthly')); $node->appendChild($dom->createElement('priority', '2')); // append the child node to the root $dom->documentElement->appendChild($node); // get the document as an XML string $xmlStr = $dom->save(); I was wondering if it was something to do with the [urlset] tag within the xml file I'm using? The xml file is just a standard google sitemap.xml Any help on this would be great Cheers Rob
  5. Hi, I want to separate out the file name from an image url. Not sure the best way to do it? I want to basically select all text after the last / slash. eg - image.jpg would be the result from http://www.google.com/images/image.jpg What's the best way to do it? Cheers Rob
  6. Hey, I need to change the url so that "www.website.com/item.php?id=1504" will read something more user friendly and better seo. I've heard you do it with a mod_rewrite, but have never done this before so was wondering if someone could show me how? it would be nice if I could output "www.website.com/newstitle_1504.html" where newstitle is the title of the news item being displayed ie this will be different for each article Example would be great Cheers
  7. Hey, can someone please tell me why the code below will not add a value to a hidden field, but it will output to screen: <SCRIPT LANGUAGE="Javascript"> <!-- // Array of day names var dayNames = new Array("Sunday","Monday","Tuesday","Wednesday", "Thursday","Friday","Saturday"); // Array of month Names var monthNames = new Array( "January","February","March","April","May","June","July", "August","September","October","November","December"); var now = new Date(); var super = (dayNames[now.getDay()] + ", " + monthNames[now.getMonth()] + " " + now.getDate() + ", " + now.getFullYear()); // --> </script> <body><script>document.write(dayNames[now.getDay()] + ", " + monthNames[now.getMonth()] + " " + now.getDate() + ", " + now.getFullYear()); document.getElementByID("newsdates").value = (super);</script> <input type="hidden" name="newsdates" id="newsdates" value="" /> </body> </html> When I load the page it should add the date to the value by id, but I cant get it to work. Thanks in advance Cheers Rob
  8. Hey, I am dealing with a table that has about 500 records. My problem is that I need to create an index and auto fill it from 1-500 (not manually). Once this is done I would like the table to autoincrement when a new record is added. I have set up a field called 'item_number', which is the index field. What php/mysql code do i need to run to fill the table from 1 (first record) to 500 (last record)? I'm hoping I can convert it to an index and autoincrement in phpmyadmin once this is done. At the moment if I try this I just get an error, duplicate field. I did ask in the mysql forum but seems a bit of a ghost town Cheers Rob
  9. BTW, the table is full of information so I dont just want to create a new table
  10. Hey, I am dealing with a table that has about 500 records. My problem is that I need to create an index and auto fill it from 1-500 (not manually). Once this is done I would like the table to autoincrement when a new record is added. I have set up a field called 'item_number', which is the index field. What php/mysql code do i need to run to fill the table from 1 (first record) to 500 (last record)? I'm hoping I can convert it to an index and autoincrement in phpmyadmin once this is done. At the moment if I try this I just get an error, duplicate field. Cheers Rob
  11. Hi, I am a little stuck as I need to resize an image then get the width and height for a record in my database. What I am basically trying to do is have a set of three constraints for the size or a custom size the user can set. For example if one option says"400 height || 400 width" then the width or the height will be set to a maximum of 400px, depending on the which is the largest (keeping aspect ratio). The custom just allows them to set the width and height themselves. It was previously done with this command below, but the system has now moved servers so it doesn't work anymore as I don't think I have permission to use the system call. if ($_POST['picsize'] == 'S') {$_POST['maxwidth']=100;$_POST['maxheight']=100;} if ($_POST['picsize'] == 'M') {$_POST['maxwidth']=250;$_POST['maxheight']=250;} if ($_POST['picsize'] == 'L') {$_POST['maxwidth']=400;$_POST['maxheight']=400;} if ($_POST['maxwidth'] > 0 && $_POST['maxheight'] > 0) { system("/usr/local/bin/convert -quality 80 -thumbnail {$_POST['maxwidth']}x{$_POST['maxheight']}\\> \"{$_FILES['ins_image']['tmp_name']}\" \"../news_images/{$_FILES['ins_image']['name']}\""); } I would like to do this with imagemagick if possible. Any help would be great Cheers in advance Rob Shillito
  12. thats what I thought. I am just looking at phpbb and it looks like just the ticket Cheers for the advice.
  13. Hi, I have never created or integrated a forum into a website before so I was wondering what would be the most simple way of doing it? Is it easier to plug in a forum thats already been created (if so which one is simple and cheap?) or to just code one up myself? If I do a simple one myself how long should it take about? Rough gestimate would be great. Cheers in advance Rob
  14. Hi, thanks for the response but for some reason the money function messed up the shopping cart, which seems very strange when all it appears to do is reformat the array value for outputting to the screen. I have used the number_format() function and this seems to work perfectly. Any clues why this might cause a problem? Cheers Rob
  15. Hi, I have created a shopping cart, which adds and subtracts the value of an item the more or less the customer has in their cart. The problem is is that I would like it to show two digits after the decimal point, but it just chops of the .*0 or .00. If the result is 19.95 that is fine but if its 19.00 it outputs just 19. If the result is 19.90 it just outputs 19.9. What do I need to do to create the extra 0/0's if necessary? Cheers Rob
  16. Hi, I have an array of items and I need to reset the index values when one has been deleted. For example - if I have a sequence of 0 => a 1 => b 2 => c 3 => d 4 => e and 2 is deleted from the array it shifts all the records up so that I am left with: 0 => a 1 => b 2 => d 3 => e I need this as I am outputting using a for loop which counts the items from 0 up to how many are in the array. Anyone got a clue? Cheers in advance guys. Rob
  17. item[0] > [0]=34, [1]=curtains, [2]=£2.99 item[1] > [0]=58, [1]=tent, [2]=£8.99 item[2] > [0]=69, [1]=ruler, [2]=£1.99
  18. Hey, I have done a function to find a value in a multidemensional array but was wondering how I find out what the main index for the record containing the value? i.e. array item[0] > [0]=34, [1]=curtains, [2]=£2.99 item[1] > [0]=58, [1]=tent, [2]=£8.99 item[2] > [0]=69, [1]=ruler, [2]=£1.99 I can find the value say 58 by using this code to pass the session array and the id number which is stored somewhere in the array: function findrecord($session, $id){ foreach($session as $key => $file){ if($file[0] == $id){ return $file[0]; } } } the problem is I need to be able to tell that it is coming from item[1] for my system to work as I want to update it and need to know which one 58 is in the array. Hope that makes sense. Cheers Rob
  19. Hi, i am creating a shopping cart and am wondering how I can update a value in the array? The reason I want to do this is for the quantity of items the customer would like to buy. As you can see from the code: $disp="SELECT id, name, description, priceforpaypal, colour FROM portfolio WHERE id='{$_POST['id']}'"; $display=mysql_query($disp); $displays=mysql_fetch_array($display); if(empty($_SESSION['items'])){ $_SESSION['items']=array(array($displays[0],$displays[1],$displays[2],$displays[3],$displays[4],"1")); }//end if The item is added to the session array with the quantity of 1 being added at the end. I have managed to do a search so that it knows if there is a item already in the array with the same id I just don't know what to do to update that record so that the quantity can be changed i.e. +1 Cheers in advance guys Rob
  20. just one last thing. How do I loop around the array so I can display each entry? Cheers
  21. cheers, figured it out from your code $_SESSION['items'][] = array($displays[0],$displays[1],$displays[2],$displays[3],$displays[4]); slaps a new item in the array Rock and roll! Thanks for the prod in the right direction
  22. thanks for the help but I need to have for example: $_SESSION['items']=array(array(1,2,3,4,5)); $_SESSION['items']=array(array(6,7,8,9,10)); So that if I do: echo $_SESSION['items'][0][0]; The output will be 1, and if I do: echo $_SESSION['items'][1][0]; The output will be 6 i know this doesnt work but I am not sure how to do it. Hope that makes a bit more sense
  23. right, i have changed my code to: $_SESSION['items']=array(array($displays[0],$displays[1],$displays[2],$displays[3],$displays[4])); echo $_SESSION['animals'][0][1]; I just need to know how to add another item into that array when the user decides to add a new item. Cheers
×
×
  • 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.