Jump to content

closer but no cigar. PHP and mySQL


tet3828

Recommended Posts

Thanks for the responses so far people. I appreacieate you all bearing with me as I reduce the broad nature of my questions by grasping the mysql/PHP concept. Ill admit the last response made very little sense to me prior to my recent trip to the library and some practice coding....Moving right along.

here goes:

I have a table in mySQL it contains

roughly 20 rows or "items" with the following values as columns: NAMEs, CATAGORYs, DESCRIPTIONs , PRICEs and HTTP:// reference to a thumbnail

how should I approach displaying the NAME PRICE AND THUMBNAIL in a borderless table when an item's catagory is selected from a dropdown?


Link to comment
Share on other sites

[code]<?php

if(!isset($_POST['submit']))
{
die("<html><body><form action=\"".$_SERVER['PHP_SELF']."\" method=\"POST\">
<select name=\"cat\">
<option value=\"cat1\">Cat1</option>
<option value=\"cat2\">Cat2</option>
</select>
<input type=\"submit\" name=\"submit\" value=\"Search!\">
</form>
</body>
</html>");
}

//Make sure you are connected to the database
$qry = "SELECT NAME,PRICE,HTTP:// FROM `Table_Name` WHERE CATAGORY='".$_POST['cat']."'";
$result = mysql_query($qry) or die(mysql_error());

echo "<table border=\"0\"><tr><td>Name</td><td>Price</td><td>Thumbnail</td></tr>";

while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>".$row['NAME']."</td>";
echo "<td>".$row['PRICE']."</td>";
echo "<td><img src=\"".$row['HTTP://']." /></td>";
echo "</tr>";
}

echo "</table>";

?>[/code]

Orio.
Link to comment
Share on other sites

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.