Jump to content

moreira

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Everything posted by moreira

  1. anyone knows if i use session start that will save my get[pesquisa] to the nexte page? Best regards, Moreira
  2. ok, let see if is that that you want: <?php $connection = mysql_connect("host", "username", "password") or die(mysql_error()); //Connection to the database. Error out if the connection fails for @mysql_select_db('yourdatabasename'); //Select the database $query = mysql_query("SELECT * FROM tablename WHERE id = 7"); $row = mysql_fetch_array($query); echo "<h1>" . $row['description'] . "</h1>"; ?> In this example, let supose that your column3 name is "description" and the 3rd row of your table have the id 7 hope i'v been useful. Best regards, Moreira
  3. I need some help. I've created a search bar (search.php) that submit the result (resultado.php). Everthing is ok, except the pagination! Results on first page good but the links for the other pages not good (it seems that looses the input information) "Notice: Undefined index: pesquisa in resultado.php on line 6". I tried to work with session but whitout sucess. Can anybody help? the search.php: <table width="200" border="0" align="center" valign="top"> <tr> <td><div align="center"><form id="form1" name="form1" method="get" action="search.php"> <label for="textfield"></label> <input name="pesquisa" type="text" id="pesquisa" value="pesquisar por..." size="26" /> </form> </td> and the resultado.php: <?php include("classes/Pagination.php"); include("classes/config.php"); $dbc = @mysqli_connect(localhost, root, mifa, ocorredorcms); $keyword = trim($_GET['pesquisa']) ; $keyword = mysqli_real_escape_string($dbc, $keyword); //PAGINATION SETTINGS //the pagination requires the total amount of articles $total_records = mysql_num_rows(mysql_query("SELECT * FROM cms_content where title like '%$keyword%' or body like '%$keyword%' or category like '%$keyword%'")); $page = 1; $size = 3; if (isset($_GET['page'])){ $page = (int) $_GET['page']; } //Pagination class $pagination = new Pagination(); //here we use the variable $siteurl which is defined in the configuration.php, should you ever use mod_rewrite to rewrite your url's //it would be a good idea to add the $siteurl variable to your urls, same for images or links to your styles and scripts $pagination->setLink("search.php?page=%s"); $pagination->setPage($page); $pagination->setSize($size); $pagination->setTotalRecords($total_records); //////////// $sql = mysql_query("SELECT * FROM cms_content where title like '%$keyword%' or body like '%$keyword%' or category like '%$keyword%' ". $pagination->getLimitSql()); $sql_num = mysql_num_rows($sql); //if the result of the function mysqli_num_rows IS null then show a message //when we store something into a variable we use = , but when we want to check/compare for something we use == or when comparing strings === if($sql_num == 0): //so if there is nothing show the message echo '<h2>Não foram encontrados resultados para: "'.$_GET['pesquisa'].'"</h2>'; else: //while there are rows print them on the screen if(isset($_GET['artigo'])){ $artigo_id = $_GET['artigo']; $query = mysql_query("SELECT * FROM cms_content WHERE id = {$artigo_id}"); $artigo = mysql_fetch_array($query); } else { $query = mysql_query("SELECT * FROM cms_content where title like '%$keyword%' or body like '%$keyword%' or category like '%$keyword%' ORDER BY id DESC ". $pagination->getLimitSql()); while($artigo = mysql_fetch_array($query)){ echo "<div class=\"artigo-info\">"; echo '<h2><a href="'.$artigo['category'].'.php?artigo='.$artigo['id']."\">" . $artigo['title'] . "</a></h2>"; echo '<p class="style4">' . $artigo['description'] . '</p>'; echo '<j10><a href="'.$artigo['category'].'.php?artigo='.$artigo['id']."\">" . "LER O ARTIGO COMPLETO >" . "</a></j10>"; echo "</div>"; } } $navigation = $pagination->create_links(); echo '<div align="center">' . $navigation . '</div>'; endif; ?> please help
×
×
  • 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.