DevilRock92
Suspenso
Boas
Eu estou a trabalhar num website onde faço a procura de um produto e faz a listagem de todos os resultados, depois acrescentei o Sortable para mover os produtos alterando a sua ordem e agora gostaria de guardar a ordem que eu altero, mas tou com dificuldades sera que alguem me pode ajudar?
Eu estou a trabalhar num website onde faço a procura de um produto e faz a listagem de todos os resultados, depois acrescentei o Sortable para mover os produtos alterando a sua ordem e agora gostaria de guardar a ordem que eu altero, mas tou com dificuldades sera que alguem me pode ajudar?
PHP:
<?php
require_once('Connections/futura.php');
?>
<?PHP
$prod=$_GET['q2'];
$query_prod="SELECT * FROM produtos WHERE nome LIKE '%".$prod."%'";
$produt=mysql_query($query_prod, $futura);
$count=mysql_num_rows($produt);
$prod_img="SELECT * FROM produtos WHERE nome LIKE '%". $prod ."%' ORDER BY ordem ASC";
$image=mysql_query($prod_img, $futura);
?>
<!----------------------------------------------------------------------------------------------------------------------->
<!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=utf-8" />
<link href="styles/style.css" rel="stylesheet" />
<title>Plásticos Futura - Pesquisa</title>
<link rel="shortcut icon" type="image/x-icon" href="imagens/plasticos.ico" />
<script type="text/javascript" src="js/java.js"></script>
<!-------------------------------------------------------------------------------------->
<link rel="stylesheet" href="jquery/themes/base/jquery.ui.all.css">
<script src="jquery/jquery-1.7.2.js"></script>
<script src="jquery/ui/jquery.ui.core.js"></script>
<script src="jquery/ui/jquery.ui.widget.js"></script>
<script src="jquery/ui/jquery.ui.mouse.js"></script>
<script src="jquery/ui/jquery.ui.sortable.js"></script>
<link rel="stylesheet" href="jquery/demos.css">
<style type="text/css">
#sortable
{
list-style-type: none;
margin: 0;
padding: 0;
width: 100%;
}
#sortable tr
{
font-size:12px;
margin: 0 3px 3px 3px;
padding: 0.4em;
padding-left: 1.5em;
height: 20px;
}
</style>
<script type="text/javascript">
$(function()
{
$("#sortable").sortable(
{
placeholder: 'ui-state-highlight',
stop: function(i)
{
placeholder: 'ui-state-highlight'
$.ajax(
{
type: "GET",
url: "updatedb.php",
data: $("#sortable").sortable("serialize")
});
}
});
$("#sortable").disableSelection();
});
</script>
<!---------------------------------------------------------------------------------------------------->
<?php
if (isset($_POST['do_submit']))
{
foreach($_GET['q2'] as $key=>$value)
{
mysql_query("UPDATE produtos SET ordem = '$key' WHERE id_produto ='$value';");
}
}
?>
</head>
<!---------------------------------------------------------------------------------------------------->
<body>
<table width="1200" border="0" align="center" cellpadding="0" cellspacing="0" style="background-image:url(imagens/fundo5.jpg);background-repeat:repeat-y;">
<tr>
<td>
<table width="1200" border="0" align="center" cellpadding="0" cellspacing="0" style="background-image:url(imagens/fundo3.jpg); background-repeat:no-repeat;" height="713" >
<tr>
<td height="60" valign="bottom"><?php include("topo.php"); ?></td>
</tr>
<tr>
<td height="613" valign="top"><table width="1200" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top"><table width="260" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="right"><a href="index.php" title="Voltar à homepage"><img src="imagens/plasticos-futura.png" border="0" /></a></td>
</tr>
<tr>
<td height="40"></td>
</tr>
<tr>
<td><table width="250" border="0" align="right" cellpadding="0" cellspacing="0">
<tr>
<td width="30"></td>
<td height="26" class="menu" onclick="window.location='index.php'"><a href="index.php" title="Home - Plásticos Futura" class="menu_text">Home</a></td>
</tr>
<tr>
<td height="2"></td>
<td height="2"></td>
</tr>
<tr>
<td width="30"></td>
<td height="26" class="menu" onclick="window.location='empresa.php'"><a href="empresa.php" class="menu_text" title="Empresa - Plásticos Futura">Empresa</a></td>
</tr>
<tr>
<td height="2"></td>
<td height="2"></td>
</tr>
<tr>
<td width="30"></td>
<td height="26" class="menu" onclick="window.location='produtos.php'"><a href="produtos.php" class="menu_text" title="Produtos - Plásticos Futura">Produtos</a></td>
</tr>
<tr>
<td height="2"></td>
<td height="2"></td>
</tr>
<tr>
<td width="30"></td>
<td height="26" class="menu" onclick="window.location='noticias.php'"><a href="noticias.php" class="menu_text" title="Notícias - Plásticos Futura">Notícias</a></td>
</tr>
<tr>
<td height="2"></td>
<td height="2"></td>
</tr>
<tr>
<td width="30"></td>
<td height="26" class="menu" onclick="window.location='oportunidades-de-negocio.php'"><a href="oportunidades-de-negocio.php" class="menu_text" title="Oportunidades de Negócio - Plásticos Futura">Oportun. Negócio</a></td>
</tr>
<tr>
<td height="2"></td>
<td height="2"></td>
</tr>
<tr>
<td width="30"></td>
<td height="26" class="menu" onclick="window.location='recrutamento.php'"><a href="recrutamento.php" class="menu_text" title="Recrutamento - Plásticos Futura">Recrutamento</a></td>
</tr>
<tr>
<td height="2"></td>
<td height="2"></td>
</tr>
<tr>
<td width="30"></td>
<td height="26" class="menu" onclick="window.location='contactos.php'"><a href="contactos.php" class="menu_text" title="Contactos - Plásticos Futura">Contactos</a></td>
</tr>
</table></td>
</tr>
</table></td>
<!----------------------------------------------------------------------------------------------------------------------->
<td width="638" valign="top" class="texto_pretobig2"><div class="bomfundo"><strong>RESULTADOS DA PESQUISA::</strong><br />
<br/>
<?PHP
if($count==0)
{
?>
<strong>Não foram encontrados resultados!</strong>
<?PHP
}
else
{
echo 'Encontrado(s) '.$count.' resultado(s) de pesquisa com a palavra "'. $prod .'":';
?>
<br/>
<br/>
<form method="POST" action="">
<table id="sortable" width="570" border="0" cellspacing="0" cellpadding="0" >
<?PHP
$i=0;
while ($linha = mysql_fetch_array($image))
{
?>
<?PHP
if ($i==0)
{
echo '<tr>';
}
?>
<tbody>
<?PHP
//MATERIAL
$query_categ_list = "SELECT * FROM materiais WHERE id_material='".$linha['id_material']."'";
$categ_list = mysql_query($query_categ_list, $futura) or die(mysql_error());
$row_categ_list = mysql_fetch_assoc($categ_list);
$totalRows_categ_list = mysql_num_rows($categ_list);
?>
<td colspan="2" class="div_topo"><a name="cat<?php echo $row_categ_list['id_material']; ?>"></a> <strong>PRODUTOS :: <span class="texto2"><?php echo $row_categ_list['material']; ?></span></strong></td>
<?PHP
//IMAGEM
$sel_img="SELECT * FROM produtos_img WHERE id_produto = '".$linha['id_produto']."'";
$img2=mysql_query($sel_img, $futura);
$img = mysql_fetch_assoc($img2);
?>
<tr>
<td width="160" height="95" valign="top"><a href="ver_produto.php?id_produto=<?php echo $linha['id_produto']; ?>&id_categoria=<?php echo $linha['id_material']; ?>"><?php if($img['imagem']!="") { ?><img src="
Está-me a dar erro o "foreach".
Obrigado e cumprimentos,
DevilRock92