Jump to content

Add, Delete SQL


PF2G

Recommended Posts

hi i'm new at SQL so i'm working on a website where i add info and delete.

 

The delete part i want a message box to confirm if i really want to delete the info:

 

<!---------------------------------------------->
		<script type="text/JavaScript">
			function confirmDelete()
			{
				var agree=confirm("Tem a certeza que quer remover?");

				if (agree)
				{
					 return true;
				}
				else
				{
					 return false;
				}
			}
		</script>
		<!---------------------------------------------->

 

In the add.php:

 

<?PHP
include 'db_connect.php';

$query_ident="SELECT * FROM content";
$ident=mysql_query($query_ident, $connect);
$row_ident=mysql_fetch_assoc($ident);
?>

<html>
<head>
	<title>Administração - Adicionar</title>
</head>

<body style="color:#FFFFFF;" bgcolor="#666666">
<form action="" method="POST">
	<table>
		<tr>
			<td align="right">
				Identificador: 
			</td>

			<td>
				<select name="identifier">
					<?PHP do{ ?>
						<option value="<?PHP echo $row_ident['id_content']; ?>">
							<!--selcciona opção definida-->
							<?PHP echo $row_ident['identifier']; ?>
						</option>
					<?PHP } while ($row_ident=mysql_fetch_assoc($ident)); ?>
				</select>
			</td>
		</tr>

		<tr height="10px"></tr>

		<tr>
			<td align="right">
				Linguagem:
			</td>

			<td>
				<select name="lang">
					<option value="1"> Português </option>
					<option value="2"> Inglês </option>
				</select>
			</td>
		</tr>

		<tr height="10px"></tr>

		<tr>
			<td align="right">
				Título:
			</td>

			<td>
				<input type="text" name="titulo">
				</input>
			</td>
		</tr>

		<tr height="10px"></tr>

		<tr>
			<td align="right" valign="top">
				Conteúdo:
			</td>

			<td>
				<textarea name="descricao" cols="50" rows="10"></textarea>
			</td>
		</tr>

		<tr>
			<td></td>

			<td>
				<input type="submit" name="adicionar" value="Adicionar Informação" />
				<a href="javascript:history.go(-1);"><input type="button" name="update" value="Voltar"/></a>
			</td>
		</tr>
	</table>
</form>
</body>
</html>

<?PHP
/*************************************************/	
if (isset($_POST['adicionar']))
{
$identifier=$_POST['identifier'];
$lang=$_POST['lang'];
$titulo=$_POST['titulo'];
$descricao=$_POST['descricao'];

$sel_ident="SELECT * FROM content WHERE identifier='".$identifier."'";
$ident=mysql_query($sel_ident, $connect);
$row_ident=mysql_fetch_assoc($ident);

$sel_id="SELECT * FROM content_lang WHERE id_content='".$row_ident['id_content']."'";
$id=mysql_query($sel_id, $connect);
$row_id=mysql_fetch_assoc($id);


if($add_info=mysql_query("INSERT INTO content_lang (id_content, lang, titulo, descricao) VALUES ('".$row_id['id_content']."', '".$lang."', '".$titulo."', '".$descricao."')"))
{
	echo 'Adicionado com sucesso.';
}
else
{
	echo 'Informação não foi inserida devido a um problema no sistema.';
}
}	
?>

 

It gives me the second message, it means that the info wasn't inserted.

 

Can someone help me?

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.