Jump to content

Recommended Posts

Hello:

 

I am writing this code:

<?php

include('include/myConn.php');
include('include/myCodeLib.php');

$zip_id = $_REQUEST['zip_id'];

$query=mysql_query("SELECT zip_id,city,full_state,zip FROM zip_codes WHERE zip_id = $zip_id") or die("Could not get data from db: ".mysql_error());

while($result=mysql_fetch_array($query))
{
  $zip_id=$result['zip_id'];
  $city=$result['city'];
  $full_state=$result['full_state'];
  $zip=$result['zip'];
}

?>

<!DOCTYPE HTML>

<head>

<title></title>

</head>

<body>

<?php echo $city; ?>, <?php echo $full_state; ?> <?php echo $zip; ?>

</body>

</html>

 

It works fine as far as writing out the "City, State Zipcode", but I wanted to see if there is a way to "join" the 3 statements together so it can be written as just 1 statement. Like:

<?php echo $city, $full_state $zip; ?>

 

What is the trick to doing this?

 

Thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/254771-join-3-php-statements-into-1/
Share on other sites

OK, thank you.

 

I think I see where you are going with it.

 

Something like:

<?php echo . $city . " ," . $full_state . $zip . ?>

 

???

 

I basically want it to read "City, State Zipcode"

 

Example: Downingtown, Pennsylvania 19335

 

Will that work that way?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.