Jump to content

Updating mySQL content via drop down menu in HTML


craigeves

Recommended Posts

in my PHP mySQL database i have a row called 'enablecontent'.

 

I want to be able to change a drop down box on my HTML page from 'yes' to 'no' and back again.

 

My code looks like this so far:

 

<select name=enablecontent><option value=1 <? if($row['enablecontent']==1) echo "selected";?>>Yes</option>
                <option value=0 selected <? if($row['enablecontent']==0);?>>No</option>
              </select>

 

But it does not update the mySQL for some reason.

 

Am I doing anything wrong. The rest of the content on the page connects to the database and updates the content.

 

Any help much appreciated.

 

Thanks

 

Craig

Here is my code. Thanks :)

 

<?php

session_start();

extract($_REQUEST, EXTR_OVERWRITE);

include ("func.php");



$uname= $_SESSION['uname'];

$upass= $_SESSION['upass'];



if(!auth_adm($uname, $upass)>0)

header('Location:logadm.php?err=1');

$sql="select photo_path,width from rsvp_set";
$rez=mysql_query($sql,$dblnk);
$row=mysql_fetch_array($rez);
$folder=$row['photo_path'];

$adminid=auth_adm($uname, $upass);
for ($num=1;$num<=1;$num++){

	@move_uploaded_file($_FILES['photo'.$num]['tmp_name'], "./".$folder."/photo1.jpg");
	//$photo1= $_FILES['photo'.$num]['name'];
	$photo1="photo.jpg";
	$image_path="./".$folder."/photo1.jpg";
	$thumb_path="./".$folder."/photo.jpg";
	$thumb_width=$row['width'];
	$thumb_height=0;
	createthumbnailjpg($image_path,$thumb_path,$thumb_width,$thumb_height);

}


$content=mysql_escape_string(stripslashes($content));

$date=$year."-".$month."-".$day;
$sql="update rsvp_set set regintro='$regintro', email_address='$email_address', content='$content', content2='$content2', content3heading='$content3heading', enablecontent='$enablecontent', content3='$content3',  heading='$heading',wedding_date='$date',photo='$photo1'";
$rez=mysql_query($sql,$dblnk);

header('location: edit_content.php');
?>

 

 

Set the variable to the value of the drop down:

 

<?php

session_start();

extract($_REQUEST, EXTR_OVERWRITE);

include ("func.php");



$uname= $_SESSION['uname'];

$upass= $_SESSION['upass'];

$enablecontent = $_POST['enablecontent']; //new line added here



if(!auth_adm($uname, $upass)>0)

header('Location:logadm.php?err=1');

$sql="select photo_path,width from rsvp_set";
$rez=mysql_query($sql,$dblnk);
$row=mysql_fetch_array($rez);
$folder=$row['photo_path'];

$adminid=auth_adm($uname, $upass);
for ($num=1;$num<=1;$num++){

	@move_uploaded_file($_FILES['photo'.$num]['tmp_name'], "./".$folder."/photo1.jpg");
	//$photo1= $_FILES['photo'.$num]['name'];
	$photo1="photo.jpg";
	$image_path="./".$folder."/photo1.jpg";
	$thumb_path="./".$folder."/photo.jpg";
	$thumb_width=$row['width'];
	$thumb_height=0;
	createthumbnailjpg($image_path,$thumb_path,$thumb_width,$thumb_height);

}


$content=mysql_escape_string(stripslashes($content));

$date=$year."-".$month."-".$day;
$sql="update rsvp_set set regintro='$regintro', email_address='$email_address', content='$content', content2='$content2', content3heading='$content3heading', enablecontent='$enablecontent', content3='$content3',  heading='$heading',wedding_date='$date',photo='$photo1'";
$rez=mysql_query($sql,$dblnk);

header('location: edit_content.php');
?>

it didn't work for some reason.... ??

 

Set the variable to the value of the drop down:

 

<?php

session_start();

extract($_REQUEST, EXTR_OVERWRITE);

include ("func.php");



$uname= $_SESSION['uname'];

$upass= $_SESSION['upass'];

$enablecontent = $_POST['enablecontent']; //new line added here



if(!auth_adm($uname, $upass)>0)

header('Location:logadm.php?err=1');

$sql="select photo_path,width from rsvp_set";
$rez=mysql_query($sql,$dblnk);
$row=mysql_fetch_array($rez);
$folder=$row['photo_path'];

$adminid=auth_adm($uname, $upass);
for ($num=1;$num<=1;$num++){

	@move_uploaded_file($_FILES['photo'.$num]['tmp_name'], "./".$folder."/photo1.jpg");
	//$photo1= $_FILES['photo'.$num]['name'];
	$photo1="photo.jpg";
	$image_path="./".$folder."/photo1.jpg";
	$thumb_path="./".$folder."/photo.jpg";
	$thumb_width=$row['width'];
	$thumb_height=0;
	createthumbnailjpg($image_path,$thumb_path,$thumb_width,$thumb_height);

}


$content=mysql_escape_string(stripslashes($content));

$date=$year."-".$month."-".$day;
$sql="update rsvp_set set regintro='$regintro', email_address='$email_address', content='$content', content2='$content2', content3heading='$content3heading', enablecontent='$enablecontent', content3='$content3',  heading='$heading',wedding_date='$date',photo='$photo1'";
$rez=mysql_query($sql,$dblnk);

header('location: edit_content.php');
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.