Ir para conteúdo
Fórum Script Brasil
  • 0

Adicionar vários ID's


cawbizinho

Pergunta

Estou realizando um painel de controle para a minha empresa. Mas, agora empaquei em como adicionar vários objetos no banco de dados.

Por exemplo:

Quando adiciono o link de um vídeo no checkbox o request.form pega com vírgula:

http://www.youtube.com/watch?v=JsujaaB4x4w, http://www.youtube.com/watch?v=l2mcdS6ioo8

Mas, quando adiciona na tabela noticia_video, cria somente uma ID com a linha completa. Veja imagem:

noticia_video.jpg

Porém, eu desejaria adicionar cada link em diferentes ID's. Veja imagem (Feita manualmente):

noticia_video2.jpg

Abaixo está o código fonte da conexão e INSERT INTO:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>

<!--#include virtual="/thyago/Connections/Arquivos.asp" -->

<!--#include virtual="/thyago/Connections/Noticia.asp" -->

<%

Dim MM_editAction

MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))

If (Request.QueryString <> "") Then

MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)

End If

' boolean to abort record edit

Dim MM_abortEdit

MM_abortEdit = false

%>

<%

' IIf implementation

Function MM_IIf(condition, ifTrue, ifFalse)

If condition = "" Then

MM_IIf = ifFalse

Else

MM_IIf = ifTrue

End If

End Function

%>

<%

If (CStr(Request("MM_insert")) = "form4") Then

If (Not MM_abortEdit) Then

' execute the insert

Dim MM_editCmd

Set MM_editCmd = Server.CreateObject ("ADODB.Command")

MM_editCmd.ActiveConnection = MM_Noticia_STRING

MM_editCmd.CommandText = "INSERT INTO noticia_video (link, titulo) VALUES (?, ?)"

MM_editCmd.Prepared = true

MM_editCmd.Parameters.Append MM_editCmd.CreateParameter ("param1", 203, 1, 536870910, Request.Form("link")) ' adLongVarWChar

MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 203, 1, 536870910, Request.Form("titulo")) ' adLongVarWChar

MM_editCmd.Execute

MM_editCmd.ActiveConnection.Close

' append the query string to the redirect URL

Dim MM_editRedirectUrl

MM_editRedirectUrl = "add_video.asp"

If (Request.QueryString <> "") Then

If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0) Then

MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString

Else

MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString

End If

End If

Response.Redirect(MM_editRedirectUrl)

End If

End If

%>

<!--#include virtual="/thyago/inc/conexao_arquivo.asp" -->

<%

confirmation = request.QueryString("confirmation")

key_acesso = request.QueryString("identidade")

%>

<%

Dim Video

Dim Video_cmd

Dim Video_numRows

Set Video_cmd = Server.CreateObject ("ADODB.Command")

Video_cmd.ActiveConnection = MM_Arquivos_STRING

Video_cmd.CommandText = "SELECT * FROM video ORDER BY id DESC"

Video_cmd.Prepared = true

Set Video = Video_cmd.Execute

Video_numRows = 0

%>

<%

Dim Noticia

Dim Noticia_cmd

Dim Noticia_numRows

Set Noticia_cmd = Server.CreateObject ("ADODB.Command")

Noticia_cmd.ActiveConnection = MM_Noticia_STRING

Noticia_cmd.CommandText = "SELECT * FROM noticia"

Noticia_cmd.Prepared = true

Set Noticia = Noticia_cmd.Execute

Noticia_numRows = 0

%>

<%

Dim HLooper1__numRows

HLooper1__numRows = 9

Dim HLooper1__index

HLooper1__index = 0

Video_numRows = Video_numRows + HLooper1__numRows

%>

<%

confirmation = request.QueryString("confirmation")

%>

Abaixo está o restante do código fonte da página:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Painel de Controle - Mainardes Comunicações</title>

<style type="text/css">

<!--

body {

margin-left: 0px;

margin-top: 0px;

margin-right: 0px;

margin-bottom: 0px;

}

#tabela_video {

height: 162px;

width: 20px;

}

-->

</style>

