Hello I am new to the database world and Ive learned how to do a few things storing text is easy. i found that out but trying to get an image to show up on a page is difficult and i cant seem to find the correct way to call it up in php so it will display..What i am trying to do is build a search engine for a furniture companys rug collection...so that the rug type style size and an image next to that will show up...
this is my php code
[php]<?php # rug search_results. php
$connection = mysql_connect(' *', '*', '*') or die(mysql_error ());
if (!$connection) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db ("rugs", $connection);
$rugtype_id = "";
if (isset($_GET['rugtype_id'])) {
$rugtype_id = $_GET['rugtype_id'];
}
if ($rugtype_id != NULL) {
$query = "SELECT * FROM rugs WHERE rugtype_id=$rug type_id";
$result = mysql_query($qu ery, $connection);
if (mysql_num_rows ($result) > 0) {
while ($row = mysql_fetch_arr ay($result, MYSQL_ASSOC)) {
echo "{$row['itemnumber']}";
echo "<br />";
echo "{$row['rugname']}";
echo "<br />";
echo "{$row['origin']}";
echo "<br />";
echo "{$row['fabric']}";
echo "<br />";
echo "{$row['image']}";
} // End of WHILE loop.
}
else { // No
echo '<p class="error">' ;
echo "There are no rugs listed for the given request.";
echo "</p>";
}
}
else {
echo '<p class="error">' ;
echo "Please select a valid rug type from the drop-down menu in order to view the rugs.";
echo "</p>";
}
?>[/php]please tell me what im doing wrong any input would help thanks
Dan
this is my php code
[php]<?php # rug search_results. php
$connection = mysql_connect(' *', '*', '*') or die(mysql_error ());
if (!$connection) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db ("rugs", $connection);
$rugtype_id = "";
if (isset($_GET['rugtype_id'])) {
$rugtype_id = $_GET['rugtype_id'];
}
if ($rugtype_id != NULL) {
$query = "SELECT * FROM rugs WHERE rugtype_id=$rug type_id";
$result = mysql_query($qu ery, $connection);
if (mysql_num_rows ($result) > 0) {
while ($row = mysql_fetch_arr ay($result, MYSQL_ASSOC)) {
echo "{$row['itemnumber']}";
echo "<br />";
echo "{$row['rugname']}";
echo "<br />";
echo "{$row['origin']}";
echo "<br />";
echo "{$row['fabric']}";
echo "<br />";
echo "{$row['image']}";
} // End of WHILE loop.
}
else { // No
echo '<p class="error">' ;
echo "There are no rugs listed for the given request.";
echo "</p>";
}
}
else {
echo '<p class="error">' ;
echo "Please select a valid rug type from the drop-down menu in order to view the rugs.";
echo "</p>";
}
?>[/php]please tell me what im doing wrong any input would help thanks
Dan
Comment