/    Sign up×
Community /Pin to ProfileBookmark

Hi All,

I’m running a query and after that query I want to run a thank you message:

[code=php]
$result = mysql_query(“Insert into results(team_one_id ,team_two_id) values(‘$team_one_id”$team_two_id’)”);
$msg = “Thank you the fixture ” . $team_one_id .” v’s ” . $team_two_id .” has been added to the database. Please continue or <a href=’../index.php’>Return to the index </a>”;
[/code]

Now the data I enter in the database I want to be able to say find the values entered in the database ie: [b]1 v’s 2[/b]

And then lookup the values in the database in another table [b]teams[/b] and print them in the thank you message:

So the thank you message would output as:

[b]team a v’s team b[/b]

[b]teams[/b]

Team_id | Name
1 | Team A
2 | Team B

Now this is the code I have for doing this:

[code]
SELECT th.team_name AS home_team, ta.team_name As away_team, r.home_score, r.away_score, r.results_id
FROM results r
INNER JOIN teams th ON r.team_one_id = th.team_id
INNER JOIN teams ta ON r.team_two_id = ta.team_id
[/code]

So how can I run my insert query whilst running the above at the same time to produce my thank you message?

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@jasonahouleJun 19.2007 — I am not sure I really understand what you are saying here. You can execute more than one query.
Copy linkTweet thisAlerts:
@chrisbauthorJun 19.2007 — Thanks,

so say in this query:

[code=php]
<?php

// Start the connection to the database

// Deleted!

// Include functions to get the various values from the dropdown boxes
include('../../../include/functions.php');

// ** If Submit is hit do your stuff **
if (isset($_POST['Submit'])) {

// ** Check for Required Fields with IF statements **
if (empty($team_one_id)){
$msg = "** You forgot to enter the home team! **";
} else if (empty($team_two_id)){
$msg = "** Error: You forgot to enter the away team! **";

// ** If all of the statements are true then **
} else {
$result = mysql_query("Insert into results(match_date,team_one_id,team_one_score,team_two_score,team_two_id,form,competition) values('$match_date','$team_one_id','$team_one_score','$team_two_score','$team_two_id','$form','$competition')");
$msg = "Thank you the fixture " . $home_team ." v's " . $team_two_id ." has been added to the database. Please continue or <a href='../index.php'>Return to the index </a>";

}
}
?>
[/code]


I want to run that query, but then also at the same time do a lookup on the [b]teams[/b] table I mentioned to use this query:

<i>
</i>SELECT th.team_name AS home_team, ta.team_name As away_team, r.home_score, r.away_score, r.results_id
FROM results r
INNER JOIN teams th ON r.team_one_id = th.team_id
INNER JOIN teams ta ON r.team_two_id = ta.team_id


Thanks
Copy linkTweet thisAlerts:
@jasonahouleJun 19.2007 — [code=php]
<?php

// Start the connection to the database

// Deleted!

// Include functions to get the various values from the dropdown boxes
include('../../../include/functions.php');

// ** If Submit is hit do your stuff **
if (isset($_POST['Submit'])) {

// ** Check for Required Fields with IF statements **
if (empty($team_one_id)){
$msg = "** You forgot to enter the home team! **";
} else if (empty($team_two_id)){
$msg = "** Error: You forgot to enter the away team! **";

// ** If all of the statements are true then **
} else {

$result = mysql_query("Insert into results(match_date,team_one_id,team_one_score,team_two_score,team_two_id,form,competition) values('$match_date','$team_one_id','$team_one_score','$team_two_score','$team_two_id','$form','$competition')");
$result2 = mysql_query("SELECT th.team_name AS home_team, ta.team_name As away_team, r.home_score, r.away_score, r.results_id
FROM results r
INNER JOIN teams th ON r.team_one_id = th.team_id
INNER JOIN teams ta ON r.team_two_id = ta.team_id");
$msg = "Thank you the fixture " . $home_team ." v's " . $team_two_id ." has been added to the database. Please continue or <a href='../index.php'>Return to the index </a>";

}
}
?>
[/code]
×

Success!

Help @chrisb spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...