Hyperlink in PHP to MySQL record


Posted on 16th Feb 2014 07:03 pm by admin

Hello,

I am having trouble as i am new to php. I have connected to the database and I have displayed the fields i want on my page. I need to access certain fields by links to each letter.

For example A will link to the products starting with A and so on.

I am using PHP ad MySQL. The database is however on a different server. I only have the .php file at the moment and want to display the data on a HTML page.

I am just unsure of how to make a link to the product field and the price field and display them within a table.
My code is this so far..

<?php
// Connect to the database server
mysql_connect("host", "username", "psssword") or die(mysql_error());

// Open to the database
mysql_select_db("telephon_cscartrestore") or die(mysql_error());

//select records from table
$result = mysql_query("SELECT cscart_product_descriptions.product, cscart_product_prices.price FROM cscart_product_descriptions, cscart_product_prices ORDER BY cscart_product_descriptions.product ASC") or die(mysql_error());

echo "<table border='1'>";
echo "<tr> <th>Product</th> <th>Price</th> </tr>";
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table
echo "<tr><td>";
echo $row['product'];
echo "</td><td>";
echo $row['price'];
echo "</td></tr>";
}

echo "</table>";

?>
I want a link 'A' that opens all records starting in A and so on. Is this possible?

thanks

No comments posted yet

Your Answer:

Login to answer
131 Like 54 Dislike
Previous forums Next forums
Other forums

shift numbers with paging
Hi

How would i be able to display 10 numbers 1 2 3 4 5 6 7 8 9 10
and when I click next

removing space from the end of a variable
i have a variable $image which contains the following url "http://tiles.xbox.com/tiles/oo/P5/0m

How can i steam a video on my PHP site? (non YouTube)
Basically I have a PHP site and don't want to give page rank to YouTube. I just want to stream a bas

Batch update record with Pagination
Hoping someone can help me with this issue I'm having, im trying to batch update records from a resu

restricting another login once you logout
Hello,

how can I restrict a page from login authenticating against info in a MySQL DB for a s

How to secure my login data to my database?
Hi there,

It may be a stupid question but I don't know how to secure my login data to my data

Can't find the problem (no error message)!
OK, here's the deal. This code is really weirdly formatted (sorry!) and hard to understand, so I'm g

Had a simple form script that suddenly stopped working
It was made about a year ago and had been working fine. Last time it was known to work for sure was

Allegro crashes when running load_bitmap. Why?
I can not get Allegro to load any BMP images. Here is a section of test code. The picture is in the

Php If in MySql query (hiding labels if a field is empty)
Okay, I've been trying to do this for a while, and I'm finally going to ask for help so I can get th

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash