Presto-X Posted January 6, 2007 Share Posted January 6, 2007 Hello Guys,I’m new to PHP and this is the first time I needed to post a question asking for help I normal use my PHP bible, search the forum, or search around on PHP freaks website, I think what I am wanting to do is relatively easy but I’m a noob lolHere we go; bear with my bad coding,I have a html questioner form with yes or no questions on it, this form posts the data to mysql. I want to know if there is a way to show an echo or print if the value of the field is = to yes and show nothing if the field is = to no.I was trying to use something like:[code]if ($identitypack == Yes) {echo "Identity Package";}[/code]Also I’m not sure if I’m doing my query the best way or not.Here is the code that I put together: [code]<?PHPinclude '../include/config.php';mysql_connect($server, $username, $password);@mysql_select_db($database);$table="customers";$id = $_GET['id'];$result = mysql_query("SELECT company, firstname, lastname, address, city, state, zip, country, email, website, phone1, phone2, phone3, fax1, fax2, fax3, totaltime, description, domainreg, websitehosting, identitypack, graphicdesign, websitedesign, contentwriting, searchengine, ecommerce FROM $table WHERE id = '$id'");mysql_close();$i = mysql_fetch_row($result);// contact information$company = $i[0];$firstname = $i[1];$lastname = $i[2];$address = $i[3];$city = $i[4];$state = $i[5];$zip = $i[6];$country = $i[7];$email = $i[8];$website = $i[9];$phone1 = $i[10];$phone2 = $i[11];$phone3 = $i[12];$fax1 = $i[13];$fax2 = $i[14];$fax3 = $i[15];// billing information$totaltime = $i[16];$description = $i[17];// the customer's interests$domainreg = $i[18];$websitehosting = $i[19];$identitypack = $i[20];$graphicdesign = $i[21];$websitedesign = $i[22];$contentwriting = $i[23];$searchengine = $i[24];$ecommerce = $i[25];echo "<p class=\"style1\">$company</p><p><a href=contract.php?id=$id target=_blank>View / Print $company's Contract »</a><br><a href=../invoice.php?id=$id target=_blank>View / Print $company's Invoice »</a></p><p><b>Contact Information:</b><br>$firstname $lastname,<br>$address<br>$city $state $zip</p><p>Phone: ($phone1) $phone2-$phone3<br>Fax: ($fax1) $fax2-$fax3</p><p><a href=mailto:$email>$email</a><br><a href=$website target=_blank>$website</a></p><p><b>Services:</b><br>";if ($identitypack == Yes) {echo "Identity Package";}?>[/code]Thanks in advance guys Quote Link to comment https://forums.phpfreaks.com/topic/33124-solved-using-values-from-mysql-data-with-if-or-else/ Share on other sites More sharing options...
.josh Posted January 6, 2007 Share Posted January 6, 2007 well..other than your condition needing quotes around the "Yes" it's technically right. Quote Link to comment https://forums.phpfreaks.com/topic/33124-solved-using-values-from-mysql-data-with-if-or-else/#findComment-154330 Share on other sites More sharing options...
Presto-X Posted January 6, 2007 Author Share Posted January 6, 2007 that did the trick, thanks Crayon Violent I was so close lol Quote Link to comment https://forums.phpfreaks.com/topic/33124-solved-using-values-from-mysql-data-with-if-or-else/#findComment-154375 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.