473,651 Members | 3,090 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

saving data to another database

12 New Member
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 1661
Motoma
3,237 Recognized Expert Specialist
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
thepresidentis
12 New Member
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
thepresidentis
12 New Member
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 Recognized Expert Expert
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 Recognized Expert Moderator MVP
This tutorial may help

Normalization and Table structures

Mary
May 18 '07 #6
thepresidentis
12 New Member
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
thepresidentis
12 New Member
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_Us ers
Table:Banned_us ers
Table:Map_userc oncerts
Table:Users
May 20 '07 #8
MMcCarthy
14,534 Recognized Expert Moderator MVP
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
thepresidentis
12 New Member
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

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

Similar topics

4
1944
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 on our Server with Javascript, in a txt file. If it possible, then I would take the content of that page. Execute another script that will take this information an place it in our database on our server. By doing this, our Team WebSite would be
2
1822
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 anymore. I reentered it and didn't have any problems for a couple of days. Today I entered some coding, saved it, opened another database, and when I opened my original database again, the coding I had entered was missing. Access 2000 always...
1
1520
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 dataset with the data in it. I need to know how to open the workbook, delete all the data in the data worksheet, update the data worksheet from the data in the dataset and then allow the user to download the new excel workbook. Anyone have any ideas...
4
6718
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 code ?? thank you Pedro Leite From Portugal ------------------------------------
6
8112
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 picture of themselves to their profile... I admit that I'm a newbie... but this is how I understand this:
6
6443
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) and be able to load them to an image webcontrol, but system.web.ui.webcontrols.image only seems to have a control to load the image from a URL. There's no way to load this directly without saving the image as a file and then using...
3
1765
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 a "table" stored with the C# front-end (not in the Access database), but don't know if this is even possible. If it is, can someone let me know how? Otherwise, how do other people handle storing and loading query strings for possible later use?
0
1540
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 Order headers. Let call this form "OrderList" From this view I edit/enter new orders by opening a new form for entering data. This is done using (more or less) the designer generated forms, so I have a "Order edit view dialog. I pass the binding...
7
1958
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 have it saved: 1. In a directory by the guides name which would be the variable 'describe11'. Create this directory if it does not already exist. 2. Create a special file name from the date and time submitted.
7
3597
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 have put together a C# programme to do this. The data will be imported into a database table. Do you have any general tips on how store the data to a database (SQL Server 2005 Express) quickly? The amount of data could be up to 100Mbytes.
0
8278
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8807
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8701
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8466
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7299
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5615
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4144
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4290
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1588
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.