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?
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.
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.... -
-
echo "Results<BR>";
-
-
$count = 1 + $s;
-
-
-
-
// this registers the information into a variable
-
-
while ($row= mysql_fetch_array($result)) {
-
-
$title = $row["City"];
-
$title2 = $row["State"];
-
$title3 = $row["Metro_Area"];
-
$title4 = $row["Date_Input"];
-
$title5 = $row["Band_Or_Event_Name"];
-
$title6 = $row["Genre"];
-
$title7 = $row["Genre_2"];
-
$title8 = $row["Genre_3"];
-
$title9 = $row["Genre_4"];
-
$title14 = $row["Venue"];
-
$title10 = $row["Other_Info"];
-
$title11 = $row["MP3_Link"];
-
$title12 = $row["Link_to_Directions"];
-
$title13 = $row["Age_Restrictions"];
-
-
-
-
//this displays the information stored in the variables
-
-
echo "$count.)
-
Date : <FONT color='red'>$title4</FONT><BR>
-
Band or event : <FONT color='red'>$title5</FONT>
-
-
Venue : <FONT color='red'>$title14</FONT><BR>
-
-
City : <FONT color='blue'>$title</FONT><BR>
-
-
State : <FONT color='red'>$title2</FONT> <BR>
-
Metro Area : <FONT color='red'>$title3</FONT><BR>
-
-
Genre : <FONT color='red'>$title6</FONT><BR>
-
Other genre's : <FONT color='red'>$title7, $title8, $title9</FONT><BR>
-
Age restriction : <FONT color='red'>$title13</FONT><BR>
-
Other information : <FONT color='red'>$title10</FONT><BR>
-
Link to mp3 : <FONT color='blue'>$title11</FONT><BR>
-
Link to directions : <FONT color='blue'>$title12</FONT></a><BR><BR>";
-
-
//this is what i used to create a link but i would rather use a function to process the insert into.
-
-
echo "[<a href=\"http://www.showsniffer.com/fgen/use/Submit/SaveShow.html\">Save This Event</a>]";
-
-
$count++ ;
-
-
}
-
-
-
-
$currPage = (($s/$limit) + 1);
-
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.
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: -
mysql> SELECT * FROM `Map_UserConcert` LIMIT 5;
-
+--------+-----------+
-
| userid | concertid |
-
+--------+-----------+
-
| 1| 158|
-
| 8| 32|
-
| 2| 60|
-
| 12| 204|
-
| 1| 1|
-
+--------+-----------+
-
5 rows in set (0.0000 sec)
-
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: -
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;
-
Which would give you something like this: -
mysql> SELECT * FROM `View_SavedConcerts` WHERE `userid` = '1' AND `Date_Input` > NOW();
-
+--------+------+-----------+---------+-------+---------+
-
| userid | Name | concertid | City | State | etc.... |
-
+--------+------+-----------+---------+-------+---------+
-
| 1| John | 158 | Chicago | IL |
-
+--------+------+-----------+---------+-------+
-
| etc... |
-
+--------+
-
And boom; all in one table, you have your User and concert data.
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.
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
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.
would it be possible to create a clickable link to envoke a variable called -
$SAVE = mysql_connect("host","username","password");
-
mysql_select_db("userdb");
-
$query2="insert into map_userconcert (userid,concertid) values ('".$userid."','".$concertid."')";
-
mysql_query($query2);
-
Sign in to post your reply or Sign up for a free account.
Similar topics |
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
|
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...
|
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...
|
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
------------------------------------
|
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:
| |
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...
|
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?
|
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...
|
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.
|
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.
|
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,...
| |
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...
|
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...
|
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,...
|
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...
|
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();...
|
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...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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...
| |