<link href="log_acesso.css" rel="stylesheet" type="text/css" />

<link href="css_links.css" rel="stylesheet" type="text/css" />

<style type="text/css">

<!--

.style2 {font-size: 16px}

.style3 {

color: #0000FF;

font-weight: bold;

}

.style6 {color: #FFFFFF}

.style7 {font-size: 24px}

.style9 {color: #FFFFFF; font-size: 18px; }

.style12 {color: #000000; }

a:link {

text-decoration: none;

color: #0099FF;

}

a:visited {

text-decoration: none;

color: #0066FF;

}

a:hover {

text-decoration: underline;

color: #0066FF;

}

a:active {

text-decoration: none;

color: #0099FF;

}

a {

font-weight: bold;

font-size: 14px;

}

.style16 {font-size: 16px; color: #000000; }

.style21 {font-size: 10px}

.style22 {color: #666666}

.style23 {font-size: 14px}

.style24 {font-size: 36px}

.style25 {font-size: 36}

.style15 {color: #FF0000}

.style19 {color: #0033CC}

#site #lateral_direito .tabela tr th table tr td table tr td div table tr td #form4 table tr td div table tr td div table tr td label {

text-align: center;

}

#site #lateral_direito .tabela tr th table tr td table tr td div table tr td #form4 table tr td div table tr td table tr td label {

text-align: center;

}

.style18 {color: #009900}

-->

</style>

<%

linkpagina=("thyago/visualizar_arquivos")

%>

</head>

<body>

<div id="site">

<div id="tabela"></div>

<!--#include virtual="/thyago/inc/botao_lateral.asp" -->

<div id="lateral_direito">

<table width="100%" border="0" cellpadding="0" cellspacing="0" class="tabela">

<tr>

<th height="25" bgcolor="#E9E9E9" scope="row"><div align="left">

<table width="100%" border="0" cellspacing="0" cellpadding="0">

<tr>

<th width="2%" scope="row"> </th>

<td width="98%" class="style3 texto">Adicionar Notícia </td>

</tr>

</table>

</div></th>

</tr>

<tr>

<th height="25" scope="row"><table width="100%" border="0" cellspacing="2" cellpadding="2">

<tr>

<td><table width="100%" border="0" cellpadding="0" cellspacing="0">

<tr>

<td valign="top"><div align="center">

<table width="100%" height="100%" border="0" align="center" cellpadding="0" cellspacing="0">

<tr>

<td height="25" align="center" valign="top" class="titulos"> </td>

</tr>

<tr>

<td valign="top"><p>

<%

acao = request.querystring("acao")

If IsEmpty(acao) or acao = "" then

%>

</p>

<form ACTION="<%=MM_editAction%>" METHOD="POST" id="form4" name="form4">

<table width="100%" border="0" cellpadding="0" cellspacing="0">

<tr>

<td><div align="center">

<table width="100%" border="0" cellpadding="0" cellspacing="0">

<tr>

<td><table width="100%" border="0">

<tr>

<td><table align="center">

<%

startrw = 0

endrw = HLooper1__index

numberColumns = 3

numrows = 3

while((numrows <> 0) AND (Not Video.EOF))

startrw = endrw + 1

endrw = endrw + numberColumns

%>

<tr align="center" valign="top">

<%

While ((startrw <= endrw) AND (Not Video.EOF))

%>

<td><table width="200" border="0" align="center" cellpadding="0" cellspacing="0">

<tr>

<td width="17" height="162" valign="bottom"><label>

<input name="link" type="checkbox" id="link" value="<%=Video("documento")%>" />

</label></td>

<td width="200" height="162"><object width="200" height="162"><param name="movie" value="<%=Video("documento")%>"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="<%=Video("documento")%>" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="200" height="162"></embed></object></td>

</tr>

</table></td>

<%

startrw = startrw + 1

Video.MoveNext()

Wend

%>

</tr>

<%

numrows=numrows-1

Wend

%>

</table></td>

</tr>

<tr>

<td><table width="253" border="0" align="center">

<tr>

<td width="17%"><input type="submit" name="button2" id="button2" value="Selecionar Todos" /></td>

<td width="19%"><input type="submit" name="button3" id="button3" value="Deselecionar Todos" /></td>

</tr>

</table>

<table width="218" border="0" align="center">

<tr>

<td width="15%"><table width="100%" border="0" cellpadding="0" cellspacing="0">

<tr>

<td><input type="submit" name="button4" id="button4" value="Página Anterior" /></td>

</tr>

</table></td>

<td width="85%"><table width="100%" border="0" cellpadding="0" cellspacing="0">

<tr>

<td><input type="submit" name="button5" id="button5" value="Página Anterior" /></td>

</tr>

</table></td>

</tr>

</table></td>

</tr>

<tr>

<td><table width="89" border="0" align="center" cellpadding="0" cellspacing="0">

<tr>

<td><input name="button" type="submit" class="botao" id="button" value="Adicionar" /></td>

</tr>

</table>

<input name="titulo" type="hidden" id="titulo" value="<%request.querystring("titulo")%>" /></td>

</tr>

</table></td>

</tr>

</table>

</div></td>

</tr>

</table>

<input type="hidden" name="MM_insert" value="form4" />

</form>

<p>

<% end if

if acao = ("videoadicionado") then

%>

</p>

<table width="283" height="50" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#F0f0f0">

<tr>

<td align="center" valign="middle"><table width="281" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF">

<tr>

<td width="72"><img src="/thyago/biblioteca/My Videos44.png" width="64" height="64" /></td>

<td width="235" bgcolor="#F5F5F5"><div align="center" class="style16"><font face="Verdana"><span class="style18"><b>Vídeo

Adicionado <strong>com sucesso!</strong></span></font></div></td>

</tr>

</table></td>

</tr>

</table>

<p> </p>

<p> </p>

<p><%end if%></p>

<table width="100%" border="0" cellspacing="2" cellpadding="2">

<tr>

<td><a href="visualizar_arquivos.asp" class="alterar style21"><font color="#999999" face="Arial, Helvetica, sans-serif"><strong><font color="#666666"><<

VOLTAR</font></strong></font></a></td>

</tr>

</table></td>

</tr>

<tbody>

</tbody>

</table>

</div></td>

</tr>

</table></td>

</tr>

</table></th>

</tr>

</table>

<table width="100%" border="0" cellpadding="0" cellspacing="0" class="tabela_baixo">

<tr>

<th scope="row"><table width="100%" border="0" cellspacing="0" cellpadding="0">

<tr>

<td> </td>

</tr>

</table></th>

</tr>

</table>

</div>

</div></div>

</div>

<div id="rodape2">

<table width="100%" height="10" border="0" cellpadding="0" cellspacing="2">

<tr>

<th class="texto style4 style7" scope="row"><div align="center" class="texto_rodape">Dúvidas entre em contato: (41) 3039-8504 </div></th>

</tr>

<tr>

<th height="2" bgcolor="#E5E5E5" class="texto style4 style7" scope="row"> </th>

</tr>

</table>

<table width="100%" border="0" cellspacing="0" cellpadding="0">

<tr>

<th scope="row"><div align="center" class="texto">Copyright 2009. Todos os Direitos Reservados. </div></th>

</tr>

<tr>

<th height="10" scope="row"></th>

</tr>

</table>

</div>

</body>

</html>

<%

Video.Close()

Set Video = Nothing

%>

<%

Noticia.Close()

Set Noticia = Nothing

%>

Estou no aguardo,

Obrigado!

Link para o comentário
Compartilhar em outros sites

1 resposta a esta questão

Posts Recomendados

  • 0

você ta fazendo isso no DreamWeaver certo? Inclusive no que compete a construção de códigos, correto?

Eis o problema... o dreamweaver é uma m*** pra fazer isso... eu particularmente uso só para autocompletar algumas tags, ou colorir o código... organizar pastas e etc... mas de resto não uso porque realmente é muito ruim...

Fica bem complicado achar um só problema... recomendaria uma reestruturada geral aí!

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,1k
    • Posts
      651,8k
×
×
  • Criar Novo...