Hi Guys,
I'm nearly there;
I have a form with the following code;
Now when I hit submit the text data is saved to the profiles table (fine and what I want) and a new record is created, but the image dropdown data i selected from the uploads table is not held.
What I want to do is go into each record when it is saved and see what image (from the dropdown) has been assigned.
Currently when I select an image from the dropdown hit submit, then go back later to modify it the dropdown data has not been held and it just says 'select an image' when I want the inital value I selected to be showing when I go to modify it.
Any ideas pleeaasee??
Many Thanks
Chris
I'm nearly there;
I have a form with the following code;
Code:
<?php
// login stuff
include("");
include("");
checklogin();
$msg = "";
$name = "";
$heading = "";
$position = "";
$signed = "";
$debut = "";
$dob = "";
$body = "";
if(isset($_POST['Submit']))
{
$name = $_POST['name'];
$heading = $_POST['heading'];
$position = $_POST['position'];
$signed = $_POST['signed'];
$debut = $_POST['debut'];
$goal = $_POST['goal'];
$dob = $_POST['dob'];
$body = $_POST['body'];
if(!isset($_GET['profilesid']))
{
$result = mysql_query("Insert into profiles(name,heading,position,signed,debut,goal,dob,body) values('$name','$heading','$position','$signed','$debut','$goal','$dob','$body')");
$msg = "New record is saved";
}
else
{
$result = mysql_query("Update profiles set name='$name', heading='$heading', position='$position', signed='$signed', debut='$debut', goal='$goal', dob='$dob', body='$body' 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);
$name = $row['name'];
$heading = $row['heading'];
$position = $row['position'];
$signed = $row['signed'];
$debut = $row['debut'];
$goal = $row['goal'];
$dob = $row['dob'];
$body = $row['body'];
}
?>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<form name="form1" method="post" action="">
<table width="100%" border="0">
<tr>
<td bgcolor="#FFFF00"><?php echo $msg?></td>
<td> </td>
</tr>
<tr>
<td>Name of Author:</td>
<td>
<select class="input" name="name" id="name">
<option value="Person 1"<? if ($name == 'Person 1') echo ' selected' ?>>Person 1
<option value="Person 2"<? if ($name == 'Person 2') echo ' selected' ?>>Person 2
</select>
</td>
</tr>
<tr>
<td>Player Name:</td>
<td>
<input name="heading" type="text" id="heading" value="<?php echo $heading?>" size="36">
</td>
</tr>
<tr>
<td>Position:</td>
<td>
<input name="position" type="text" id="position" value="<?php echo $position?>" size="36">
</td>
</tr>
<tr>
<td>Signed from:</td>
<td>
<input name="signed" type="text" id="signed" value="<?php echo $signed?>" size="36">
</td>
</tr>
<tr>
<td>Debut:</td>
<td>
<input name="debut" type="text" id="debut" value="<?php echo $debut?>" size="36">
</td>
</tr>
<tr>
<td>First Goal:</td>
<td>
<input name="goal" type="text" id="goal" value="<?php echo $goal?>" size="36">
</td>
</tr>
<tr>
<td>Date of Birth:</td>
<td>
<input name="dob" type="text" id="dob" value="<?php echo $dob?>" size="36">
</td>
</tr>
<tr>
<td>Body Text:</td>
<td>
<textarea name="textarea" id="body" cols="60" rows="20"><?php echo $body?></textarea>
</td>
</tr>
<tr>
<td>Select an Image:</td>
<td> <?php
if (isset($_POST['image'])){
$selected = $_POST['image'];
$selected_display = $_POST['image'];
} else {
$selected = "";
$selected_display = "select an image...";
}
echo "
<select name='image'>
<option selected value='$selected'> $selected_display </option>
";
$query = mysql_query("SELECT * FROM `uploads`");
while($reza = mysql_fetch_assoc($query)){
$name = $reza['name'];
$location = $reza['url'];
echo " <option value='$location'>$name</option>";
}
echo "</select>";
?></td>
</tr>
<tr>
<td> </td>
<td>
<div align="right">
<input type="submit" name="Submit" value="Submit" class="button">
<input type="reset" name="Reset" value="Reset" class="button">
</div>
</td>
</tr>
</table>
</form>
</body>
</html>
Now when I hit submit the text data is saved to the profiles table (fine and what I want) and a new record is created, but the image dropdown data i selected from the uploads table is not held.
What I want to do is go into each record when it is saved and see what image (from the dropdown) has been assigned.
Currently when I select an image from the dropdown hit submit, then go back later to modify it the dropdown data has not been held and it just says 'select an image' when I want the inital value I selected to be showing when I go to modify it.
Any ideas pleeaasee??
Many Thanks
Chris