I have set up a DB which uses a Code table to store numerical values that correspond to a "Description" of the cigar. For example, a Cigar made in the Dominican Republic would be stored in the DB as being made in "80004." I'm not completely immovable on the Code table if someone has a better idea but my understanding is that storing values as numbers is more effecient and makes queries run quicker than text strings.
In any case, I am developing a page which displays all the information for a given cigar individually. This is what the sections look like currently:
<?php session_start(); //Set Page Variable $CigarID = $_GET['cigar_id']; //Open Database include 'dbconnection.php'; //Set Array $SQL = "SELECT * from Cigar WHERE Cigar_ID = $CigarID"; $Result = mysql_query($SQL); $Array = mysql_fetch_array($Result); //Decode Manufacturer $SQL2 = "SELECT * FROM Code WHERE $Array = Code"; $Result2 = mysql_query($SQL2); $Array2 = mysql_fetch_array($Result2); //Decode Wrapper $SQL3 = "SELECT * FROM Code WHERE $Array = Code"; $Result3 = mysql_query($SQL3); $Array3 = mysql_fetch_array($Result3); ?>
Sample of Display Text
Cigar Id = <?php echo $CigarID ?><br> Cigar Description = <?php echo $Array ?><br> Cigar Manufacturer = <?php echo $Array2 ?><br> Cigar Wrapper = <?php echo $Array3 ?><br>
As you can see, the only way I've been able to get it to work is by creating a set of commands for EACH descriptor of the cigar that has a value stored in the Code table. This is frankly annoying and I'm sure there has to be another, more efficient, way to do this but I can't figure it out. I've tried setting up the Code table itself as an array but then it's having problems identifying the individual descriptors (e.g. Wrapper, Binder Filler, etc) to link them to the Code table.
Any help or suggestions??? :confused:
Edited by jrotunda85: Fix PHP Code Tags