atticus Posted November 11, 2007 Share Posted November 11, 2007 I need help building a an option box. Basically, the admin will select a user from one table and upload files to another table. When that user logs in, they should be able to see those files that are associated with their name. However, I do not know the best way to do it. I would post my code, but I think I am going about the wrong way. Any suggestions on how to do this would be greatly appreciated. This is how my table structures are laid out table_cust field: cust_id field: password table_upload: field:id fields: (file info) field: cust_id Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted November 11, 2007 Share Posted November 11, 2007 Try this SELECT c.file_info FROM cust c LEFT JOIN upload u ON u.cust_id = c.cust_id Quote Link to comment Share on other sites More sharing options...
atticus Posted November 11, 2007 Author Share Posted November 11, 2007 For the option box; this is what I came up with: <form method="post" enctype="multipart/form-data"> <input type="hidden" name="MAX_FILE_SIZE" value="2000000"> <label> <select name="cust_id> <?php $sql = "SELECT * FROM cust"; $query = mysql_query($sql); while($row = mysql_fetch_array($query)) { echo "<option>".$row['cust_id']."</option>"; } ?> </select> <label>Title:</label><input type="text" name="title" id="title"><br /><br /> <label>File:</label><input name="userfile" type="file" id="userfile"><br /><br /> <label></label><td width="80"><input name="upload" type="submit" class="box" id="upload" value=" Upload "> </form> However, this looks promising for retrieving the info: Try this SELECT c.file_info FROM cust c LEFT JOIN upload u ON u.cust_id = c.cust_id However, i am not sure how to use it. How do I associate the user name with the file when they are in two different tables? Do I do it on the upload or in the results? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.