Jump to content

bemax

Members
  • Posts

    13
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Male

bemax's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi, I'm trying to get data from one field in a table (database). But I get undesirable result: Here is my code -> <?php $result2 = mysql_query("SELECT DISTINCT theme FROM mytable ") or die(mysql_error()); while($row2 = mysql_fetch_array( $result2 )) { ?> <form method="post" action='<?php echo $_SERVER["PHP_SELF"]; ?>'> <select name='themes'"> <?php $arr= array($row2['theme']); foreach($row2 as $value) { echo "<option value='$value'><b>". $value."</b> </option><br> "; } } ?> The attached image file show the result that I don't wont. (It's not a dropdown). Is there anyone who may help me, I spent a lot of time to find out but I can't. Thanks a lot for your help [attachment deleted by admin]
  2. Hi, Can someone help me to find what is wrong in this. It doesn't give me things from my Database. <div id="centercontent"> <table border="0" width="100%" > <tr> <td> Montrer resultat <? if(isset($_POST['find'])) { $srch = $_POST["find"];// This is what I receive from an other page - I get it (no problem) //echo "$srch"; } // Make a MySQL Connection include( "sumba/conn.php"); // Get all the data from the "News_Nk" table $result = mysql_query("SELECT id,theme,titre,text,src FROM News_Nk WHERE titre='%$srch%'") or die(mysql_error()); $info = mysql_fetch_array( $result); while($info = mysql_fetch_array($result )) { Print "<b>Titre:</b> ".$info['titre'] . " "; Print "<b>Text:</b> ".$info['text'] . " <br>"; } ?> </td> </tr> </table> </div> Thanks in advance Bemax
  3. Can someone tell me what is wrong in this code! I tried many ways but it can't work. I want to get the variable $valg in my query. Here is the code: $valg= $_POST['valg']; /*$result = mysql_query("SELECT*FROM products WHERE nom= ' ".$valg." ' ") or die("SELECT Error: ".mysql_error());*/ /*$result = mysql_query("SELECT*FROM products WHERE nom= '.$valg.' ") or die("SELECT Error: ".mysql_error());*/ $row = mysql_fetch_assoc( $result ); $result = mysql_query(" SELECT * FROM products WHERE name='$valg' ") or die("SELECT Error: ".mysql_error()); while($row = mysql_fetch_assoc($result)) { echo $row['nom'] . " " . $row['taille']." ".$row['prix']." "; echo "<br />"; } Thanks Bemax
  4. Is someone who can help me; I'm trying to get an image from a folder and show it: Here is my code, logos is the directory; the problem is that I'm getting only the name of the image! $handle=opendir('../logos/'); while (false!==($file = readdir($handle))) { if ($file != "." && $file != "..") { echo "".$file."\n"; } } closedir($handle); Thanks
  5. Hi I'm working with php in my project at school. Now I have a problem, it's a system where I want the administrator to chose a logo from his computer and submit it. Then show it when registed persons login. I'm using Mysql - and I want load images in my database. Can someone help me with this code? Or if there is an other way I can get it help please! Thanks
  6. Thanks for your reply! It was very helpfull but i have an other question. I doing a pagination and I getting an error message witch is : Query failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '8, 4' at line 1 I cant realy find where is the mistake, could you please help me with this? Here is the code: <?php /* ////////////////////////////////////////// ////1) MySQL Database Connection /////////// ////////////////////////////////////////// */ $host = "localhost"; $user = "francine"; //$db_name= "yourdatabasename"; $db_name= "francine"; $pass= "123"; $conn = mysql_connect($host, $user, $pass) or die(mysql_error()); mysql_select_db($db_name, $conn) or die(mysql_error()); ?> <?php /* ////////////////////////////////////////////////// ////2) Get page number, if any ///////////////////////////////////////// ////// Prevent Injection Attack ///////// ////// Set $pageno variable ///////////// ///////////////////////////////////////// */ if(isset($_GET['pageno'])) { if(!is_numeric($_GET['pageno'])) { echo 'Error.'; exit(); } $pageno = $_GET['pageno']; } else { $pageno=1; } ?> <!-- ////////////////////////////////////////////////////////////////// //3) Calculate how many rows or records in total the query will output ///////////////////////////////////////////////////////////////// --> <?php $queryCount = 'SELECT count(*) FROM proverbes'; $resultCount = mysql_query($queryCount); $fetch_row = mysql_fetch_row($resultCount); $numrows = $fetch_row[0]; // if there is no results if($numrows == 0) { echo 'Sorry, we have no products yet.'; exit(); }?> <!-- /////////////////////////////////////////////////////////////// ///4) Calculate number of pages //////////////////////////////////////////////////////////////// --> <?php $perPage = 4; $lastpage = ceil($numrows/$perPage); $pageno = (int)$pageno; if($pageno<1) { $pageno=1; } elseif($pageno>$lastpage) { $pageno=$lastpage; } ?> <!-- //////////////////////////////////////////////////////////////// ///5) Generate page links //////////////////////////////////////////////////////////////// --> <?php // ----- PAGE LINKS ----- if($pageno==1) { $pages .= 'FIRST | PREVIOUS '; } else { $pages .= "<a href='{$_SERVER['PHP_SELF']}?pageno=1'>FIRST</a> | "; $prevpage=$pageno-1; $pages .= " <a href='{$_SERVER['PHP_SELF']}?pageno=$prevpage'>PREVIOUS</a> "; } $pages .= ' ( Page '.$pageno.' of '.$lastpage.' ) '; if($pageno==$lastpage) { $pages .= ' NEXT | LAST '; } else { $nextpage = $pageno+1; $pages .= " <a href='".$_SERVER['PHP_SELF']."?pageno=$nextpage'>NEXT</a> | "; $pages .= " <a href='".$_SERVER['PHP_SELF']."?pageno=$lastpage'>LAST</a>"; } ?> <!-- ///////////////////////////////////////////////////////////////// /////6) Calculate LIMIT clause for the MySQL query //////////////////////////////////////////////////////////////// --> <?php //$limit=' LIMIT '.($pageno-1)*$perPage.', '.$perPage; $limit=($pageno-1)*$perPage.', '.$perPage; ?> <!-- ////////////////////////////////////////////////////////////////// ////7) Run the query, echo the results and echo the page links ///////////////////////////////////////////////////////////////// --> <?php $query = $query.$limit; $result = mysql_query($query); if(!$result) { echo 'Query failed: '.mysql_error(); } else { while($row = mysql_fetch_array($result , MYSQL_NUM)) { echo $row['id'].' '.$row['theme'].' '.$row['proverbe'].' '.$row['explication'].' '.$row['nom'].'<br />'; //echo $row[0]; } } echo '<div style="width:100%; text-align: center; font-size: smaller; color: #999;">'.$pages.'</div>' ; echo ' Total number of products: '.$numrows; ?>
  7. I have an login system. Now I want the user to have the possibility to format the text before sending to database as he want. Something like what I have here where I sending this message. Example: Something like what I have here where I sending this message How can I do it in php?
  8. I have an login system. Now I want the user to have the possibility to format the text before sending to database as he want. Something like what I have here where I sending this message. Example: Something like what I have here where I sending this message How can I do it in php?
  9. I tried but I could not succed. The problem that I have 2 pages: navigation.php - where I have my form - this form has input=the word to search and an other parameter which specify where to search. search.php where I want to send the data(parameters) and display the result from database. This side is not visible in what I send to you. It's id=11 which is send from contents.php(here is a function with ids corresponding to every page). I think you understand my idea. The page navigation is on the right and when visitors put a word to search, this is send to search and here I will use the variables to get data from database.(This is not a big problem to me - only get my parameters in the search.php page from navigation.php) Here is the code of navigation.php <table> <tr> <td> <!--<form action="search.php?id='11' && $mot && $ou" method="post">--> <form action="contents.php?id=11 && par1={$mot} && par2= {$ou}" method="get"/> <p class="pUnderLine"><b class="asterisk">&#8727;</b> Recherche<br/> <input type="text" name="search"/><br/> <select name="fields"> <option value="Actualite">Actualité</option> <option value="Annonces">Annonces</option> <option value="Culture">Culture</option> <option value="Ecrivains">Ecrivains</option> <option value="Musique">Musique</option> <option value="Art">Art</option> <option value="Contes">Contes</option> </select> <input type="submit" name="submit" value="chercher"/> </p> </form> <?php if(isset($_POST['submit'])) { $mot = $_POST['name']; $ou = $_POST['fields']; echo $mot; echo $ou; } ?> </td> </tr> </table>
  10. Thanks Corbin; I'm trying with what you proposed to me(?var1=val1&var2=val2&var3=val3) but it doesen't work! Can you please try with my code and se what happen.
  11. Is anyone who kan show me how I can send more than 2 parameters to another page? I having trouble with this. I have a search in a page.( navigation.php). Here is a dropdown. I want to send the dropdow parameter with the search word to a page called (search.php) page. Here is the script I'm having problem with <form action="contents.php?id=11 & par1={$mot} & par2= {$ou}" method="post"> Recherche<br/> <input type="text" name="search"/><br/> <select name="fields"> <option>Actualité</option> <option>Annonces</option> <option>Culture</option> <option>Ecrivains</option> <option>Musique</option> <option>Art</option> <option>Contes</option> </select> <input type="submit" name="submit" value="chercher"/> </form> <?php if(isset($_POST['submit'])) { $mot = $_GET['name']; $ou = $_GET['fields'];
  12. Hi, Can someone help me???? I want to go to page with id 11 and at the same time send search and fields to that page! Here is how the code look like: <form action="contents.php?id=11" method="post"> <input type="text" name="search"/><br/> <select name="fields"> <option>Actualité</option> <option>Annonces</option> <option>Culture</option> </select> <input type="submit" name="submit" value="chercher"/> </p> </form>
×
×
  • 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.