Jump to content

wwfc_barmy_army

Members
  • Posts

    320
  • Joined

  • Last visited

    Never

Everything posted by wwfc_barmy_army

  1. Hello. I am testing out web scraping and I have a page I am testing with and it has a div with a class 'total_price'. I am using the Simple HTML DOM Parser with this code: // Create DOM from URL or file $html = file_get_html('**My Test Page**'); $ret = $html->find('.total_price'); print_r($ret); Although it seems to get stuck in some kind of loop and I get a lot of output text: ..etc...etc... There is one point it returns the value I am trying to get (the price) which is: Anyone see what i'm doing wrong? Thanks.
  2. It produces a multidimenstional array rather than a single array
  3. the record contains either "tag1" or multiple tags "tag1, tag2, tag3". I want it to get all the individual tags and put them into an array. See what i mean?
  4. I'm getting error: implode() [function.implode]: Invalid arguments passed in C:\wamp\www\myfile.php on line 14 just swapped explode for implode. Any ideas? Thanks.
  5. Hey Guys, I've got this code: while($row = mysql_fetch_array($result)) { $tagstringarray[]=$row['mycolumn']; } } foreach ($tagstringarray as $tag) { $pieces[] = explode(",", $tag); } foreach ($pieces as $tag) { echo $tag . "<br/>"; } print_r ($pieces); My database has a number of records which are tags, so are seperated by commas. eg. "tag1, tag2, tag3", but some just contain 1 tag eg "tag1". This seems to put it as (presumably) a multi dimensional array, any ideas how I can return it all to one single dimensional array? Thanks.
  6. Hellol. Does anyone know of software that can take two php files, and distinguish what code is the same in the two files? Like a version check kind of thing? Thanks.
  7. It would depend on how the tablet acts, if it turns the browser around for you (like Iphone) then using percentages as widths will give that kind of effect. I know for iphone you can get a script that tells which way the orientation is, but iphone is the only one I know of that has this kind of script available.
  8. Applying CSS to fields with name tag instead of ID or Class - Is this possible? It's hard to explain why but I can't really change the text field html to include an ID or class, so can you style from using the 'name=' value? Thanks.
  9. I didn't include the whole code and it may change your answer: $file = fopen("myfile","r"); while( ! feof($file)) { $line = fgets($file); if (preg_match("/^Number\b/", $line)) { echo $line; } } fclose($file); If i'm not mistaken it's opening it with read access, so I don't think that would work. Any other ideas? Thanks.
  10. Hello Guys. I have this PHP code to get a line from a file that starts with the word 'Number'. There is only 1 line with this in: while( ! feof($file)) { $line = fgets($file); if (preg_match("/^Number\b/", $line)) { echo $line; } } How would I go about replacing just that line? Any suggestions? Thanks.
  11. Hello, I have this code: $file = fopen("myfile","r"); while(! feof($file)) { if( preg_match( "/^Number\b/", fgets($file) )) { echo fgets($file); } } fclose($file); I want it to print the line that starts with 'Number' but for some reason it is printing the line AFTER the line that starts with 'Number' Anyone got any suggestions? Thanks.
  12. If I've understood what you want correctly then this should help: https://addons.mozilla.org/en-US/firefox/addon/1843
  13. I haven't used it in a long time, but you can translate a page. Try reading the documentation: http://code.google.com/apis/ajaxlanguage/documentation/
  14. Google Translator is your best bet as far as i know. Maybe you should work on the issues that creates with your site first. http://code.google.com/apis/ajaxlanguage/
  15. I'm not sure where I'm going wrong, I followed this tutorial: http://www.strangerstudios.com/sandbox/pagination/diggstyle.php to do a pagination, and I've got the actual data showing fine, but I can't seem to get the pagination buttons to show (1,2,3,4 etc). This is the function i'm using: function getPaginationString($page = 1, $totalitems, $limit = 15, $adjacents = 1) { //defaults $pagestring = "?page="; if(!$adjacents) $adjacents = 1; if(!$limit) $limit = 15; if(!$page) $page = 1; //other vars $prev = $page - 1; //previous page is page - 1 $next = $page + 1; //next page is page + 1 $lastpage = ceil($totalitems / $limit); //lastpage is = total items / items per page, rounded up. $lpm1 = $lastpage - 1; //last page minus 1 /* Now we apply our rules and draw the pagination object. We're actually saving the code to a variable in case we want to draw it more than once. */ $pagination = ""; if($lastpage > 1) { $pagination .= "<div class=\"pagination\""; if($margin || $padding) { $pagination .= " style=\""; if($margin) $pagination .= "margin: $margin;"; if($padding) $pagination .= "padding: $padding;"; $pagination .= "\""; } $pagination .= ">"; //previous button if ($page > 1) $pagination .= "<a href=\"$pagestring$prev\">« prev</a>"; else $pagination .= "<span class=\"disabled\">« prev</span>"; //pages if ($lastpage < 7 + ($adjacents * 2)) //not enough pages to bother breaking it up { for ($counter = 1; $counter <= $lastpage; $counter++) { if ($counter == $page) $pagination .= "<span class=\"current\">$counter</span>"; else $pagination .= "<a href=\"" . $pagestring . $counter . "\">$counter</a>"; } } elseif($lastpage >= 7 + ($adjacents * 2)) //enough pages to hide some { //close to beginning; only hide later pages if($page < 1 + ($adjacents * 3)) { for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++) { if ($counter == $page) $pagination .= "<span class=\"current\">$counter</span>"; else $pagination .= "<a href=\"" . $pagestring . $counter . "\">$counter</a>"; } $pagination .= "<span class=\"elipses\">...</span>"; $pagination .= "<a href=\"" . $pagestring . $lpm1 . "\">$lpm1</a>"; $pagination .= "<a href=\"" . $pagestring . $lastpage . "\">$lastpage</a>"; } //in middle; hide some front and some back elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2)) { $pagination .= "<a href=\"" . $pagestring . "1\">1</a>"; $pagination .= "<a href=\"" . $pagestring . "2\">2</a>"; $pagination .= "<span class=\"elipses\">...</span>"; for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++) { if ($counter == $page) $pagination .= "<span class=\"current\">$counter</span>"; else $pagination .= "<a href=\"" . $pagestring . $counter . "\">$counter</a>"; } $pagination .= "..."; $pagination .= "<a href=\"" . $pagestring . $lpm1 . "\">$lpm1</a>"; $pagination .= "<a href=\"" . $pagestring . $lastpage . "\">$lastpage</a>"; } //close to end; only hide early pages else { $pagination .= "<a href=\"" . $pagestring . "1\">1</a>"; $pagination .= "<a href=\"" . $pagestring . "2\">2</a>"; $pagination .= "<span class=\"elipses\">...</span>"; for ($counter = $lastpage - (1 + ($adjacents * 3)); $counter <= $lastpage; $counter++) { if ($counter == $page) $pagination .= "<span class=\"current\">$counter</span>"; else $pagination .= "<a href=\"" . $pagestring . $counter . "\">$counter</a>"; } } } //next button if ($page < $counter - 1) $pagination .= "<a href=\"" . $pagestring . $next . "\">next »</a>"; else $pagination .= "<span class=\"disabled\">next »</span>"; $pagination .= "</div>\n"; } return $pagination; } and i'm using this to call and echo it: $pag = getPaginationString($page, $total_pages, $limit, $adjacents); echo $pag; I've also tried echo instead of return in the function and just calling the function. But nothing shows. Any ideas? Thanks.
  16. If i use ../images/image.jpg on the subdomain it looks at mysub.mydomain.com/images/image.jpg, isn't it because of how the browser looks at it?
  17. Hello. Not really sure which section this belongs in but; I have a domain and subdomain, lets say, mydomain.com and mysub.mydomain.com. Mydomain.com has a fully working website, images in a folder called images. I want the same layout on my subdomain, I can link the css and the javascript using the file path, eg ../css/mycss.css, but obviously i can't do the same with the images because of the way the browser gets them and it looks in mysub.mydomain.com. Instead of copying over the images folder, or giving it a full domain path in the image link (eg. <img src="http://mydomain.com/images/myimage.jpg">) is there a way of setting the image paths to default to the main domain directory? Htaccess maybe? Thanks.
  18. Hi, Hoping someone can help. First off, i'm still reasonably new to Jquery but i'm picking it up slowly. Basically i'm adding a search function to my site and I have this Jquery code: $(document).ready(function() { //Display Loading Image function Display_Load() { $("#loading").fadeIn(900,0); $("#loading").html("<img src='images/bigLoader.gif' />"); } //Hide Loading Image function Hide_Load() { $("#loading").fadeOut('slow'); }; $("#pagination li:first") .css({'color' : '#FF0084'}).css({'border' : 'none'}); $("#searchsubmit").submit(function(){ var searchquery = document.getElementById("searchbox").value; var searchtype = $('input[name=searchtype]:checked').val(); $("#pagination").load("includes/searchpag.php?search=" + searchquery); Display_Load(); $("#thumbarea").load("includes/searchfunction.php?page=1&type=" + searchtype + "&search=" + searchquery, Hide_Load()); //$("#searchsubmit").fadeOut('slow'); return false; }); //Pagination Click $("#pagination li").click(function(){ Display_Load(); //CSS Styles $("#pagination li") .css({'border' : 'solid #dddddd 1px'}) .css({'color' : '#0063DC'}); $(this) .css({'color' : '#FF0084'}) .css({'border' : 'none'}); //Loading Data var pageNum = this.id; var searchquery = document.getElementById("searchbox").value var searchtype = $('input[name=searchtype]:checked').val(); // if(typeof cat != "undefined") { //if cat DOES exist $("#thumbarea").load("includes/searchfunction.php?page=" + pageNum + "&type=" + searchtype + "&search=" + searchquery, Hide_Load()); return false; }); }); It works fine and this is what shows in firebug: http://yfrog.com/jamogsearchissue1j But if i search for the same or another word with the results still there it seems to submit it a number of times, this is what shows in firebug after click it one more time (top 4 results were the original): http://yfrog.com/0wmogsearchissue2j I've spent hours trying to figure this out but I just can't seem to solve it. Can anyone help? Thanks.
  19. Hello. I have a Jquery image upload script which I found on the internet and i've already made a number of changes to it, although I'm not the best at ajax stuff yet, but I don't know how I can get it to return the random file name created in the php upload script. The image is uploaded with the random file name, but just not returned to the main page yet. Here is my code: In my main page: <script language="javascript" type="text/javascript"> $(document).ready(function(){ $('#status').hide(); }); $(function(){ var ipup = 0; var btnUpload=$('#upload'); var status=$('#status'); new AjaxUpload(btnUpload, { action: 'upload-file.php', //Name of the file input box name: 'uploadfile', onSubmit: function(file, ext){ if (! (ext && /^(jpg|png|jpeg|gif)$/.test(ext))){ // check for valid file extension status.text('Only JPG, PNG or GIF files are allowed'); return false; } status.text('<img src="images/ajax-loader.gif"> Uploading...'); $('#status').show(); }, onComplete: function(file, response){ //On completion clear the status status.text(''); $('#status').hide(); //Add uploaded file to list if(response==="success"){ $('<li></li>').appendTo('#files').html('<img src="./images/upload/'+file+'" alt="" /><br />'+file).addClass('success'); $('<p></p>').appendTo('#files').html('<input name="file' + ipup + '" type="hidden" value="' +file+ '" /><br />'); ipup = ipup + 1; } else{ $('<li></li>').appendTo('#files').text(file).addClass('error'); } } }); }); </script> Upload-file.php <?php $uploaddir = './images/upload/'; // get the file extension first $ext = substr(strrchr(basename($_FILES['uploadfile']['name']), "."), 1); // make the random file name $randName = md5(rand() * time()); // and now we have the unique file name for the upload file $file = $uploaddir . $randName . '.' . $ext; //$result = move_uploaded_file($tmpName, $filePath); //$file = $uploaddir . basename($_FILES['uploadfile']['name']); if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $file)) { echo "success"; } else { echo "error"; } ?> As far as I can see if I echo it the returning value will not be success so will not work, so I'm not sure the best way to go about it. Thanks for any help and advice.
×
×
  • 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.