Jump to content

WebStyles

Members
  • Posts

    1,216
  • Joined

  • Last visited

Everything posted by WebStyles

  1. $arr_to_string = 'Item, quantity ' . implode(' , ',$arr); implode basically takes all values of an array and glues them together with thatever text/simbols you want. in this case, they're being joined by [space][comma][space] defined in single quotes, thus: ' , '
  2. this: $quantity = (!empty($_POST['quantity'][$key])) ? intval($_POST['quantity'][$key]) : 0; is shorthand for this: if( !empty($_POST['quantity'][$key]) ){ $quantity = intval($_POST['quantity'][$key]); }else{ $quantity = 0; }
  3. file_put_contents(); // sorry, another typo. I'm kind of dyslexic today.
  4. yeah, that's why i was trying to find another criteria. adding that database id is fine, but then you have to map 85,000 products.
  5. sorry, I meant file_get_contents();
  6. $file = get_file_contents('filepath/filename.txt'); $lines = explode("\n",$file); // now you have an array with all the lines in it. You can loop through it and do whatever you want. foreach($lines as $line){ ... } // erase file: get_put_contents('filepath/filename.txt','');
  7. hmmm, 15 forms for 85,000 products. How is this form distinction decided? by category? by type? by country? something else? (there's gotta be something). Imagine there is a category (or 15 in this case) it would be as easy as having the form files with the same name as the respective category. Really depends on what other data you have in each product.
  8. could it not be that you have a margin or padding on the footer css? (just a suggestion, 'cause I can't see the css files) . Just as a note, I noticed you use: include 'news/index.php'; // single quotes, no parentheses and then include("footer.php"); // parentheses and double quotes. not that it's harmful in any way, but why the 2 different styles of programming?
  9. If I'm not missing anything, that seems like it should work fine, unless the function the_permalink(); is also generating html code instead of just echoing a link. I would have a look at that function. remove everything else and just echo that function to see what it outputs.
  10. It kind of depends on how large your database is, how much stuff you'll be doing, how long the database connection will be open, and how many simultaneous connections vs how much traffic you have.
  11. I'm assuming you got that error on an INSERT or UPDATE command. Check your field names and compare with database, check the values you're inserting, and check for misplaced commas etc.
  12. Sure, but all this depends on how many times you'll be using these functions, how your database is set up, if you'll be calling these functions separately from other places, how many records your database has, etc... Only you know exactly how your project is set up, so you're the best person to decide how to implement it.
  13. if you use time() all you need to do is substract endTime - startTime and you'll get the result in total seconds.
  14. there's really no advantage in doing this with txt files, I would use a simple database with a uniqueID and a text field, but, if you insist: you can use a seperate file just to store the last id used, so it's easier to grab and increment: $lastID = file_get_contents('lastSearchID.txt'); $lastID++; file_put_contents('lastSearchID.txt',$lastID); or you can read the last line of your main .txt file, grab the id, increment it and then use it for next search. If you have many simultaneous connections, anticipate file_lock problems when two people are trying to write to it at the exact same time, etc. A Database is much better and faster for this. If you just write a small function to store the search string, the ID will be automatic function storeSearchString($string){ $conn = conn(); mysql_query("insert into `searchTracking` (`searchString`) values ('$string')",$conn); @mysql_close($conn); } hope this helps
  15. can't really go through all of your code right now, but the first error should give you a hint. "No such file in directory" If the function cannot find the image, it's probably not being uploaded correctly or has a different path or name. After uploading, check the upload folder to see if it's there. Then check that the filename and path match the ones you wanted. If not, there's a problem either uploading, or moving the uploaded file. Hope this helps
  16. of course, you could consider using awstats or even google analytics to get that information. Your main problem will not be storing the start time. you can use the unix timestamp for that time(); to store the exact time a user logged in. The hard(er) part if figuring out when the user left, if they just close the browser, or navigate away instead of hitting the logout button, you have to do constant checks at given intervals to check if they're still online or not. So there will always be a margin of error, the same size as your interval for checking.
  17. yes, that is an option. Consider organizing each query into a separate function, for re-using. here's a simple example just to illustrate the concept: create a file called functions.php, and put all the functions in there. then add require_once('functions.php'); to all pages. function getNames($id){ ... return $result; } // then this function can be called from any page with: $allnames = getNames($_POST['id']); after that, if your result is an array, you can just use a foreach() loop to skim through all the results and display them.
  18. still, I don't get what the problem is. If you know how to get data from one table, you also know how to get it from another.
  19. so, what is not working? If you're posting here, I'm assuming you still have a problem to fix. what is it?
  20. ok, so what is not working now? (I would remove 'width="219" height="190"' from the <img> tag. if you have different size images in database, that can distort them.)
  21. there's nothing to it. Store stuff in session, retrieve stuff from session. keep session_start(); at the beginning of each file and you should be ok.
  22. you could also build little translation arrays. Meaning: all the possible words for each placeholder (depends really on how many there are, if they're only a few, this could work fine). Like: $similar1 = array("event","competition","match","game"); then, when you grab a placeholder name, you search through the arrays looking for it. If you use position [0] as your default name, then you can easily translate them. If there are a lot, you can build a simple database with `defaultWord`,`similarWord` and just search through that. again, not the best way to solve your problem, but it should work.
  23. let me see if I get it... you want to execute html code from a single jpeg file? As in, use php to create a jpeg file, that you can then send as a little standalone application that will execute it's very own html upon arrival to it's destination?
  24. for pictures, you can store the filename in the database and use that to create a link to the file. Imagine you have a database field called `mainPhoto` and the value is 123.jpg. when you pull out the data from the table, also grab `mainPhoto`. then you would display it by simply building a link to the file: <img src="imagesFolder/<?=$mainPhotoFileNameVariable;?>">
  25. if the differences are just the 2 you described (uppercase/lowecase and the fact that one says 'v' and the other says 'vs'), then just for the sake of comparison you could convert them all to lowercase and do a replace of all 'vs' str_replace(" vs "," v",$file_contents); Of course, this is just a silly fix, and also depends on how you're importing the data (string or array). a unique id per event, as you said, would be much better and easier to identify.
×
×
  • 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.