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
54
Other forums
File upload issues
Hi Guys,
Can anyone see any issues with this code:
Code: [Select]$setImage= 'productimages
User feedback after MySQL query has been executed
Hi all, I've just registered on PHPFreaks because I've got a question that I simply can't work out b
Code error with Index.php
Error: Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/runevid/public_
Creating a unique 'control panel' for each user
Hi there,
I'm thinking of designing a site that will allow users to sign up and have their ow
Logging and nologging bulk insert
Hi,
oracle version: 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
PHP loop
Okay so I have several "articles" stored in a mysql database and am attempting to echo tho
if statements problems
Hi. I'm trying to make a web form, but I kind of hit a dead end trying to figure out why it doesn't
my code does not work.
I have a code problem.
Quote"<a href=index.php?gogo=ureticidetay&'?l={$le
natcasesort works on one server but not on another
Hi
I have a problem that I was hoping that someone can help me with.
I'm trying to use
Spaghetti Code
So.
I've pretty much reached the point where I have so many isset s on one page that I can't