473,382 Members | 1,786 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

saving data to another database

I have a database that users can search for concert listings.
I also have a user registration database where users can log on.
I want to be able to have a link in the search results for the concert listings to save the show information to their profile.
I have thought long and hard about this but I am still green on PHP
I thought i could create a link next to the each concert listing (SAVE THIS EVENT) and then send the event info to a form that automatically inserts it into their saved shows column in the user reg database.
Am I even close?
If so how would i send the info to the user reg database?
May 16 '07 #1
10 1645
Motoma
3,237 Expert 2GB
I have a database that users can search for concert listings.
I also have a user registration database where users can log on.
I want to be able to have a link in the search results for the concert listings to save the show information to their profile.
I have thought long and hard about this but I am still green on PHP
I thought i could create a link next to the each concert listing (SAVE THIS EVENT) and then send the event info to a form that automatically inserts it into their saved shows column in the user reg database.
Am I even close?
If so how would i send the info to the user reg database?
I would create another table, consisting of UserID and EventID. When a user saves an event, put it in the table.
May 17 '07 #2
I would create another table, consisting of UserID and EventID. When a user saves an event, put it in the table.
okay. Thanks
one more question though,
how would I send the data from the concert listing to the database?
i was thinking that i could create the save this show link and then if they were to press it then it would call a function?
that would use insert into.
but my problem is that i am still new to coding with php, and I am not sure how to pass the data stored in the variables to a function that will use insert into.
any help would be such a life saver!!!!
here is what I have so far....
Expand|Select|Wrap|Line Numbers
  1.  
  2. echo "Results<BR>";
  3.  
  4. $count = 1 + $s;
  5.  
  6.  
  7.  
  8. // this registers the information into a variable
  9.  
  10. while ($row= mysql_fetch_array($result)) {
  11.  
  12. $title = $row["City"];
  13. $title2 = $row["State"];
  14. $title3 = $row["Metro_Area"];
  15. $title4 = $row["Date_Input"];
  16. $title5 = $row["Band_Or_Event_Name"];
  17. $title6 = $row["Genre"];
  18. $title7 = $row["Genre_2"];
  19. $title8 = $row["Genre_3"];
  20. $title9 = $row["Genre_4"];
  21. $title14 = $row["Venue"];
  22. $title10 = $row["Other_Info"];
  23. $title11 = $row["MP3_Link"];
  24. $title12 = $row["Link_to_Directions"];
  25. $title13 = $row["Age_Restrictions"];
  26.  
  27.  
  28.  
  29. //this displays the information stored in the variables
  30.  
  31. echo "$count.)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  32. Date : <FONT color='red'>$title4</FONT><BR> 
  33. &nbsp;Band or event : <FONT color='red'>$title5</FONT> 
  34. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  35. &nbsp;&nbsp;Venue : <FONT color='red'>$title14</FONT><BR>
  36. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  37. &nbsp;&nbsp;&nbsp;&nbsp;City : <FONT color='blue'>$title</FONT><BR> 
  38. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  39. &nbsp;&nbsp;&nbsp;&nbsp;State : <FONT color='red'>$title2</FONT> <BR>
  40. &nbsp;&nbsp;&nbsp;Metro Area : <FONT color='red'>$title3</FONT><BR>
  41. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  42. &nbsp;Genre : <FONT color='red'>$title6</FONT><BR> 
  43. &nbsp;&nbsp;Other genre's : <FONT color='red'>$title7,&nbsp;$title8,&nbsp;$title9</FONT><BR> 
  44. &nbsp;Age restriction : <FONT color='red'>$title13</FONT><BR>
  45. &nbsp;Other information : <FONT color='red'>$title10</FONT><BR> 
  46. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Link to mp3 : <FONT color='blue'>$title11</FONT><BR> 
  47. &nbsp;Link to directions : <FONT color='blue'>$title12</FONT></a><BR><BR>";
  48.  
  49. //this is what i used to create a link but i would rather use a function to process the insert into.
  50.  
  51. echo "[<a href=\"http://www.showsniffer.com/fgen/use/Submit/SaveShow.html\">Save This Event</a>]";
  52.  
  53. $count++ ;
  54.  
  55. }
  56.  
  57.  
  58.  
  59. $currPage = (($s/$limit) + 1);
  60.  
May 17 '07 #3
also could I just register the primary Key as a variable and just save the Primary Key in the saved events column in the USER REG DB?
I am Hoping this will save disk space rather than saving all of the show information again.
May 17 '07 #4
pbmods
5,821 Expert 4TB
I'm moving this thread to the MySQL forum 'cause that's what it's turning into!

Welcome to database normalization 101.

Alrightey. So you have concerts, and you have Users. Users can save as many events as they want, and more than one User can save any given concert. You have what we like to call a "many-to-many" relationship.

Many-to-many relationships between two tables actually requires three tables:
  • Data_Concerts
  • Data_Users
  • Map_UserConcert

Map_UserConcert tells you what Concerts each User has saved:

Expand|Select|Wrap|Line Numbers
  1. mysql> SELECT * FROM `Map_UserConcert` LIMIT 5;
  2. +--------+-----------+
  3. | userid | concertid |
  4. +--------+-----------+
  5. |       1|        158|
  6. |       8|         32|
  7. |       2|         60|
  8. |      12|        204|
  9. |       1|          1|
  10. +--------+-----------+
  11. 5 rows in set (0.0000 sec)
  12.  

