Jump to content

probabaly a simple solution. "looking up a table from a drop down value?"


therelelogo

Recommended Posts

sorry to be a constant poster looking for help from you guys.

 

another query  :shrug:

 

here is a simple form i have:

<form method="post" name="drill_down_adverts0" action="profile_standard_view_my_adverts_delete.php">


<select name="advert_select" style="width: 229px">
<?php
// Make a MySQL Connection
mysql_connect("xxxxxxx") or die(mysql_error());

$sql = "SELECT item_name FROM adverts WHERE seller = '{$_SESSION['SESS_LOGON_NAME']}' ".
"ORDER BY item_name";

$rs = mysql_query($sql);

while($row = mysql_fetch_array($rs))
{
  echo "<option value=\"".$row['item_name']."\">".$row['item_name']."\n  ";
}
?>

 

which is passed to another page, now the next page should display find the item selected in the dro pdown box, and show some more info from the table.

here it is:

 

// Make a MySQL Connection
mysql_connect("DELETED

// Get all the data from the "example" table
$result = mysql_query("SELECT * FROM adverts WHERE item_name = '$advert_select'") 
or die(mysql_error());  

echo "<table border='1'>";
echo "<tr> <th>ID</th> <th>Name</th> <th>Description</th> <th>Seller</th> <th>Category</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['item_id'];
echo "</td><td>"; 
echo $row['item_name'];
echo "</td><td>"; 
echo $row['item_description'];
echo "</td><td>"; 
echo $row['seller'];
echo "</td><td>"; 
	echo $row['category'];
echo "</td></tr>";


} 

echo "</table>";
?>

 

except, all that is "resulted" is the table head names i gave (i.e echo "<tr> <th>ID</th> <th>Name</th> <th>Description</th> <th>Seller</th> <th>Category</th> </tr>";)

there isnt actually any info being pulled from the tabel, why would this be? i'm assuming that it IS possible to search a table this way? but its more probabaly just my crappy coding.

 

as always...any help appreciated

 

thanks in advance.

Hi, thanks for the reply.

this has now been resolved, but while your here could you advise with this please:

 

<?
//print_r($_POST);

if($_POST["action"] == "Upload Image")
{
unset($imagename);

if(!isset($_FILES) && isset($HTTP_POST_FILES))
$_FILES = $HTTP_POST_FILES;

if(!isset($_FILES['image_file']))
$error["image_file"] = "An image was not found.";


$imagename = basename($_FILES['image_file']['name']);
//echo $imagename;

if(empty($imagename))
$error["imagename"] = "The name of the image was not found.";

if(empty($error))
{
$newimage = "images/" . $imagename;
//echo $newimage;
$result = @move_uploaded_file($_FILES['image_file']['tmp_name'], $newimage);
if(empty($result))
$error["result"] = "There was an error moving the uploaded file.";
}

}

?>


<form method="POST" enctype="multipart/form-data" name="image_upload_form" action="<?$_SERVER["PHP_SELF"];?>">
<p><input type="file" name="image_file" size="20"></p>
<p><input type="submit" value="Upload Image" name="action"></p>
</form>

<?
if(is_array($error))
{
while(list($key, $val) = each($error))
{
echo $val;
echo "<br>\n";
}
}
?>

 

its an upload form, however the script just keeps saying "There was an error moving the uploaded file."

i have created the folder "images" so the script should work, any ideas why it isnt?

 

sorry to change topic like that

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.