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
https://forums.phpfreaks.com/topic/25146-closer-but-no-cigar-php-and-mysql/
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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.