1.11M Members

need to pass information for one item from a page with multiple results

 
0
 

I am creating a database that will be filled with items for sale. I am trying to create a back end so that the items can be edited, currently I am working on the pictures that will be uploaded for the items. I need to make it so that I can upload multiple pictures for each individual item. I have almost everything working however when I try to select the specific item from a page that lists all the items in the database I run into my problems. I have tried using select buttons but I am missing on passing only the one items id through to the next page and I wind up passing all of the ids along and get errors. Can anyone help? here is the code I am working with:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Vehicle Select</title>
</head>
<body onUnload="window.addEventListener("unload", invalidateBackCache, true)>
<center>
<?php
$result = mysql_query("SELECT * FROM inventory")
    or die(mysql_error());

echo "<table border = '1'>";
echo "<tr><th>ID</th><th>Description</th></tr>";
while($row = mysql_fetch_array($result))
    {
        //print out the contents of each row
        echo "<tr><td>";
        echo $row['id'];
        $refId = $row['id'];
        echo "</td><td>";
        echo $row['description'];
        echo "</td><td>";
        ?>
        <form action="picUploads.php" method="post"
enctype="multipart/form-data">
<input type="hidden" name="refID" value=<?php echo $refId; ?> /></td><td><input type="submit" name="submit" value="Select" />
        <?php
        echo "</td></tr>";
    }
echo "</table>";
switch($refId)
{

}
?><br /><br />
<a href = addInventory.php><input type = "button" value = "Add Items" /></a> <a href = register.php><input type = "button" value = "Add Users" /></a><br /><br /><a href = logout.php><input type = "button" value = "Logout" /></a>
</center>
</body>
</html>

I need for the ID to be passed along to the next page to be used as a reference so that the pictures uploaded will refer to the selected item. The code for the page that it is passed to:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Photo Upload</title>
</head>

<body  onUnload="window.addEventListener("unload", invalidateBackCache, true)>
<center><h1>UPLOAD PICTURES</h1></center>
<form action="upload.php" method="post"
enctype="multipart/form-data">
<input type="text" name="refID" value=<?php echo $_POST['check_option']; ?> /><br />
<label for="file">Filename:</label>
<input type="file" name="file" id="file" />

<input type="submit" name="submit" value="Submit" />
</form>
</body>
</html>

when I get this figured out there will be more places for the user to upload photos so that they can give more then one at a time. Thank you in advance for any help.

LastMitch
Deleted Member
 
1
 

@GraficRegret

I have tried using select buttons but I am missing on passing only the one items id through to the next page and I wind up passing all of the ids along and get errors.

What errors? Why didn't you post the errors?

On line 25 & 26 :

<form action="picUploads.php" method="post" enctype="multipart/form-data">

Change it to this

<form name="?" action="picUploads.php" method="post">

Where is you name? Plus you didn't close your </form>

I need for the ID to be passed along to the next page to be used as a reference so that the pictures uploaded will refer to the selected item. The code for the page that it is passed to

You are missing a query to fetch that id to appear on to that page.

 
0
 

For multiple picture upload, why not try

Uploadify http://www.uploadify.com/demos/

PLupload http://www.plupload.com/example_queuewidget.php

BlueImp http://blueimp.github.com/jQuery-File-Upload/ for Twitter Bootstrap

Anyway you could do something similar with multiple file fields - or even a single one with AJAX.

I'd favour an ajax interface (single page) with this - here's a mockup of how I'd go about it (no css - so looks rubbish):

sc4

Anyway, again - your problem seems to be that you don't have a close form tag. Maybe I'm wrong.

Attachments
 
0
 

Change this $_POST['check_option']; to $_POST['refID'];

You are posting refId with field name 'refID' 
 
0
 

@LastMitch I owe you an appology bud, I had uploaded a previous version of my script, I thought the form was closed and all the mistakes you had pointed to were fixed, I have a newer script which is the one I thought was uploaded that I have it all set up the way you are suggesting. I am very sorry for my comments.

@everyone I made all the necesasary changes to the scripts and I now have it passing a value but it will only pass through the last id that was retrieved from the table no mater which one I "select" any ideas?

 
1
 

