I recently bought a book titled, "Sams Teach Yourself PHP, MySQL and Apache" in hopes of learning how to change my website from a static one to a database driven site. After 2 weeks of frustration, I still have not been able to figure out how to accomplish my goal.
Here is a sample of the html code that I wish to modify with variables pulled from a MySQL database:
<tr>
<td width="137" height="100" colspan="3"></td>
<td width="130" height="100" colspan="4" valign="top">
<img src=".../images/helmets/Colts.jpg" width="130" height="100"></td>
<td width="18" height="100"></td>
<td width="130" height="100" colspan="3" valign="top">
<img src=".../images/helmets/Patriots.jpg" width="130" height="100"></td>
<td width="155" height="100" colspan="5"></td>
<td width="130" height="100" colspan="6" valign="top">
<img src=".../images/helmets/Cardinals.jpg" width="130" height="100"></td>
<td width="20" height="100"></td>
<td width="130" height="100" colspan="9" valign="top">
<img src=".../images/helmets/Rams.jpg"width="130" height="100"></td>
<td width="148" height="100" colspan="4"></td>
</tr>
I have a MySQL table named "wkly_forms" where I have a column named "week" and numerous columns named gm_01a, gm_01b, gm_02a, gm_02b, and so on. Each "gm_*" column contains the name of a team. What I would like to do is replace the hardcoded team values (Colts, Patriots, Cardinals, Rams) with a variable ($gm_01a, $gm_01b, $gm_02a, $gm_02b) that pulls it's value from the database.
The code I use to pull the data from the database is as follows:
<?php
$conn = mysql_connect("localhost", "joeuser", "somepass");
mysql_select_db("wkly_forms",$conn);
$sql = "SELECT gm_01a FROM wkly_forms WHERE(week = "01")";
$result = mysql_query($sql, $conn) or die(mysql_error());
?>
How do I get this information into my html form? Is it even possible?
Would anyone be willing to share the syntax or procedure to accomplish this?
I am completely new to PHP, except for the 500 plus pages I've read with no successful outcome, so any help would be GREATLY appreciated! This is also my first post on a forum, so please be gentle!
Thanks,
Deadlast99