prcollin Posted September 4, 2008 Share Posted September 4, 2008 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); ?> Quote Link to comment https://forums.phpfreaks.com/topic/122715-how-do-i-make-the-first-column-for-each-result-a-hyperlink/ Share on other sites More sharing options...
Hinty Posted September 4, 2008 Share Posted September 4, 2008 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); ?> Quote Link to comment https://forums.phpfreaks.com/topic/122715-how-do-i-make-the-first-column-for-each-result-a-hyperlink/#findComment-633739 Share on other sites More sharing options...
pocobueno1388 Posted September 4, 2008 Share Posted September 4, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/122715-how-do-i-make-the-first-column-for-each-result-a-hyperlink/#findComment-633741 Share on other sites More sharing options...
prcollin Posted September 4, 2008 Author Share Posted September 4, 2008 You guys are awesome thanks. Worked like a charm Quote Link to comment https://forums.phpfreaks.com/topic/122715-how-do-i-make-the-first-column-for-each-result-a-hyperlink/#findComment-633750 Share on other sites More sharing options...
prcollin Posted September 4, 2008 Author Share Posted September 4, 2008 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} Quote Link to comment https://forums.phpfreaks.com/topic/122715-how-do-i-make-the-first-column-for-each-result-a-hyperlink/#findComment-633785 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.