Jump to content

jamesjmann

Members
  • Posts

    247
  • Joined

  • Last visited

Everything posted by jamesjmann

  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.
  14. That makes sense. But I'd imagine you could use mysql_free_result() after the method goes through the loop each time? Not sure if that would make a difference, but I suppose it's a possibility... And I have just one more question regarding this...how would I go about getting the breadcrumbs for nested albums? Like say, I'm currently in an album called "Photography" and it has several albums inside, each with their own subalbums and photos. What I want to be able to do is add up the number of photos in each sub album that's nested in "Photography" so I can display it on the page for "Photography". Getting the number of photos in each album isn't the problem. If I can get this method to construct an array with the ids of every nested album, I can use one of my other methods to do the calculations. S'just the problem is GETTING those nested albums' ids. I would imagine you'd have to do the above in reverse, but I haven't the slightest clue how.
  15. Question: I use SELECTED and often times don't give my attributes values. I code in HTML (not XHTML). Can I get away with doing this coding in either?
  16. Nevermind. After looking at my code I realized I forgot to add a space in between "<option" and "SELECTED".
  17. I know this is probably going to sound like a stupid question, but I have a multiple select box with this code: <select MULTIPLE> </select> And a foreach statement that dynamically generates <option>'s. I want one option to be automatically selected when the user clicks the page, depending on a certain $_GET variable in the query string. I tried: <option SELECTED> Like you would a normal <select> and this didn't work. Anyone know if this is even possible? Note: I tried googling it, but google turned up nothing. Someone help. I'm a newb at multiple selects lol.
  18. Thanks so much! I've been scratching my head for the past hour trying to tweak a "Breadcrumb" script I found that actually worked to return an array instead of printing the "crumbs". Nothing I did seemed to work, and didn't help that script in question had a method calling itself within itself when executed wherever. I kind of feel like an idiot for not having realized that this could have been achieved with such little code, but then again I had never worked with dowhile loops before... Not that I'm too concerned about this, but what do you mean it is less efficient? I've tested the code already and it seems to work exactly how I want it to, but now I'm starting to have doubts about it's overall efficiency.
  19. This was my original approach, but the thing I can't figure out is how would you set it up so that the loop or whatever you'd use would stop checking that process once the parent id reaches 0 on it's own? This solution would only be okay if I had wanted a maximum nesting level, which I don't. I'm developing this application as freesource which I will eventually publish on my website and I want users to have the maximum amount of capabilities/options, meaning I want them to be able to make as many nested albums as they wish. But the farther you go into the "nest", the harder it is to navigate to previous albums. I took a look at the link above, but didn't find it very useful. But now I have yet another question because the user above you stated that I'm "coming at this from the wrong angle". Is my DB structure how you'd go about achieving something like this? I'd imagine it's the same as how PHPBB stores their forums. If I'm correct, PHPBB allows for unlimited nested forums. I mean this is just how I thought something like this should be done, but if there's another better way that doesn't involve more than one table, please let me know!
  20. Hmmm, I'm thinking you can keep track of each step completed. Maybe insert a row into a table that keeps track everytime a user starts step 1. if he/she closes out after it, when they log back in next you can display a message like "Finish uploading files" or whatever it is you want them to do. Then take them to a page where they can do step 2. Once step 2 is completed, update same record in database saying it's completed. Same with step 3. Once all steps are completed, either make note of that in record or simply delete it.
  21. Hi, I'm developing a "gallery" script so that I can manage my photos online, and I'm having a problem I can't seem to figure out. Hoping someone can help... So here's my problem. I have two main tables for my application (amongst several others but for all intents and purposes they aren't needed). One is "albums" and the other "photos". Here's the structure for both: Albums CREATE TABLE IF NOT EXISTS `kill4silence_photos_albums` ( `id` int(255) NOT NULL AUTO_INCREMENT, `parent_id` int(255) NOT NULL, `user_id` int(255) NOT NULL, `cover` int(255) NOT NULL, `name` varchar(50) NOT NULL, `description` text NOT NULL, `location` varchar(255) NOT NULL, `time` varchar(50) NOT NULL, `date` varchar(50) NOT NULL, `timestamp` int(255) NOT NULL, `last_updated_date` varchar(50) NOT NULL, `last_updated_time` varchar(50) NOT NULL, `last_updated_timestamp` int(255) NOT NULL, `views` int(255) NOT NULL, `tags` longtext NOT NULL, `downloads` int(255) NOT NULL, `download_disabled` int(1) NOT NULL, `comments_disabled` int(255) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=156 ; ----------------------------------------------------------------------------------------- Photos CREATE TABLE IF NOT EXISTS `kill4silence_photos_photos` ( `id` int(255) NOT NULL AUTO_INCREMENT, `album_id` int(255) NOT NULL, `user_id` int(255) NOT NULL, `name` varchar(50) NOT NULL, `caption` varchar(200) NOT NULL, `time` varchar(50) NOT NULL, `date` varchar(50) NOT NULL, `timestamp` int(255) NOT NULL, `file_name` varchar(5000) NOT NULL, `file_type` varchar(100) NOT NULL, `file_ext` varchar(25) NOT NULL, `location` varchar(200) NOT NULL, `photo_time` varchar(50) NOT NULL, `photo_date` varchar(50) NOT NULL, `views` int(255) NOT NULL, `tags` longtext NOT NULL, `downloads` int(255) NOT NULL, `downloads_disabled` int(1) NOT NULL, `comments_disabled` int(1) NOT NULL, `visible` int(1) NOT NULL, `last_updated_date` varchar(50) NOT NULL, `last_updated_time` varchar(50) NOT NULL, `last_updated_timestamp` int(255) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=204 ; Now basically how this works is when a new album is created, it is given a parent_id of '0' where the parent_id is the identifer of it's "parent" album. Say, I have five albums, each nested within each other like so. 1, 2, 3, 4, 5. On the page, it would look like, Album 1 (link that takes you to Album 2) Album 2 (link that takes you to Album 3) And so on... I use $_GET to send you to the next nested album. Each album's query string looks like this: photos.php?album={$id} No matter what album you're in (be it the "father" parent album or a nested album) Now, what I want to do is construct a method to add to my "photos" class, that creates an array of all parent album id's depending on the current nested album, so I can use that array to display a "navigation" type thingy-ma-jigger at the top of each page. For example: Current album is "Ghosts" Navigation would look like: Paranormal Activity -> Experiences -> Ghosts Where "Ghosts" and "Experiences" are albums nested in "Paranormal Activity" I figure you'd have to go about this using a loop of some kind, but I can't for the life of me figure it out. The only thing I can think of to do that doesn't entirely solve this problem is get the parent id of the current album. So as of right now, if "Ghosts" is currently being displayed, I can output a link taking you to "Experiences", but I can't do so to get "Paranormal Activity". I mean I could, but I'd have to loop through twice to get both ID's. I need a method that will loop through infinitely until there are no more parent albums to be found. Hope this all makes sense. Here's my code for viewing an album, just so you can get a clear picture (I'm using the Smarty extension case the HTML code confuses you) <div id='view_album'> <!--<a href='photos.php?album={$PARENT_ALBUM_ID}'>« Back to {$PARENT_ALBUM_NAME}</a>--> <div class='album_name'> {$ALBUM_NAME} </div> <div class='album_info'> Created by <a href=''>{$USERNAME}</a> (<a href="photos.php?album={$PARENT_ALBUM_ID}">{$PARENT_ALBUM_NAME}</a>) {$DATE_FANCY} • Updated {$LAST_DATE_FANCY} {if strlen($LOCATION) > 0} • Taken at {$LOCATION} {/if} {if $smarty.const.PHOTOS_ADMIN_ACCESS == true} • <a href='photos.php?album={$ALBUM_ID}&action=edit'>Edit Album</a> • <a href='photos.php?album={$ALBUM_ID}&action=delete'>Delete Album</a> • <a href='photos.php?album={$ALBUM_ID}&action=upload&max=1&submit=false'>Upload Photos</a> {/if} </div> <!--Start albums--> {$i= 0} {$max_columns = 5} {$column_width = 100 / {$max_columns}} <table width='100%'> {foreach $ALBUMS_ARRAY as $id => $id} {if $i == 0} <tr> {/if} <td width='20%' align='center'> <div class='album_graphic_container'><a href='photos.php?album={$id}'> {if {albums::info ("id", "=", {$id}, "cover")} == 0} <a href="photos.php?album={$id}"><img src='photos/images/icons/album_default.png'></a> {else} <img src='photos/covers/{$id}/default.jpg' style="width: 100%;"/> {/if} </div> <div class='album_graphic_info'> <a href='photos.php?album={$id}'>{albums::info ("id", "=", {$id}, "name")}</a> <br> {albums::info ("id", "=", {$id}, "num_albums")} Albums • {albums::info ("id", "=", {$id}, "num_photos")} Photos <br> <a href='' style='font-size: 100%;'>{albums::info ("id", "=", {$id}, "num_comments")} Comments</a> </div> </td> {$i = $i + 1} {if $i == $max_columns} </tr> {$i = 0} {/if} {/foreach} {if $i < $max_columns} {$j = 0} {for $k = $i; $k < $max_columns - 1; $k++} {if $j == 0} <td width='{$column_width}%' align='center'> <div class='album_graphic_container'> <a href='photos.php?album={$ALBUM_ID}&action=compose'> <img src='photos/images/icons/album_default.png'> </a> </div> <div class='album_graphic_info'> <a href='photos.php?album={$ALBUM_ID}&action=compose'>+ Add New Album</a> <br> <br> </div> </td> {/if} {$j = 1} <td width='{$column_width}%' align='center'> </td> {/for} {else} {/if} </table> <!--Start photos--> <div class='view_album_lft'> {if {albums::info ("id", "=", {$ALBUM_ID}, "num_photos")} == 0} {else} <!--<div class='view_album_photos_header'>"; Photos In <a href=''>" . albums::info ("id", "=", $_GET["album"], "name") . "</a> (" . albums::info ("id", "=", $_GET["album"], "num_photos") . ")"; </div>";--> {$p = 0} {$p_max_columns = 6} {$p_column_width = 100 / $p_max_columns} <table width='100%'> {foreach $PHOTOS_ARRAY as $id => $id} {if $p == 0} <tr> {/if} <td width='{$p_column_width}%' align='center'> <div class='album_graphic_container'> <a href='photos.php?album={$ALBUM_ID}&photo={$id}'><img src='{photos::info ("id", "=", $id, "src_thumb_medium")}' style='width: 100%;'></a> </div> <div class='album_graphic_info'> {photos::info ("id", "=", {$id}, "views")} Views <br> {photos::info ("id", "=", {$id}, "num_comments")} Comments </div> </td> {$p = $p + 1} {if $p == $p_max_columns} </tr> {$p = 0} {/if} {/foreach} {if $p < $p_max_columns} {for $q = $p; $q < $p_max_columns; $q++} <td width='{$p_column_width}%'> </td> {/for} {/if} </table> {/if} </div> <div class='album_info_2_lft'> {if {likes::determine ("album", {$ALBUM_ID}, $smarty.const.PHOTOS_USER_LOGGED)} == -1} {$NUM_LIKES} Likes • <a href="photos.php?album={$ALBUM_ID}&action=like">Like this album</a> | {$NUM_DISLIKES} Dislikes • <a href="photos.php?album={$ALBUM_ID}&action=dislike">Dislike this album</a> {/if} {if {likes::determine ("album", {$ALBUM_ID}, $smarty.const.PHOTOS_USER_LOGGED)} == 1} {$NUM_LIKES} Likes • <a href="photos.php?album={$ALBUM_ID}&action=unlike">Unlike this album</a> | {$NUM_DISLIKES} Dislikes • <a href="photos.php?album={$ALBUM_ID}&action=dislike">Dislike this album</a> {/if} {if {likes::determine ("album", {$ALBUM_ID}, $smarty.const.PHOTOS_USER_LOGGED)} == 0} {$NUM_LIKES} Likes • <a href="photos.php?album={$ALBUM_ID}&action=like">Like this album</a> | {$NUM_DISLIKES} Dislikes • <a href="photos.php?album={$ALBUM_ID}&action=undislike">Undislike this album</a> {/if} </div> <div class='album_info_2_rt'> {$DOWNLOADS} Downloads • <a href="photos.php?album={$ALBUM_ID}&action=download">Download this album</a> </div> <br clear="all" /> <!--<div class='view_album_rt'> <div class='view_album_rt_header'> Share This Album </div> <div class='view_album_rt_header'> Download This Album </div> <a href=''>Low Quality ({albums::info ("id", "=", {$ALBUM_ID}, "album_size_low")})</a> <br> <a href=''>Medium Quality ({albums::info ("id", "=", {$ALBUM_ID}, "album_size_medium")})</a> <br> <a href=''>High Quality ({albums::info ("id", "=", {$ALBUM_ID}, "album_size_high")})</a> <br> <a href=''>Full Size Quality ({albums::info ("id", "=", {$ALBUM_ID}, "album_size_full")})</a> </div> <br clear='all'>--> <div class='view_album_comments_container'> <div class='view_album_comments_header'> All Comments ({$ALBUM_NUM_COMMENTS}) </div> <div class='view_album_comments_add'> {if !{$PHOTOS_USER_LOGGED}} You must <a href='login.php'>login</a> or <a href='register.php'>sign up</a> in order to post comments {else} {if $COMMENTS_DISABLED == 0} <div class='view_album_comments_single_wrapper'> <div class='view_album_comments_single_lft'> <img src='members/{users::info ($smarty.const.PHOTOS_MEMBERS_FIELD_ID, "=", $smarty.const.PHOTOS_USER_ID, "avatar_src")}'> </div> <div class='view_album_comments_single_rt'> <form action='photos.php?album={$ALBUM_ID}&comment=new&action=add' method='post'> <input type='hidden' name='parent_id' value='0' /> <textarea name='body' placeholder="Write your response" class='view_album_comments_add_textarea'></textarea> <span style="float: right;"><input type="submit" class="fb_button_blue" value="Post Comment" /></span> </form> </div> <br clear='all'> </div> {else} Comments for <a href=''>{$ALBUM_NAME}</a> has been disabled {/if} {/if} </div> {foreach $COMMENTS_ARRAY as $id => $id} <div class='view_album_comments_single_wrapper'> <div class='view_album_comments_single_lft'> <img src='members/{users::info ($smarty.const.PHOTOS_MEMBERS_FIELD_ID, "=", {comments::info ("id", "=", {$id}, "user_id")}, "avatar_src")}'> </div> <div class='view_album_comments_single_rt'> <div class='view_album_comments_single_rt_username'><a href=''>{comments::info ("id", "=", {$id}, "username")}</a></div> <div class='view_album_comments_single_rt_body'>{comments::info ("id", "=", {$id}, "body")}</div> <div class='view_album_comments_single_rt_info'> {comments::info ("id", "=", {$id}, "date_fancy")} • <a href="">Like</a> | <a href="">Dislike</a> {if $smarty.const.PHOTOS_USER_LOGGED == true} {if $smarty.const.PHOTOS_ADMIN_ACCESS || $smarty.const.PHOTOS_USER_ID == {comments::info ("id", "=", {$id}, "user_id")}} • <a href="">Delete</a> {/if} • <a href="">Report</a> {/if} </div> </div> <br clear="all" /> </div> {/foreach} <div id='view_album_comment_report'> <div id='view_album_comment_report_body'> <span class='view_album_comment_report_body_header'>Report Comment</span> </div> </div> </div> </div> Need more info, just ask. Thanks.
  22. Not so random i - $1 - The | forms a regular expression to match any of your search keywords - keyword1|keyword2|keyword3 The i causes the preg_replace to match both upper and lower case so that for example keyword1 will match KeYwOrD1 in the text. The $1 is a variable/reference to the actual value (which ever keyword out of the possible choices) that was actually matched so you can let the preg_ statement do the work instead of you needing to cycle through each choice, one at a time. It works and I understand it now. Spose I shoulda read the manual before sitting down for five hours trying to work with fussy loops lol. Thanks =)
  23. $(document).ready(function() { if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); } else { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { $("#news_feed).html(xmlhttp.responseText); } } xmlhttp.open("GET", "../news_feed.php, true); xmlhttp.send(); }); This will display the news feed automatically when the page gets loaded, and input what's returned in the div container "news_feed". Pretty self-explanatory, but if you want to use this function to load the data on triggered events, give the function a name and write it into your html. BTW, this uses jQuery, so I'd recommend downloading it before trying to use this code. Hope this helps!
×
×
  • 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.