Jump to content

[SOLVED] Using values from mysql data with if or else


Presto-X

Recommended Posts

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 lol

Here 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]<?PHP
include '../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 &raquo;</a><br>
<a href=../invoice.php?id=$id target=_blank>View / Print $company's Invoice &raquo;</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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.