Jump to content

adambedford

Members
  • Posts

    86
  • Joined

  • Last visited

    Never

Everything posted by adambedford

  1. I'm writing a mini social network and I'm having trouble figuring out how to deal with privacy settings. I have established a range of privacy options (level 1-4): 1. Only Facebook friends can see profile (users connect via FB) 2. Only current classmates 3. Past + current classmates 4. All users in given group I am writing a function to return a list of available users based on a given parameter (eg. Find all classmates of a user). Obviously I have to respect users privacy settings, so I thought to query against all users with level 2 permissions, however I realise that I may miss out some classmates who are FB friends but have permission levels set to 1. Secondly, I'm looking to find out the relationship between two users (a function that I can plug in 2 user IDs and return their relationship...classmates, FB friends, past classmates, no relationship) which I can then use to determine whether a user has permission to view another users profile. I don't have much code as of yet, because I spent a long time exploring one avenue which I now realise to be the wrong one! Any suggestions/help would be greatly appreciated!
  2. hi, i have a database that looks something like this: +--------------+-------------------+-------------------+ | ce_id | ce_start_time | ce_cal | +--------------+-------------------+-------------------+ | 9 | 09:00 | 1105 | | 10 | 09:00 | 1105 | | 11 | 10:00 | 1105 | | 12 | 13:00 | 1201 | | 13 | 14:00 | 1201 | +--------------+-------------------+-------------------+ the ce_cal field refers to the year and period (11 = 2011 and 05 = period 5). i need to fetch the latest batch of records out of the table, ie those with the highest 'ce_cal' values. unfortunately, i don't know how to do this! any help would be appreciated, thanks!
  3. thanks for your suggestions. i need to view all days of the week (monday-friday) on the same page at the same time, however.
  4. Thanks for the reply. I have the following code (simple stuff right now): $sql_find_schedule = "SELECT * FROM tbl_ClassEntries WHERE ce_uid = '{$u_info['u_id']}'"; $query_find_schedule = mysql_query($sql_find_schedule) or die(mysql_error()); while($find_schedule = mysql_fetch_array($query_find_schedule)) { $recurrence = explode($find_schedule['ce_recurrence']); } I'm trying to group the records by day of the week, so I need some way of seeing what day they occur on (ie. What the contents of $recurrence is) and then displaying them under that day. Its possible that they'll occur multiple times in one week.
  5. Hi, I have a table (tbl_ClassEntries) that stores appointment information. One of the fields is 'ce_recurrence' which stores what days of the week the appointment occurs. The info is stored as a comma separated string (eg. Monday, Wednesday and Thursday would be 'm,w,th'). I'm querying this table and returning all appointments matching a certain user (field called: ce_uid) however I'd like to show a day by day list of the appointments (there will be multiple each day). I'm thinking that I need to loop through the recordset and then explode the recurrence string but then I'm stuck and don't know where to go from there. Any help would be really appreciated!
  6. With the addition of "==" instead of "=", thats done the trick, thank you!
  7. Thanks for the reply, the problem is that there aren't unique fields for each type of metadata (keywords, description etc). I have a field called met_Type and another called met_Content and there is a record for each type of metadata. Sorry is that doesn't make too much sense. Here is an e.g: | ------------|-------------------|--------------------------|-----------------------------| |met_ID |met_PageID | met_Type | met_Content | | ------------|-------------------|--------------------------|-----------------------------| |1 | 1 | keywords |blah, blah, blah | |2 | 1 | description |description here.... | | ------------|-------------------|--------------------------|-----------------------------| So I have about 7 records in total corresponding to each page, and each record holds one type of metadata.
  8. In my mind this is slightly more tricky than the usual while loop through a recordset, however I may be missing something really simple. I have a table (tbl_Metadata) that stores metadata about every page of my site. Each page has an ID, so there is a field in tbl_metadata called met_ID to associate the metadata with the corresponding page. Obviously, there are lots of types of metadata (keywords, description, language, ROBOTS etc all for SEO purposes) so each type gets a record of its own, which means that each page has about 7 records in tbl_metadata corresponding to it. I'm not sure this is the best way to achieve this, but I couldn't come up with a better solution so I went with it! My problem comes when adding/updating the contents of tbl_Metadata. I have a simple query that retrieves all records associated with a certain page ID. However, I then need to loop through these remaining records and assign the contents of 'met_Content' (where the actual metadata is stored) to local variables. I'm hoping to achieve something like this: $keywords = 'blah, blah, blah', $description = 'this is a description' and so on and so forth. I'm stuck as to how to do this! Please help!
  9. wildteen88: thank you for your suggestion! that looks like it will do the trick nicely! I'll test it out and hopefully I'll be able to report that all is working nicely.
  10. Thanks for your reply! What happens when the region is only 2 words, i.e. costa-blanca-3-bedrooms.html? Because then $details[2] would go from being the last word of the region to the number of bedrooms. Can I somehow discard the last element and extract a number from the array? Therefore leaving the region (with the varying number of words/elements)?
  11. I'm working on a website redesign and I'm under strict instruction to keep the URLs the same (they are static HTML pages) so I've figured out how to use mod_rewrite to redirect to my PHP script to decide what pages to include. My questions/problem is deciphering the original URL and extracting the info in order to make the right query/page include. The website is a villa rental site and the pages are formatted like this: costa-blanca-3-bedrooms.html. 1 problem is that the file names vary from costa-blanca-3-bedrooms.html to costa-del-sol-3-bedrooms.html to barcelona-3-bedrooms.html. As you can see, the region name differs in the number of words and therefore I can't use a strict template to extract the details into an array. My thoughts are that I could work backwards to automatically remove the last element of the array (which would be something like "bedrooms.html" as that info is useless. Then i could split my text/digits or work my way backwards, always knowing that the next element is going to be the number of bedrooms and what remains is going to be the region. How would I go about manipulating the array like this? Or does anyone have a potentially better solution? Any help would be really appreciated!
  12. Thanks for your suggestions! That returns the same server error...which most likely means that mod_rewrite IS enabled, but theres something wrong with it, right?
  13. Yeah it does, i get the same Internal Server Error message. I guess that means theres a problem with the server setup then? I've already contacted the hosting company and I'm awaiting a reply. Is there anything I can do in the meantime do you think? Unfortunately, I don't have access to any of the server config stuff because it's shared hosting.
  14. I'm using shared hosting so I don't get too much access to the server. I have checked, however, and they say that the mod_reqrite module is enabled. Any ideas why this is still not working? :S
  15. Having said that, I'm actually getting an error message using the following code: RewriteEngine on RewriteRule ^(.*)\.html$ url_rewrite.php?original_filename=$1 [L] The error message is: Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, webmaster@ and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. Any ideas?
  16. Thank you, that looks like the perfect solution!
  17. That looks like a pretty simple solution, thank you! I'm trying to future proof the site as much as possible so that other regions can be added at a later date. These might have varying number of words (ie. "costa-del-sol" or simply "barcelona") so I'm wondering how I can deal with this variable number of elements in the URL? The constant will be that after the region name, there will be 2 words, the number of bedrooms and the word "bedroom" or "bedrooms". Would it be possible to work backwards from the end of the string and parse the data that way rather than having a rigid template? Alternatively, my other thought would be to simply pass the entire filename as 1 variable to a PHP page and then parse it in PHP, so for example pass this: "path/to/file/page.php?old_filename=costa_blanca_1_bedroom.html" Is this a good idea? Thanks for your help!
  18. I'm working with an old site that is made up of entirely static html pages and I'm under strict instruction not to change the URLs at all (for SEO purposes). Pages are named like this: costa-blanca-villas.html and costa-blanca-3-bedrooms.html whereby the costa-blanca-villas.html is the parent page with links to the various sub-pages for each bedroom category. Now I'm certain I can work with this structure and still develop a new, dynamic site, but I don't know how to go about the mod_rewrite complication. Any suggestions? The pages are all consistently named as above with varying regions of Spain and numbers of bedrooms so I think I would need to forward to a new php page and pass the info along in a query string. I understand how to do this if the pages were named "villas/costa-blanca/3/" for example but I dont know how to deal with parsing the format they're in currently. Also, how would I go about ignoring the ".html" extension? Any help would be greatly appreciated!
  19. hi there, thanks for your reply! I'm afraid I don't quite understand what to do, however! I'm still getting to grips with PHP. My database schema is as follows: table: tracks fields: t_ID, t_Name, t_Description, t_Category, t_Filepath. My query is simply "SELECT * FROM tracks". So would I change it to: "SELECT * FROM tracks ORDER BY t_Category ASC"? Would you please mind explaining the 2nd and 3rd steps? I don't quite understand what you mean 'set variable $curent_cat to something that can be category' and 'browse records check variable $curent_cat again'. Thank you!
  20. So I've got a nice and straight forward query and a table that has several fields, including 'category'. I'm repeating the results of the query on the page (with a basic while loop) but I want to split the records up by category. Now I know I can use the MySQL GROUP BY option to group the records together, but I don't know how to actually split the records and add a subheading before repeating the records in that category. The subheader content will come will be the 'category' field but I really don't know how to figure this out. Is it even possible? I know I could do it with a separate query for each category and use a WHERE clause but that seems awfully long winded and I'm certain there must be a better solution! Any help would be really appreciated. Thanks!
  21. ignace, thank you for your reply. would you mind running through your code quickly...I'm pretty new to all this! The tables I have are 'users' 'businesses' and relationships' so I'm not quite sure I would convert your example to mine. Once again, thank you and I aplogise for not understanding
  22. Hi thanks for your reply! I had kind of thought of that already (but much simpler) but the problem I have is that I'm repeating a list of records (businesses) down the page so I can't pin point one exactly to query whether its being followed yet or not. So essentially I guess I need to decide before hand whether any of the businesses displayed on the page are being followed or not before rendering the correct markup. With regards to my database: I have a table for users (User_ID, Name, Email etc.) a table for businesses (Biz_ID, Name, Email etc) and a relationships table connecting the two (Relationship_ID, User_ID, Relationship_type, Business_ID). I'm now thinking about turning to AJAX to display the button. Could I make the ajax request and POST the business ID to a different script which then took the business ID and used your above code to figure out whether it's being followed already or not. This way I could make these requests on the fly and decide the right button to display for each record(business) individually. Does this sound like a good idea?
  23. I'm in the process of building a social networking platform and I'm having a little trouble with this. Essentially, when a record is displayed (showing user info) I have a button giving the option to 'follow' that user. Obviously there are some conditions to displaying this buton, such as the user has to be logged in, but I also need to check that theyre not already following the other user. I've got a simple if statement to check that there is a session in progress which then displays the 'follow' button, and if there is no session, it displays a 'log in to follow' message. The third option I need is 'You're already following this user'. Below is my simple code that I have currently that displays the button. To check if they're already following them, I'm thinking I need to query my relationships table filtering results to only the logged-in user ID. How would I then go through that to check that the other user (which is actually in a table called businesses) isn't already matched to the user and therefore already being followed by them? <!--follow the business--> <?php if ($_SESSION) { ?> <a href="LINK TO FOLLOW SCRIPT" class="follow">Follow this business</a> <?php } else { ?> <a href="LINK TO NOT LOGGED IN CODE" class="follow">Login to follow</a> <?php } ?> <!--end follow code--> So yeah, I'd really appreciate any help on this. I've got as far as querying the relationships table with a WHERE clause for the logged in user ID but then I don't know how to go about checking that the business ID in question isn't already being followed by that user. Thanks in advance!
  24. I've got this query: mysql_select_db($database_links, $links); $businesses = mysql_query($query_businesses, $links) or die(mysql_error()); $row_businesses = mysql_fetch_assoc($businesses); $totalRows_businesses = mysql_num_rows($businesses); which returns a number of records (the query string is specified earlier in the code)... and it works perfectly (as it should!) but I want to add all the results of the query to another array so that I can filter them based on a value in the mysql table. I know I can do this with another, more specific, MySQL query, but I thought this way would be more efficient (correct me if I'm wrong) So i used this foreach loop to add the results to the associative array $featured_array foreach ($row_businesses as $col => $val) { $featured_array = array($col => $val); } ...except that it doesnt work! I wrote it myself and I'm new to this so that's probably why its not working but I'd appreciate a pointed in the right direction! Also, am I going about this correctly? Should i simply use another query? Or is there a third, better way to achieving what I need. Thanks in advance!
  25. I need help with a couple of things that I think can be best accomplished in jQuery. I'm writing an application for business listings and right now I'm dealing with the actual listings page. I have a query (in PHP MySQL) that displays a list of records. On load, the name of the business and the description is displayed, however I want to truncate the text of the description to keep everything neat and tidy. When a user clicks on a particular record, I want the container div to expand to display further information about the business and I also want the truncated text to expand fully. Now I know there are plenty of individual scripts on the web for show/hiding divs and I've had a play around with adjusting the height of a div with jQuery and CSS and I've also found a jQuery plugin called jTruncate that truncates the text...but I'm struggling with putting it all together. The main problem I have with the jTruncate (and all other truncate scripts) is that they add their own 'See more' link, and I want to complete all operations with my own stylized button. The other predicament I have is related to displaying the other information. I don't know whether to expand the current div (change height property) or to show another div beneath it. Ideally I'd like the same div to slide down and then within that I can show other HTML and maybe even another div. Does anyone have any suggestions as to how I can do all this with one click of the mouse? I'm really (really!) new to jQuery (and pretty much to javascript) so any help would be greatly appreciated. If anyone knows how to do this (I'm sure its quite simple, I'm just not knowledgeable enough to know how!) using methods other than jQuery...I'd be really appreciative of that advice as well! Plain old javascript might be just as effective. Thanks.
×
×
  • 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.