Jump to content
Larry Ullman's Book Forums

Cofa

Members
  • Content Count

    54
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Cofa

  • Rank
    Advanced Member
  1. Thanks again Hartley San. I have decided to avoid the complicated regular express approach. For purposes of sharing with the forum, my solution to allow user to add links in their message (an ad page), is to have them fill in up to 9 sets of input fields. Each set consists of one "caption" field and one "full url" field. When the page is loaded, those links (if any) will be listed at the bottom, apart from the message block (each link is rendered by combining a caption and a full url in pair). It's not fancy at all but should serve the needs of most users of our services.
  2. Sorry it looks like I am making things complicated. To make it easier to understand what I wish to do I am rewording my question again: Say if I send an email message to introduce a website to my friend. I would simply type (or copy and paste) the URL in text: "Visit this site to find out: www.sitename.com." When the message is received in the reader's browser, the URL will become a "clickable link" - this feature is seen in Gmail and many email services. And this is what I try to accomplish with my site: User can type any number of URLs in the textarea input area (I assume they know very little HTML tags), and when the message (eg, advertising) is published on a webpage, the URLs in the message will be converted into active links. Thanks for your comments. After some research I agree that it is not an easy job for me. I might just leave the URLs in plain text form for now then.
  3. Hi HartleySan, thanks for your response. What I mean is that the entry will be stored to database using this code: $message = mysql_real_escape_string(htmlspecialchars(trim($_POST['message']))); When the entry is retrieved from database I use this code to print the message on the webpage: echo nl2br($row['message']); The effect is that all HTML tags (if any) will be printed in text strings. For example, the <a href...> tag will become <a href...> and the anchor tag will have no effect as a clickable link. But the goal of my question is to see how I could change a simple URL text string (no HTML tag) a user has entered in the textarea can be printed as an active link on the webpage, using PHP coding. I think I might be able to do one URL in the message using strstr() but I would not know how to do it if there is more than one URL in the message.
  4. I have a textarea in a form to collect user message to a database. When the entry is stored to database all html tags are converted into text. Users can include any number of URLs in the message. With my current settings all the URLs will be printed on the webpage as static character strings (i.e., they are not "clickable."). I wonder how I could make those URLs become clickable links when the message is retrieved from database and printed on a webpage, using purely PHP coding?
  5. Anyone who is familiar with the topic "MLS® data feed" and all of the components in the subject line? I want to develop a program that can fetch MLS listing data from the appropriate MLS data servers in Canada and in the US for use by multiple user. My initial research shows that none of the "data feed" sources and specifications have anything to do with PHP and MySQL. Could anyone give me an idea how big the difference is between the specifications of RETS, IDX, DDF, XML and the specifications of PHP and MySQL? Thanks.
  6. Thanks HartleySan. I notice that (as from real test), the SELECT `AUTO_INCREMENT` code will get the *future* ID to be inserted if I subsequently execute an insert query. I assume there would be a chance my actual insert would generate a member_id that's different than the value being captured in the first query, IF there's another transaction that has been executed in between my two queries - is this possible (although extremely slim)? Anyway, I found your second suggestion much easier for me, and with these advantages: 1) Everything is inserted in just one query (i.e., only the lastname and firstname values), and the "auto_increment ID" is guaranteed to be unique for that query. 2) The publicname value can be generated by SELECT whenever is needed, and can be in any pattern (good flexibility for future changes). Thanks again!
  7. I have a membership table which contains the following fields (as example): member_id (primary key, auto increment = 123) lastname (= Smith) firstname (= David) publicname (= 123SD) Note that the value of the field publicname is in fact the combination of the member_id and the first characters of the fields lastname and firstname, respectively. I manage to insert the values of the first three fields to create a new record as the first step, then create the value for field publicname and insert it into the newly created record as the second step. My question is, whether it is possible to insert a new record in just ONE sql query: two values for fields firstname and lastname are provided via form input while values for fields member_id and publicname are generated by a php script. If it is possible, any hint how this could be achieved? Thanks!
  8. Mmmm. Each combination of m_id and other columns can be a unique record (listing). If we don't have l_id (listing id), how could we call (identify) a record from the table then? I must miss something here and am interested in knowing more. Thanks.
  9. Hi HartleySan, thanks for your comments. The l_id in the listings table is the primary key (auto assigned and auto incremented whenever a new listing is created). In the listings table each record will have many more other columns (property age, price, room measurements, etc, etc) that are not shown here. For my learning sake, I don't understand why you see m_id in the listings table could be unique, as each member ('m_id') can have many unique listings in the table (only the 'l_id' is unique). Thanks.
  10. Below is my final result of this topic - four tables and two query options... members m_id m_name 1 David 2 Jennifer 3 Mary groups g_id g_name 1 Group1 2 Group2 mem_group m_id g_id 1 1 2 2 3 1 3 2 listings l_id m_id type 1 1 House 2 3 Condo 3 1 Condo 4 1 Townhouse 5 3 Condo 6 2 Condo 7 3 Condo ----------------------- SUCCESSFUL QUERY CODE: ----------------------- SELECT l.* FROM listings AS l LEFT JOIN members AS m ON l.m_id = m.m_id LEFT JOIN mem_group AS mg ON m.m_id = mg.m_id WHERE mg.g_id = 2 ORDER BY l.l_id DESC ----------------------- SELECT * FROM mem_group AS mg LEFT JOIN listings AS l ON mg.m_id = l.m_id WHERE mg.g_id = 2 ORDER BY l.l_id DESC
  11. Thanks for following up on this. I'll check out the query code when have chance and update here again. Have a great day!
  12. After some thinking, I still don't understand why the need of "another table between members and listings," since I already have table listings consisting of this relationship. Any hint please? (Note: the table listings will also consist of other columns like property_type, address, age, etc.) I still haven't had a chance to experiment the query as I have not built the tables yet. But I have yet already had another query code (below) - wonder if there is any error. Thanks. SELECT m.id, g.id FROM members AS m, groups AS g WHERE g.id = 2 ##We are to get all listings of group 2 GROUP BY g.id LEFT JOIN members_groups AS mg ON ( g.id = mg.group_id ) LEFT JOIN listings AS l ON ( l.member_id = m.id ) ORDER BY l.id DESC
  13. Thanks again for the quick reply! I think I'll need some time to figure out how to do the query part.It's good to know the direction so far. Have a great day!
  14. Thanks HartleySan for the quick reply (and how are you? it's been a while ) ! I have not set up the database tables yet but figure that what I need to do next could be as follows... I'll set up a listings table and use the SQL query to retrieve the listings of a specified group, like this: listings id member_id 1 1 2 3 3 1 4 1 5 3 6 2 SELECT l.*, m.id, g.id, mg.group_id FROM listings l, members m, groups g, members_groups mg WHERE g.id = '2' ##We are to get all listings of group 2 AND mg.group_id = g.id AND l.member_id = mg.member_id GROUP BY l.id ORDER BY l.id DESC; Could you predict any wrong in the above code? Thanks!
×
×
  • Create New...