MySQL join two tables and post

I have two tables ‘Registration’ and ‘2012 Reunion Registration’. I have a foreign key “ID”. Currently my log in is pulling session information from ‘Registration’ using ‘username’. I want to pull the (ID, username, fname, lname, linage, and state) from 'Registration and add it to ‘2012 Reunion Registration’ and store the values entered from the new form into '2012 Reunion Registration as well. Then I want to display all of the information from both database tables into a table on the page. This is what I have:

[php]

<?php session_start(); if (isset($_SESSION['username'])) { header('Location: portal.php'); } ?> Elston Family <?php $hostname="myelstonfamily.db.#######.hostedresource.com"; $dbuser="myelstonfamily"; $pass="password"; $username = $_POST['username']; $password = $_POST['password']; $linage = $_POST['linage']; $fname = $_POST['fname']; $lname = $_POST['lname']; $adultfees = $_POST['adultfees']; $youthfees = $_POST['youthfees']; $childrenfees = $_POST['childrenfees']; $tyouthsmall = $_POST['tyouthsmall']; $tyouthmedium = $_POST['tyouthmedium']; $tyouthlarge = $_POST['tyouthlarge']; $tadultsmall = $_POST['tadultsmall']; $tadultmedium = $_POST['tadultmedium']; $tadultlarge = $_POST['tadultlarge']; $tadultxl = $_POST['tadultxl']; $tadult2xl = $_POST['tadult2xl']; $tadult3xl = $_POST['tadult3xl']; $ap = $_POST['ap']; $ao = $_POST['ao']; $ad = $_POST['ad']; $pif = $_POST['pif'];

$link = mysql_connect($hostname,$dbuser, $pass);
$db_selected = mysql_select_db(‘myelstonfamily’, $link);
if (!$db_selected) {
die ('Can’t use foo : ’ . mysql_error());
}
else
{

mysql_query ("SELECT FROM Registration FULL JOIN 2012 Reunion Registration ON Registration.id=2012 Reunion Registration id, Registration.username=2012 Reunion Registration id, Registration.fname=2012 Reunion Registration.fname, Registration.lname=2012 Reunion Registration.lname, Registration.linage=2012 Reunion Registration.linage, Registration.state=2012 Reunion Registration.state);
}

mysql_query (“INSERT INTO 2012 Reunion Registration (id,username,fname,lname,state,linage,adultfees,youthfees,childrenfees,tyouthsmall,tyouthmedium,tyouthlarge,tadultsmall,tadultmedium,tadultlarge,tadultxl,tadult2xl,tadult3xl,ap,ao,ad,pif) VALUES(’$adultfees’,’$youthfees’,’$childrenfees’,’$tyouthsmall’,’$tyouthmedium’,’$tyouthlarge’,’$tadultsmall’,’$tadultmedium’,’$tadultlarge’,’$tadultxl’,’$tadult2xl’,’$tadult3xl’,’$ap’,’$ao’,’$ad’,’$pif’)”);
?>

You have successfully submitted your 2012 Reunion Registration. <?php echo "Your total due is: SELECT SUM ("ad") FROM 2012 Reunion Registration WHERE username = ("_SESSION['username']");;

// I want to display this in a table
echo “Your Reunion Information is:
SELECT * FROM Registration WHERE username = (”_SESSION[‘username’]");
SELECT * FROM 2012 Registration WHERE username = “_SESSION[‘username’]”);;
?>
[/php]

I hope I explained that well.

to display the data they need to be inside a query variable not an echo.

as you did to INSERT.

[php]$query = “SELECT * FROM Registration …etc…”

$result = mysql_query($query);

if (!$result) die ("Database access failed: " . mysql_error());

$rows = mysql_num_rows($result);

{

	$row = mysql_fetch_row($result);

echo $row[0] . $row[1] . ///and so on - all rows start with 0

}

php]

Sponsor our Newsletter | Privacy Policy | Terms of Service