As you can see (at least by this sample of 5 rows), User #1 saved concerts 1 & 158; User #2 saved concert 60; User #8 saved concert 32 and User #12 saved concert 204.

For best results, you'll be wanting to create a view:

Expand|Select|Wrap|Line Numbers
  1. CREATE VIEW `View_SavedConcerts` AS SELECT * FROM (`Data_Users` LEFT JOIN `Map_UserConcert` USING(`userid`) LEFT JOIN `Data_Concerts` USING(`concertid`)) ORDER BY `userid`, `concertid` ASC;
  2.  
Which would give you something like this:

Expand|Select|Wrap|Line Numbers
  1. mysql> SELECT * FROM `View_SavedConcerts` WHERE `userid` = '1' AND `Date_Input` > NOW();
  2. +--------+------+-----------+---------+-------+---------+
  3. | userid | Name | concertid |   City  | State | etc.... |
  4. +--------+------+-----------+---------+-------+---------+
  5. |       1| John |       158 | Chicago |    IL |
  6. +--------+------+-----------+---------+-------+
  7. | etc... |
  8. +--------+
  9.  
And boom; all in one table, you have your User and concert data.
May 17 '07 #5
MMcCarthy
14,534 Expert Mod 8TB
This tutorial may help

Normalization and Table structures

Mary
May 18 '07 #6
Thanks for all the info, it is really helping...
I am still a little confused(sorry)
on map_concerts does there need to be an index?
I have 2 fields
userid and concert id.
May 20 '07 #7
p.s the users db is a seperate database than the concerts database

here is my structure

Database: EVENT DATA
Table:Events
then there is a seperate fields for State, city, metro area, etc...

Database: UserDB
Table: Active_guests
Table:Active_Users
Table:Banned_users
Table:Map_userconcerts
Table:Users
May 20 '07 #8
MMcCarthy
14,534 Expert Mod 8TB
Thanks for all the info, it is really helping...
I am still a little confused(sorry)
on map_concerts does there need to be an index?
I have 2 fields
userid and concert id.
Assuming you are talking about a JOIN table to split up a many to many relationship then it would have a composite primary key made up of both foreign keys.
May 20 '07 #9
would it be possible to create a clickable link to envoke a variable called
Expand|Select|Wrap|Line Numbers
  1. $SAVE = mysql_connect("host","username","password");
  2. mysql_select_db("userdb");
  3. $query2="insert into map_userconcert (userid,concertid) values ('".$userid."','".$concertid."')";
  4. mysql_query($query2);
  5.  
May 20 '07 #10
pbmods
5,821 Expert 4TB
would it be possible to create a clickable link to envoke a variable called ....
To do that, create a link to another PHP script that executes that statement.

E.g.,
Expand|Select|Wrap|Line Numbers
  1. <a href="save.php?concertid=4">Save this Concert</a>
  2.  
Then in save.php:
Expand|Select|Wrap|Line Numbers
  1. mysql_connect("host","username","password");
  2. mysql_select_db("userdb");
  3. $query2="insert into map_userconcert (userid,concertid) values ('".$userid."','".intval($_GET['concertid'])."')";
  4. mysql_query($query2);
  5.  
May 20 '07 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Rene Aube | last post by:
Hi everyone, I'm incharge of updating the stats on a chl hockey teams Web Site. I would like to know if there is a way (javascript) to be able to save the content of the CHL Statistics WebPage...
2
by: manning_news | last post by:
Has anyone had a problem with Access 2003 not saving their coding? I've been using 2003 for a couple of months now and just this week noticed that some coding I'd done for a database was not there...
1
by: Bernard O'Flynn | last post by:
Hi I have a pivot table that gets it data from another worksheet in the workbook. I need to update the data worksheet from data in a database (I'm using MS Data Application Block) and get a...
4
by: Pedro Leite | last post by:
Good Afternoon. the code below is properly retreiving binary data from a database and saving it. but instead of saving at client machine is saving at the server machine. what is wrong with my...
6
by: Jeff | last post by:
Hey (and thank you for reading my post) In visual web developer 2005 express edition I've created a simple website project.. At this website I want users who register to be able to upload a...
6
by: Mark Denardo | last post by:
My question is similar to one someone posted a few months back, but I don't see any replies. Basically I want to be able to have users upload photos and save them in a database (as byte data)...
3
by: Nathan Guill | last post by:
I have an interface that works with an Access back-end. I would like to store and/or load user defined query strings per each user (i.e. no user can access another's queries). The idea I had was...
0
by: Magnus Bergh | last post by:
I am developing an application for pocketpc and this involvs a but of juggling with different forms. I have an "order entry" type of application. On the main form I have a grid which displays...
7
by: Dave Kelly | last post by:
There has to be a name for what I want to do and I don't know what words to google for. I have a form here: http://www.texasflyfishers.org/firstpage.htm I want to submit it to the server and...
7
by: Jon | last post by:
Hi, I plan to import some data from an old DOS-based programme. The data file format that this programme produced appears to be proprietary, but I've managed to reverse engineer the format and...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.