Display SQL Query Data in Table with Links - Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Go Back   Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more > Webmaster Tech > Databases - MySQL, SQL, Oracle, Access and others

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 07-30-2009, 01:52 PM   #1 (permalink)
Junior Member
 
Join Date: Jul 2009
Posts: 4
Default Display SQL Query Data in Table with Links

Posted before in the wrong forum.

Although I am pretty good with HTML and a little javascript, I have a problem using php which I know nothing about.

I'm trying to insert an html table which displays info from an mysql database . . . product info as well as two hrefs, a thumbnail image which enlarges in a new window when clicked (scripted in webpage) and an add to basket link. I'm not sure if I can do either of these from the database. (Newbie to php and mysql)

I'm doing this mostly so that all changes can be made from the product database (by someone who knows nothing about HTML or Javascript) without having to alter web pages.

I tried searching the web for examples and apply that to my situation, but nothing shows up on my webpage.

Here is the code as it exists now. Is this rubbish or can it be fixed?

<table border="0" cellspacing="2" cellpadding="2">

<?
$username="MyName";
$password="MyPassword";
$database="MyProducts";

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM MyProducts";
$result=mysql_query($query);

$num=mysql_numrows($result);

mysql_close();


$i=0;
while ($i < $num) {

$Category=mysql_result($result,$i,"Category");
$ItemID=mysql_result($result,$i,"ItemID");
$Desc=mysql_result($result,$i,"Desc");
$Price=mysql_result($result,$i,"Price");
$Thumb=mysql_result($result,$i,"Thumb");

$query="SELECT * FROM PoshEtc WHERE Category='Dresses'";
$result=mysql_query($query);



?>



<tr>
<td><? echo $Thumb; ?></td>
<td><? echo $ItemID; ?></td>
<td><? echo $Desc; ?></td>
<td><? echo "$" $Price; ?></td>
<td><? echo $AddLink; ?></td>

</tr>

<?
$i++;
}


echo "</table>";

Thanks a bunch,
Carol
CarolD54 is offline   Reply With Quote
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Sponsors

» Links

» Affiliates
Web Hosting
Online Backup Reviews
Marketing Find
Merchant Select
SiteMap Builder
Host Compare

» Links

» Sports Network
Paintball Forum
Football Forum
Hockey Forum
Golf Forum
Boxing Forum
Lacrosse Forum
Baseball Forum
SnowBoarding Forum
Soccer Forum
MMA Forum


All times are GMT -4. The time now is 07:17 AM.


Powered by vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.2
Webmaster Forums
Web Hosting | Chicago Web Hosting | Web Hosting