Jump to content

How do i make the first column for each result a hyperlink?


Recommended Posts

I hve this code and I want customerName to be a link that when clicked it brings me to a display page with infomration regarding the name that was clicked.  First I just need the way to make it a hyperlink then if anyone can offer insight for my other feat that would be great too

 

<?php

/** include riles */
include "connect.php";


/** Establish Database Connection */
mysql_select_db('sepr_mxxxxxxxxxxt', $con);


/** set up the query and results */
$result = mysql_query("SELECT * FROM xxxxxxbleTaxxxes");

while($row = mysql_fetch_array($result))
{
echo $row['orderID']. " " . $row['customerName']. " " . $row['customerEmail']. " " . $row['tableSize']. " " . $row['feltColor']. " " . $row['cupHolders']. " " . $row['chipHolders']. " " . $row['sideRails']. " " . $row['paintColor']. " " . $row['woodFinish']. " " . $row['schoolLogo']. " " . $row['orderTotal']. " " . $row['estimatedCompletion']. " " . $row['completeDate']. " " . $row['deliveryInstructions']. " " . $row['deliveryDate'];

echo "<br />";
}

mysql_close($con);
?>

Hey, put the name inbetween the anchor tag for hyperlinks

 

<?php

/** include riles */
include "connect.php";


/** Establish Database Connection */
mysql_select_db('sepr_mxxxxxxxxxxt', $con);


/** set up the query and results */
$result = mysql_query("SELECT * FROM xxxxxxbleTaxxxes");

while($row = mysql_fetch_array($result))
{
echo $row['orderID']. "<a href='http://link-to-page'>" . $row['customerName']. "</a>  " . $row['customerEmail']. " " . $row['tableSize']. " " . $row['feltColor']. " " . $row['cupHolders']. " " . $row['chipHolders']. " " . $row['sideRails']. " " . $row['paintColor']. " " . $row['woodFinish']. " " . $row['schoolLogo']. " " . $row['orderTotal']. " " . $row['estimatedCompletion']. " " . $row['completeDate']. " " . $row['deliveryInstructions']. " " . $row['deliveryDate'];

echo "<br />";
}

mysql_close($con);
?>

I'm going to assume that the customer's name is a unique field in your customer table, if not...you should use the auto incremented ID for the URL.

 

Here is how you would make it a link:

echo $row['orderID']. " <a href='customer.php?name={$row['customerName']}'>{$row['customerName']}</a> " . $row['customerEmail']. " " . $row['tableSize']. " " . $row['feltColor']. " " . $row['cupHolders']. " " . $row['chipHolders']. " " . $row['sideRails']. " " . $row['paintColor']. " " . $row['woodFinish']. " " . $row['schoolLogo']. " " . $row['orderTotal']. " " . $row['estimatedCompletion']. " " . $row['completeDate']. " " . $row['deliveryInstructions']. " " . $row['deliveryDate'];

 

I'm just going to call the page the link goes to "customer.php".

 

Now, on the customer.php file, you need to do something like this.

 

//grab their name from the URL
$name = $_GET['name'];

//do a query selecting their information from DB
$query = mysql_query("SELECT fields FROM customer_table WHERE customerName='$name'")or die(mysql_error());
$row = mysql_fetch_assoc($query);

//now you can start displaying their information here

Ok now I want to display the info as a table this is what I have and it still just displays the informaiton in string format not in table format

 

<?php

/** include files */
include "connect.php";

/** Establish Database Connection */
mysql_select_db('sepr_xxxxxxxxxxnt', $con);

//grab their name from the URL
$name = $_GET['name'];

//do a query selecting their information from DB
$query = mysql_query("SELECT * FROM coxxxxxxles WHERE customerName='$name'")or die(mysql_error());

echo "<table border='1'>";
while($row = mysql_fetch_assoc($query));

//now you can start displaying their information here


{

echo "<tr><td> .$row['orderID']. "</td><td>" . $row['customerName']. "</td><td>" . $row['customerEmail']. 

"</td><td>" . $row['tableSize']. "</td><td>" . $row['feltColor']. "</td><td>" . $row['cupHolders']. 

"</td><td>" . $row['chipHolders']. "</td><td>" . $row['sideRails']. "</td><td>" . $row['paintColor']. 

"</td><td>" . $row['woodFinish']. "</td><td>" . $row['schoolLogo']. "</td><td>" . $row['orderTotal']. 

"</td><td>" . $row['estimatedCompletion']. "</td><td>" . $row['completeDate']. "</td><td>" . 

$row['deliveryInstructions']. "</td><td>" . $row['deliveryDate']. "</td></tr>";

}
echo "</table>";

mysql_close($con);

?>

 

one last thing is how can i make it show in this format if anyone knows or can helpi have someone doing this layout for me but would like to try to see if anyone can help me learn.  or point me in the right direction

 

Customer Details

Customer ID  { ID HERE }

Customer Name                  Customer Address

{Name Here}                              {Address Here}

Customer Email                   Customer Phone

{Email Here}                                {Phone Here}

 

Project Details

Project Title {Title Here}

Project Description

{

Space here for the details

}

Project Status                      Estimated Completion

{Status Here}                              {Completion Here}

Order Total

{Total Here}

 

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.