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

Link to comment
Share on other sites

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');
?>

 

 

Link to comment
Share on other sites

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');
?>

Link to comment
Share on other sites

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');
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.