I am very much new to php and MySql, but everything I do know is self learned.
I have a form that once filled in and submitted enters the correct information into my database. Now I want to retrieve that information, actually I only need to retrieve and echo sorryID into a table. I can successfully echo the sorryID into the table on my page, however I only want to data from the sorryID to to echoed if there is a corresponding squareID.
My database table is:
Table raffle
squareID name email sorryID time
5 Tom Thumb tom@dst.net Sorry, I'm already taken 2010-05-03 12:48:52
3 Bertha Bugle bertha@dst.net Sorry, I'm already taken 2010-05-03 12:53:22
7 John Smith john@dst.net Sorry, I'm already taken 2010-05-03 12:53:42
I have a table on the raffle.php page with 10 columns and 10 rows, I am trying to figure out how to echo the sorryID column from the database into the correct corresponding table cell.
So if someone fills out the form and selects square 5, or 3, or 7, or what ever square they choose, it gets entered into the database, now I want to display only the data from sorryID into the corresponding squareID which corresponds to the correct table cell.
Someone selects table cell 5, fills in the form, submits it, then the sorryID is automatically echoed into the table cell 5.
<?php
// Make a MySQL Connection
$db = mysql_connect("localhost", "root", "admin") or die(mysql_error());
mysql_select_db("raffle",$db) or die(mysql_error());
// Retrieve all the data from the "raffle" table
$result = mysql_query("SELECT * FROM raffle");
//or die(mysql_error());
// store the record of the "raffle" table into $row
$row = mysql_fetch_array($result);
// Print out the contents of the entry
//echo "Name: ".$row['sorryID'];
?>
<td width="92" height="50" align="left" valign="top" class="number">1<br />
<p align="center"><?php echo $row["sorryID"]; ?></p>
</td>
Right now the sorryID data is echoed to every table cell, but that is not what I want. Is this possible, and if it is, could one of you knowledgeable people please help me. This is for a fundraiser for a non-profit dog rescue group that is hurting for donations.
Here is a link to the page I am using
http://www.pap911rescue.com/raffle/spring_raffle.php
Thank you for any and all help.
Larry
MOD EDIT: [noparse]
..
[/noparse] bbcode tags added.