Perhaps if you post your updated code?

 
0
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Vehicle Select</title>
</head>
<body onUnload="window.addEventListener("unload", invalidateBackCache, true)">
<center>
<?php
$result = mysql_query("SELECT * FROM inventory")
    or die(mysql_error());

echo "<table border = '1'>";
echo "<tr><th>ID</th><th>Year</th><th>Make</th><th>Model</th><th>Milage</th><th>Description</th></tr>";
//keeps getting the next row untill no more exist
while($row = mysql_fetch_array($result))
    {
        //print out the contents of each row
        echo "<tr><td>";
        echo $row['id'];
        $refId = $row['id'];
        echo "</td><td>";
        echo $row['year'];
        echo "</td><td>";
        echo $row['make'];
        echo "</td><td>";
        echo $row['model'];
        echo "</td><td>";
        echo $row['mileage'];
        echo "</td><td>";
        echo $row['description'];
        echo "</td><td>";
        ?>
        <form action="picUploads.php" method="post"
name="itemSelect">
<input type="text" name="refID" value=<?php echo $refId; ?> /></td><td><input type="submit" name="submit" value="Select" id="<?php $refId; ?>" /></td></tr>
        <?php
    }
?></table><br /><br />
<a href = addInventory.php><input type = "button" value = "Add Cars" /></a> <a href = register.php><input type = "button" value = "Add Users" /></a><br /><br /><a href = logout.php><input type = "button" value = "Logout" /></a>
</form>
</center>
</body>
</html>

as far as errors there are no errors it simply displayse the item id of the last one that was loaded so if the last one loaded was if 12 then 12 is displayed in the refID field on the next page regardless of which item I "select"

 
0
 

Line 36, change value=<?php echo $refId; ?> to value="<?php echo $refId; ?>". I don't think that'll solve it but you should have the quotes there. Same for the hrefs on line 40.

Can you provide your code on the next page that includes $_POST['refID'] and how you process it? Make sure you are accessing $_POST['refID'], not $_POST['refId'].

 
0
 

sure here it is

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Photo Upload</title>
</head>

<body  onUnload="window.addEventListener("unload", invalidateBackCache, true)">
<center><h1>UPLOAD PICTURES</h1>
<form action="upload.php" method="post"
enctype="multipart/form-data">
<input type="text" name="refID" value=<?php echo $_POST['refID']; ?> /><br />
<label for="file">Pictures to be uploaded:</label><br />
<input name="file[]" type="file" /><br />
<input name="file[]" type="file" /><br />
<input type="submit" name="submit" value="Submit" /><br /><br /><a href = addInventory.php><input type = "button" value = "Add Cars" /></a> <a href = register.php><input type = "button" value = "Add Users" /></a><br /><br /><a href = logout.php><input type = "button" value = "Logout" /></a>
</form>
</center>
</body>
</html>

there it is and this line

<input type="text" name="refID" value=<?php echo $_POST['refID']; ?> />

is made a text area for the sole purpose of testing to see if the propper value is passed through, once it is passed correctly it will be made a hidden field to hold the value for further processing

 
0
 

@ D

For multiple picture upload, why not try

I will definitely look into those, however I am being told to "recreate the whele" as it were, and I get chewed out whenever I look to something like those even for snippets, I am however urged to look at things like those for ideas on how to go about making my own programms

 
0
 

I'm sorry, I'm not seeing any reason why only the last refID would be passed. Maybe someone else has an idea.

On a side note, the <center> tag is deprecated, you shouldn't use it anymore. If you need to center-align something, wrap it in a div, give the div a width, and then set margin: 0 auto;. The auto left & right margins will center the div.

 
0
 

ok i will remember that thanks

 
0
 

ok so I finally figured this one out, by the grace of God. the code is good but I had to make each itteration of the while loop create a form specifically for each item pulled up so that the forms only had one refID each but I still had all the information I needed to have pulled up.

Question Answered as of 1 Year Ago by diafol, EvolutionFallen, Bachov Varghese and 1 other
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article