Jump to content

Recommended Posts

i connect to the db:

 

mysql_connect("localhost", "admin", "pass") or die(mysql_error());

mysql_select_db("test") or die(mysql_error());

 

now, i have a table called: 'shipment' with three fields:

 

tracking

name

address

 

I keep the tracking (which is unique) in a cookie for later use -- so I can do this :

 

$tracking = $_COOKIE['tracking'];

$check = mysql_query("SELECT * FROM shipment WHERE tracking = '$tracking'")or die(mysql_error());

 

Now, my problem is that I need to echo the name and address for tracking and I don't know how.

 

How do I do that? Any Ideas?.

Read some basic php-mysql tutorials....

 

<?php

$check = mysql_query("SELECT * FROM shipment WHERE tracking = '$tracking'")or die(mysql_error());
$row = mysql_fetch_array($check);
echo $row['name']." Lives in ".$row['address'];

?>

 

 

@wildteen88- You're faster :D But no need for a loop, "tracking" is unique.

 

Orio.

You have to put the query into an array like so:

 

$shipment = mysql_fetch_array($check);

 

then to display the rest you would do echo it like this:

 

echo $shipment['name'];

 

or

 

echo $shipment['address'];

 

I hope this helps!

 

 

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.