Hi Guys,
I’m a bit stuck working on a PHP content management system that assigns a photograph with each profile I create.
Now I have my php page set-up so you can enter a variable called $firstname, and this data entered into the textbox is saved in MySQL database in a table called ‘profiles’ when you hit submit - (and it can be retrieved and modified) as shown below:
Now as you can see I also have an $image variable on this page. What I want to do is create an <option></option> drop down menu, which looks at a different table in MySQL database called ‘uploads’ which holds information on .jpg images uploaded to a folder.
Basically each .jpg uploaded has $name and $url data assigned to it in the ‘uploads’ table..
So I want the <option></option> drop down menu to do is:
- Return all $name of uploaded images in the dropdown
- Hit Submit
- The $URL to that image I have selected is held in the ‘profiles’ table
held in the $image variable.
But I have not got a clue how to do it – anybody help?
Thanks
Chris
I’m a bit stuck working on a PHP content management system that assigns a photograph with each profile I create.
Now I have my php page set-up so you can enter a variable called $firstname, and this data entered into the textbox is saved in MySQL database in a table called ‘profiles’ when you hit submit - (and it can be retrieved and modified) as shown below:
Code:
<?php
// login stuff
include("../ch.php");
include("../cm.php");
checklogin();
$firstname = "";
$image = "";
if(isset($_POST['Submit']))
{
$firstname = $_POST['firstname'];
$image = $_POST['image'];
if(!isset($_GET['profilesid']))
{
$result = mysql_query("Insert into profiles(firstname,image) values('$firstname','$image')");
$msg = "New record is saved";
}
else
{
$result = mysql_query("Update profiles set firstname='$firstname', image='$image' where profilesid=".$_GET['profilesid']);
$msg = "profiles Record is updated";
}
}
if(isset($_GET['profilesid']))
{
$result = mysql_query("Select * From profiles where profilesid=".$_GET['profilesid'],$link);
$row = mysql_fetch_array($result, MYSQL_BOTH);
$firstname = $row['firstname'];
$image = $row['image'];
}
?>
<html>
<head>
<title>Admin</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="../ssheet.css">
</head>
<body>
<div align="center"></div>
<form name="form1" method="post" action="">
<input name="firstname" type="text" id="firstname" value="<?php echo $firstname?>" size="36">
</form>
</body>
</html>
Now as you can see I also have an $image variable on this page. What I want to do is create an <option></option> drop down menu, which looks at a different table in MySQL database called ‘uploads’ which holds information on .jpg images uploaded to a folder.
Basically each .jpg uploaded has $name and $url data assigned to it in the ‘uploads’ table..
So I want the <option></option> drop down menu to do is:
- Return all $name of uploaded images in the dropdown
- Hit Submit
- The $URL to that image I have selected is held in the ‘profiles’ table
held in the $image variable.
But I have not got a clue how to do it – anybody help?
Thanks
Chris