n8w Posted February 26, 2006 Share Posted February 26, 2006 I am creating a [b]"my favorites" [/b]feature on [a href=\"http://www.illustrationmundo.com/illustrators.php?str_date=rb\" target=\"_blank\"]http://www.illustrationmundo.com/illustrat...php?str_date=rb[/a] where when a user is logged in they can add the illustrators they like to their favorites listThe favorites table will have the following fields:user_id - login idillustrator_id - the id of the illustrator they want to save as one fo their favoritesdate - current dateSo I have two questions[!--sizeo:2--][span style=\"font-size:10pt;line-height:100%\"][!--/sizeo--][b]1. When a user clicks "add favorite" should I have this as an ajax function that processes this request and updates the page without changing the page (if so how do I do this .. or go about learning how to do this).. if not .. I assume I just have a php page that will process this info and return the user back to the page they were previously on.[/b][!--sizec--][/span][!--/sizec--][!--sizeo:2--][span style=\"font-size:10pt;line-height:100%\"][!--/sizeo--][b]2. What is the best way to write the sql statement to insert/update this in the database?[/b][!--sizec--][/span][!--/sizec--]In the past I have wrote multiple SQL statements .. with a series of "if" statements .. but I am sure there is a more effecient way to do this??What I have been doing is ... if the table has user_id and artist_id as the primary key then write a sql statement that UPDATES the tableif notwrite a sql statement thatn inserts this infois there an easy way where you can just write .. insert this info .. and if it exists it overwrites it .. or do you have to do it the way I have been doing it?Thanks so muchn8wShould I write a few sql statements Quote Link to comment Share on other sites More sharing options...
fenway Posted February 26, 2006 Share Posted February 26, 2006 Well, you could always go the AJAX route (or the preferred IFRAME route, IMHO); alternatively, just have an "Add" button to add another favourite, and then a "Save" button that calls the desired php script. Depending on the table layout, you could always use a REPLACE INTO, assuming you don't care about the UIDs. Quote Link to comment Share on other sites More sharing options...
n8w Posted February 27, 2006 Author Share Posted February 27, 2006 Hey Fenway .. thanks for responding. I think I will try the Iframe approach. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.