SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How To make SQL Query Select Option Results
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

jdsmith8
Starting Member

USA
11 Posts

Posted - 07/12/2014 :  16:36:20  Show Profile  Reply with Quote
Hi All,

I have a Managers table in my SQL DB and it has a ManagerID, MgrName and MgrPhoto field base...

I can code a form with a select button that displays a drop down with the managers in it as choices, but am a little confused as to how I would make the PHOTO (MgrPhoto) change to the corresponding ManagerID that is selected from that option drop down since the SELECT CODE in the form only queries the ManagerID / MgrName combo for the choice.. The photo is below that drop down box and does anyone know how to make it change to whatever photo is assigned to the selected ManagerID / MgrName ???

Here is the form code with query :

<form enctype="multipart/form-data" action="updatemanagerphoto.php" method="POST"> 
<select name="ManagerID" id="manager" style="width:400px" class="form_textbox">
                             <?
                                               
							$db_connect	= mysql_connect($db_host, $db_username, $db_password);
							mysql_select_db($db_name, $db_connect) || die(mysql_error());
													
							$sql_query	= "SELECT * FROM Managers ORDER BY MgrName ASC";
							$result		= mysql_query($sql_query) or die(mysql_error());
							while($row	= mysql_fetch_array($result)){
														
							$row			= decode_array($row);
							$ManagerID		= $row['ManagerID'];
							$MgrName	= $row['MgrName'];
							$MgrPhoto   = $row['MgrPhoto'];

							?>
							    <option value="<?= $ManagerID; ?>"><?= $MgrName; ?></option>
							<?
												        
							}
							mysql_close($db_connect);
													
													
							?>
    									</select>
												<br/> <br/> 
                                                Current Image (if exists) :<br/>
           <?
		                                 
							$db_connect	= mysql_connect($db_host, $db_username, $db_password);
							mysql_select_db($db_name, $db_connect) || die(mysql_error());
													
							$sql_query	= "SELECT MgrPhoto FROM Managers WHERE ManagerID='$ManagerID'";
							$result		= mysql_query($sql_query) or die(mysql_error()); $sql = mysql_query($query);  
    
        while ($row = mysql_fetch_array($query)){ 
        $MgrPhoto = $row['MgrPhoto'];
		}
		
		mysql_close($db_connect);
		
                            ?>    <? if (file_exists("../files/mainmanagerphoto/$MgrPhoto")) { ?><img src="../files/mainmanagerphoto/<?= $MgrPhoto ?>" width="200px" height="200px">
                                <? } ?><br/><br/><br/>
 New Manager Photo: 
 <input type="file" name="photo"><br> <br>  
 <input type="submit" value="Add"> 
 </form>


James Smith

bitsmed
Constraint Violating Yak Guru

406 Posts

Posted - 07/13/2014 :  12:17:38  Show Profile  Reply with Quote
This forum is for MS SQL Server. Your question will be best answered in MySQL or PHP forum.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

Sweden
30265 Posts

Posted - 07/13/2014 :  12:29:07  Show Profile  Visit SwePeso's Homepage  Reply with Quote
How is the path calculated? With the webserver as root?
I can see the path in the webpage is relative.



Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000