Jump to content

Join 3 PHP statements into 1 .. ??


spacepoet

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
Share on other sites

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.