Page 1 of 1

Beginner is kind of lost here......

Posted: Thu Oct 26, 2006 6:17 pm
by jm999
I'm in the process of building a gift registry and I'm drawing a blank about how to go about this. I don't expect anyone to solve my problems for me but maybe give me a few pointers on how I should approach this. I have already set up the database and registration form and everything is working good. Now I need to set up a page where the user can log in to administer their registry. The things I'm having trouble with wrapping my head around are:

1. The idea is that the user will have their own admin page to populate/update their registry with links to items on different websites. They would copy/paste the links into a textfield and seperate them with a comma. I only have one field for links in the database. Is it possible to display clickable links for items in the same field that are seperated by a comma? What is the best way to go about it? I also need to add the ability to add/edit/delete the entries. I know how to accomplish this through MySql, but not with items seperated by commas.

2. The next issue is that when a user registers they can instantly invite other people via email to view their registry. There is a field in the reg. form called "guests" in which guest's email addresses are entered, seperated by a comma. These people are stored in the database in the field "guests". As soon as the registration form is submitted it sends the automated email to the addresses in the "guests" field. The problem that I'm having is generating a clickable link within the email that will take the guest to the users registry page.

Like I said, I'm new and I want to learn so I just need some tips on what I should consider doing. I'm sorry if these questions have been asked. Any help would be HUGELY appreciated! Thanks for reading.

Posted: Thu Oct 26, 2006 6:25 pm
by s.dot
#1

Sounds like you're in need of a separate table to store the links. It would be a simple setup..

ID | USERID | LINK

With the above setup, a single query could get all of any users links.

SELECT `link` FROM `linktable` WHERE `userid` = '$x'

That would be much more practical than storing a comma delimited list. However, if you do want to go the comma way, explode() will help you get single values out of the list. For example:

Code: Select all

$links = explode(',', $comma_delimited_list);

//echo '<pre>';
//print_r($links);
//echo '</pre>';

#2.

What kind of troubles? Link syntax?

Code: Select all

<a href="http://www.yoursite.com/view_registry.php?userid=1234">view</a>
That link would imply that you have a PHP page called view_registry, that would query the database for all entries by userid 1234.

Posted: Thu Oct 26, 2006 6:50 pm
by jm999
:oops:

Yeah, a seperate table would be much easier to deal with.

To be more specific on sending the link...

How does the "userid=1234" get added to the link automatically when the email is sent? I'm assuming I can't put <a href="blahblah.com/view_registry.php?userid=<?php echo $userid ?>">Click Here</a>.

Posted: Thu Oct 26, 2006 7:33 pm
by s.dot
How does the "userid=1234" get added to the link automatically when the email is sent? I'm assuming I can't put <a href="blahblah.com/view_registry.php?userid=<?php echo $userid ?>">Click Here</a>.
why can't you? ;d

that's how it's done!

Posted: Thu Oct 26, 2006 7:36 pm
by RobertGonzalez
jm999 wrote:How does the "userid=1234" get added to the link automatically when the email is sent? I'm assuming I can't put <a href="blahblah.com/view_registry.php?userid=<?php echo $userid ?>">Click Here</a>.
Variables represent something in PHP. Of course you can do what you assumed here you cannot. $userid is just a var. Tell PHP to do something with it and watch what happens.

Posted: Thu Oct 26, 2006 8:02 pm
by jm999
Thanks for the advice guys. I was just assuming that the "<" and ">" would affect the html syntax negatively. This all seems pretty obvious. I think I've just been trying to cram too much into my brain in the last week or two. 8O .

Posted: Thu Oct 26, 2006 9:59 pm
by RobertGonzalez
Remember, PHP is an HTML embeddable language. That in itself allows for that type of syntax.

Code: Select all

<?php
$name = 'jm999';
?>
You know what I mean, <?php echo $name; ?>?