Results 1 to 1 of 1
  1. #1
    ivan_tkd1's Avatar
    Join Date
    Sep 2011
    Gender
    male
    Posts
    3
    Reputation
    10
    Thanks
    0

    im breaking my head with this source code in php

    hey people , i've a trouble with mysql Database , if i change these both variables ( $numreg and $inicial) for like 1 , 2 or whatever i name it , it works as well , but i want to let these both variables.Can someone help me please?

    i tried to do cast converstin and etc but it won't let me go so what's happenning ?

    Thank you very much!


    $selecionar = mysql_query("SELECT id,nome,area,cargo,salario,sexo,estado,cidade,
    deficiencia,descr,data FROM vaga WHERE id_emp='$id_emp' ORDER BY id DESC LIMIT
    $inicial,$numreg") or die (mysql_error('erro ao buscar dados, tente novamente' ));

    Edit this is the full source code


    <?php
    require_once("includes/conexao.php");
    if(isset($_POST['excluir']) )
    {
    $id_anuncio = $_GET ['id_anuncio'];
    $sql = "DELETE FROM vaga WHERE id=$id_anuncio AND id_emp='$empresa_id'";
    if ($sql)
    {
    echo "<script>window.alert('Vaga deletada!'); </script>";
    }
    else
    {
    echo "<script>window.alert('Erro ao deletar vaga. Tente novamente!'); </script>";
    }

    $numreg =3; // Quantos registros por página vai ser mostrado

    if (!isset($pg))
    {
    $_GET['$pg'] = 0;
    }
    $inicial = $_GET['pg'] * $numreg;
    $id_emp = $_SESSION [ 'EMPRESA_ID' ];
    }
    require_once("includes/conexao.php");

    $selecionar = mysql_query("SELECT id,nome,area,cargo,salario,sexo,estado,cidade,defi ciencia,descr,data
    FROM vaga WHERE id_emp='$id_emp' ORDER BY id DESC LIMIT ($numreg, $inicial)")
    or die ('Desculpe-nos pelo contra tempo, tente novamente mais tarde');
    if ($selecionar)
    {
    $sql_conta = mysql_query("SELECT id, nome, area, cargo, salario, sexo, estado, cidade, deficiencia, descr, data FROM vaga WHERE id_emp='$id_emp' ");
    $quantreg = mysql_num_rows($sql_conta);
    $quant_pg = ceil('$quantreg/$numreg');
    $quant_pg++; // Verifica se esta na primeira página, se nao estiver ele libera o link para anterior

    echo "<br>";
    if ( $pg > 0)
    {

    $local = "suas_vagas.php";
    }

    echo "<a href=".$local."?pg=".($pg-1) ." &busca=$busca class=pg><b>&laquo; anterior</b></a>";
    }
    else
    {
    echo "<font color=#CCCCCC>&laquo; anterior</font>";
    } // Faz aparecer os numeros das página entre o ANTERIOR e PROXIMO

    require_once("includes/conexao.php");

    for($i_pg=1;$i_pg<$quant_pg;$i_pg++)
    {
    // Verifica se a página que o navegante esta e retira o link do número para identificar visualmente
    if ($pg == ($i_pg-1))
    {
    echo " <span class=pgoff>[$i_pg]</span> ";
    }
    else
    {
    $i_pg2 = $i_pg-1;
    echo " <a href=".$local."?pg=$i_pg2&busca=$busca class=pg><b>$i_pg</b></a> ";
    }
    }
    // Verifica se esta na ultima página, se nao estiver ele libera o link para próxima
    if (($pg+2) < $quant_pg)
    {
    echo "<a href=".$local."?pg=".($pg+1)." &busca=$busca class=pg><b>próximo &raquo;</b></a>";
    echo "<font color=#CCCCCC>próximo &raquo;</font>";
    }
    else
    {
    echo " não ha mais vagas cadastradas!";
    }


    while ($resultado = mysql_fetch_array ($selecionar, MYSQL_BOTH) )
    {
    echo "<div style='margin-top:0px; width:890px; color:#757272'>";
    $id = $resultado[id];
    echo "<div style='float:left; margin-left:35px; width:200px'>";
    echo "<br>";
    echo "<b>nome</b>: $resultado[nome] </b><br>";
    echo "<hr>";
    echo "<b>data</b>: $resultado[data]<br>";
    echo "<b>área</b>: $resultado[area] <br>";
    echo "<b>cargo</b>: $resultado[cargo] <br>";
    echo "<b>salario</b>: $resultado[salario] <br>";
    echo "<b>Nº de vagas</b>: $resultado[qnt] <br>";
    echo "<br>";
    echo "$resultado[descr]<br>";
    echo "<br>";
    echo "<form method='post' action='vagas_editar.php?id_anuncio=$id'>";
    echo "<div style='float:left; margin-left:0px'>";
    echo "<input type='submit' name='editar' value='editar'>";
    echo "</form>";
    echo "</div>";
    echo "<form method='post' action='vagas_candidatos.php?id_anuncio=$id'>";
    echo "<div style='float:left; margin-left:10px;'>";
    echo "<input type='submit' name='editar' value='candidatos'>";
    echo "</form>";
    echo "</div>";
    echo "</div>";
    echo "</div>";
    }
    ?>
    Last edited by ivan_tkd1; 09-13-2011 at 07:20 AM.

Similar Threads

  1. Replies: 13
    Last Post: 02-22-2010, 10:59 AM
  2. My, NexoN Account Creator with Full Source Code!!
    By CodeHPro in forum Visual Basic Programming
    Replies: 22
    Last Post: 11-08-2009, 10:31 PM
  3. what is wrong with this source?
    By Petros in forum C++/C Programming
    Replies: 6
    Last Post: 07-04-2007, 04:33 PM
  4. wats wrong with this weapon code
    By CHECK2PASS in forum WarRock - International Hacks
    Replies: 3
    Last Post: 07-03-2007, 04:38 AM