/    Sign up×
Community /Pin to ProfileBookmark

Formatting Results Help

Hello:

I could use some help in formatting my results a bit neater.

My script creates a drop-down where a person can select a customer. Once, a customer is selected, all information pertaining to that customer appears.

Finally, the script gives the person a link to select another customer.

Right now, the information appears like:
Company: whatever
Address: whatever
City: whatever
Home Phone: whatever

I would like to make this more readable by placing the information into a table so the information is all lined up as such:

[code=php]
Company: whatever
Address: whatever
City: whatever

Here is the portion of the script that is displaying the information:

//get rest of customer information
$get_info = “select * from customer where id = $_POST[sel_id]”;
$get_info_res = mysql_query($get_info);

if (mysql_num_rows($get_info_res) > 0) {
$display_block .= ”
<P><b><font size=”2″ face=”Verdana”>Customer Information:</b><br><br>”;

while ($add_info = mysql_fetch_array($get_info_res)) {
$company = $add_info[Company];
$address = $add_info[Address];
$city = $add_info[City];
$state = $add_info[State];
$zipcode = $add_info[zipcode];
$homephone = $add_info[HomePhone];
$workphone = $add_info[WorkPhone];
$email1 = $add_info[PrimaryEmail];
$email2 = $add_info[SecondEmail];

$display_block .= ”
Company: $company<br>
Address: $address<br>
City: $city<br>
State: $state<br>
Zip Code: $zipcode<br>
Home Phone: $homephone<br>
Work Phone: $workphone<br>
Primary Email: $email1<br>
Secondary Email: $email2″;
}

$display_block .= “</font>”;
}

$display_block .= “<br><br><p><font size=”2″ face=”Verdana”><a href=”$_SERVER[PHP_SELF]”>Select Another Customer</a></p></font>”;
}
?>

<html>
<head>
<title>template</title>
</head>
<body>
<?php echo $display_block; ?>
</body>
</html>
[/code]

I experimented with modifying this section by placing table tags into it as such:

[code=php]
$display_block .= ”
<table border=1>
<tr>
<td>Company:</td> <td> $company</td></tr>
<tr><td>Address:</td> <td> $address/td></tr>
<tr><td>City:</td> <td>$city</td></tr>
<tr><td>State:</td> <td>$state</td></tr>
<tr><td>Zip Code:</td> <td>$zipcode</td></tr>
<tr><td>Home Phone:</td><td>$homephone</td></tr>
<tr><td>Work Phone:</td><td>$workphone</td></tr>
<tr><td>Primary Email:</td><td>$email1</td></tr>
<tr><td>Secondary Email:</td><td>$email2</td></tr>”;
}

$display_block .= “</font>”;
}

$display_block .= “<br><br><p><font size=”2″ face=”Verdana”><a href=”$_SERVER[PHP_SELF]”>Select Another Customer</a></p></font>”;
}
?>
[code=php]

The result places the information after the Select Another Customer Link. I’m not sure why.

If someone can give me some help with formatting, it’ll be greatly appreciated.

Thanks so much.

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@JonaSep 05.2004 — [font=trebuchet ms]You have forgotten to close your [/font][font=courier new]table[/font][font=trebuchet ms] tag.[/font]
Copy linkTweet thisAlerts:
@summit310authorSep 05.2004 — Yes, that was it.

Thanks for the help.?
Copy linkTweet thisAlerts:
@JonaSep 05.2004 — [font=trebuchet ms]You're welcome. ? [/font]
×

Success!

Help @summit310 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...