Jump to content

jamesjmann

Members
  • Posts

    247
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

jamesjmann's Achievements

Regular Member

Regular Member (3/5)

0

Reputation

  1. Looking for developers interested in being apart of a new project. The project in question is located at www.usingthecode.com. It's kind of like StackOverflow, but I intend to make it more social and intuitive. So far, it's just me! Unfortunately, no "positions" offer pay so this is strictly a time/learning investment. Having said, if you are serious about being part of the project, the first contenders will have a larger stake in whatever the project evolves into. Languages utilized: 1. PHP 2. SQL 3. HTML/CSS 4. JavaScript/jQuery Pay: None Location: Anywhere; work will all be over the internet If you are not a programmer/designer, but are interested in contributing in other ways, just let me know! If you are, knowledge in the above languages are a must. Cheers!
  2. Is there a way to get the count of rows like this? $count = somefunctionthatreturnscount(mysqli_query($mysqli, "SELECT COUNT(*) FROM table")); Instead of... $count = mysqli_num_rows(mysqli_query($mysqli, "SELECT id FROM table")); //or even... $count = mysqli_fetch_array(mysqli_query($mysqli, "SELECT COUNT(*) as count FROM table")); Ultimately, I want the method that will get the count the quickest and if can be done similarly to the first code and still have good performance. Thanks in advance! Update: Reported post as duplicate. Need moderate to delete duplicates as that option is not appearing for me.
  3. Hi, I'm creating a php/mysql/jquery based email application which allows users on my site send and receive private messages, and I was wondering if someone could give me advice on which way I should go about storing different types of messages, e.g., spam, draft messages, and messages in the "trash" folder. Right now, I'm leaning on using only one table for all messages no matter what folder they're in. Example 1 Table 1 Messages Fields id user_1 user_2 message draft spam trash date Example 2 Table 1 Messages Fields id folder_id user_1 user_2 message date Table 2 Folders Fields id name date Example 3 Table 1 Messages Fields id user_1 user_2 message date Table 2 Trash Fields id user_1 user_2 message date exp Table 3 Drafts Fields id user_1 user_2 message date Table 4 Spam Fields id user_1 user_2 message date So with the first example, if a user moves a message to the "trash" folder, there would be a query run to update the row storing the message and would place a "1" in the trash field. If the user, then, decided to move it to the "spam" folder, the row would be updated to make the "spam" field contain a value of "1" and would make the "trash" and "draft" fields "0". With the second, there would be one table storing messages and a second storing all of the possible folders a user could move them to. For instance, if the user decided to move a message to the "trash" folder, the row containing the message would be updated to have the "folder_id" field contain the value of the id of the folder in the "Folders" table. The third is just really messy and redundant in my opinion, but I figured I'd include it, because it is ultimately one way that can allow for flexibility and seems versatile enough. I figure that the 3rd example is probably the worst way to go about this, because it uses up more resources, i.e., it takes up unnecessary space with all of the extra tables. I like the first the best, because only one table is used, and so only one table would need to be updated anytime a user opts to move a message to another folder. Anyone have an idea as to what I should do? Any and all advice is appreciated
  4. I was also thinking maybe I could just add an extra field to the albums table andwhere the field would hold a value of either 0 or 1, where 1 would signify that it has nested albums inside. In which case then itd be easier to loop through but assuming we dont want a loop that probably wouldnt be best. And in regards to mysql_close, i read on php.net that your supposed to run it at the end of your script not each query. Im thinking that everytime you run it your creating more work for the server so the less its the better.
  5. If you don't mind me asking, can you explain what the above does? I'm not too familiar with LEFT JOINS and the code is confusing the hell out of me lol.From what I've gathered, you constructed a tree-like array of all the albums. And um, yeah thats pretty much all I gathered lol.
  6. Oh wow. I saw that it said boolean was returned and not a resource. Should've realized haha. Thanks for the tip!
  7. So I just started using mysql_free_result on all my methods in a certain little class I've been working on and for some reason I keep getting an error when I use it on an UPDATE query. Here's the method in it's entirety: public static function update_views($photo_id, $views, $redirect = NULL) { $views = $views + 1; $query = "UPDATE " . PHOTOS_TABLE_PHOTOS . " SET views = '" . $views . "' WHERE id = '" . $photo_id . "'"; $result = mysql_query($query); mysql_free_result ($result); $redirect = isset ($redirect) ? header ("Location: " . $redirect) : NULL; } Am I doing something wrong here? I call the function after the query has been executed, but I'm getting this stupid error: Warning: mysql_free_result() expects parameter 1 to be resource, boolean given in C:\Program Files\wamp\www\index.php on line 1307 Where line 1307 is where this method is being called. I'm confused?
  8. Ok, yeah I was thinking it would terminate the query and as I have so many that would be a catastrophe lol. But I'm confused...are you tweaking the original code you gave me or trying to come up with a way to solve the "reverse order breadcrumb trail"? I could care less for a tweaked version of the latter, although I appreciate your efforts on the matter. I'm sure an improved version with no loop would be ideal, but it's crucial I come up with a method that can get all ids of nested albums (rather than the parent albums). It's like, almost completely integral in making my application complete. Like without it, I'd probably have to kill myself in defeat lol.
  9. Okay, but do you think there's a way to do the "reverse" Breadcrumb trail? You said it's impossible with my table structure, but I KNOW there's something I can do about it. Just got to dig deep down into the depths of my brain. Which I'm having a slight difficulty in doing at the moment lol *scratches head* Random question...I've heard of mysql_close and understand it's uses for implementation, but I always wondered, is it global (for want of a better word)? By global I mean if I have two methods, A and B, both with mysql queries, will running it in A stop any queries/connections that may transpire in B? I'm looking at it as though Javascript wherein code is, essentially, executed in literal order. I'm guessing it would only close the connections in A, but, like return, it may only cause crazy things to happen in the function and only in that function.
  10. good info, but for the fact the the OP alreadt stated they wrote the code themselves following video tutorials... Oh, lol. I thought he found a script somewhere and just "plugged" it into his site, which, if that were the case, I'd have strongly advised against it. But that's just my take from my own experience with this wonderful language.
  11. I'm going to tell you what I wish someone had told me when I first started out in PHP...DO NOT COPY/PASTE. Seriously, when I first started out I resorted to copying/pasting others' scripts hoping that they would just magically work once on my already existing website. But I learned that doing this only makes everything that much more complicated. If I were you, I would take a look at php.net and get familiar with basic functions and syntax. Then go through the tutorials on it for tips. PHP is a language based on logic. It is how some of the best applications today are made. If you don't have it or intend to hone it then you might as well give it up and take up American Idol as an alternative past time lol. But assuming you take my advice and start from the ground up (which is always best with any application), I say you start by creating a basic html form and save it in a file called "blahblahblah" with the ".php" extension. Once you've got that down, simply set up a "process" function that checks the inputs the user entered. But in order to be able to do any of this, you'd first need a table that holds all your members and, of course, a registration script. Here's one I found really useful: http://www.tutorialcode.com/php/registration-script/ Any questions, feel free to ask. I don't mind throwing in a helping hand when I can =)
  12. Is there a solution to the "multiple query" thing? I ask this because I have at least 50 methods defined in about 5-6 classes and almost all of them execute a query of some kind. Perhaps running mysql_close at the very end of the script would solve this? Or is it inevitable, because so many queries are being executed anyway? And I'm thinking it can't be impossible to get to the very end of each branch. There's GOT to be a solution.
  13. Well, I was able to do that, but I also want to get the number of photos in each nested albums nested albums. For example, say I'm on "Photography". This the navigation tree for that album: Photography -> A (4 photos), B (3 photos) -> C (20 photos), D (8 photos) -> E (39 photos) -> F (60 photos), G (29 photos) -> H (1 photo) -> I, J (0 photos), K Where the labels after the "->" signify a nested album. ----or----- **********************************Photography********************************** ***********A**********B**********D**********G**********J**********K*********** ******** ****** | ****** | ******* | ****** ****** *********** C E H | | F i As of right now I am able to get all of the photos in A, B, D, G, J, and K, by running a query like this: $result_9 = mysql_query("SELECT id FROM " . PHOTOS_TABLE_ALBUMS . " WHERE parent_id = '" . $row["id"] . "'"); $info = self::info ("id", "=", $row["id"], "num_photos"); while ($row_9 = mysql_fetch_array($result_9)) { $info = $info + self::info ("id", "=", $row_9["id"], "num_photos"); } $info = $info; Which is inside of the class/method: albums/info. What it does is gets the number of photos in the current album and adds it to the number of photos in each nested album. What I can't figure out is how to get the number of photos inside of "C", "E", "H", "F", and "I". I mean, I could get the numbers for those albums, but, again, I need a query that will "loop" through until there are no more nested albums in each nested album to check. Hope this all makes sense, but case in point, in regards to the hypothetical example above, I want to get all 164 photos from all of the albums in "Photography" and display "164" on the page for "Photography", rather than just get 44 photos from the first set of nested albums.
×
×
  • 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.