Results 1 to 6 of 6

Thread: Problem with putting image and positionning a div with an echo"div"

  1. #1
    Join Date
    Nov 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Problem with putting image and positionning a div with an echo"div"

    hi all, im new here and im new to php javascript also
    i would need a help

    what i want to do is to put a image and text from database so it can be like a news

    with a button play it show the next news

    i have trouble to display the image like it show below

    http://img219.imageshack.us/my.php?image=testjf6.jpg

    PROBLEM WITH DIV position is resolve

    Code:
    <html>
    <head>
    <title>Bibliothèque</title>
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
    <script type="text/javascript">
    var page_courante=1;
    var nb_pages=1;
    
    //Show previous page
    function pagePrecedente() {
       if (page_courante==1) {
          alert("Vous êtes déjà sur la première page !");
       } else {
          affichePage(page_courante-1);
       }
    }
    
    //show Next Page
    function pageSuivante() {
       if (page_courante==nbpages) {
          alert("Vous êtes déjà sur la dernière page !");
       } else {
          affichePage(page_courante+1);
       }
    }
    
    //show next page image text news and with a settimeout it change the news every 5 seconds
    function play() {
       if (page_courante==nbpages) 
       {
          alert("Vous êtes déjà sur la dernière page !");
       } else {
          affichePage(page_courante+1);
       }
       setTimeout(play(),5000);
    }
    
    //Show Page Function
    function affichePage (page){
       document.getElementById("page"+page_courante).style.display = "none";
       document.getElementById("lienpage"+page_courante).style.fontWeight = "normal";
       document.getElementById("page"+page).style.display = "block";
       document.getElementById("lienpage"+page).style.fontWeight = "bold";
       page_courante=page;
    
    }
    </script>
    
    </head>
    <body>
    <?php
    
    //connect to the database
    $connection = mysql_connect("localhost","root","") or die("impossible de se connecter au serveur mysql.<p>Veuillez réessayer plus tard");
    $res = mysql_select_db("test") or die("impossible de sélectionner la base de données <b>ecole</b>.<p>Veuillez réessayer plus tard");
    
    
    //request path textNouvelle Fields with a select
    $requeteStr = "SELECT path,textNouvelle from upload2";
    $resultatRequete = mysql_query($requeteStr) or die("la requete de sélection a échoué.<p>Veuillez réessayer plus tard");
    $resultat=mysql_query($requeteStr);
    $cpt = mysql_num_rows($resultat);//number of result from the request
    $rpp = 1;//Nombre de résultats à afficher par page
    $nbpages = ceil($cpt / $rpp);//calculate numbers of page
    $cpt2 = 0;//limit the number of results per page
    $cpt3 = 0;//tell us when all data has been view
    $cpt4 = 1;//send an id for every div id=\"page".$cpt4."\"
    
    
       for ($i=1; $i<=$nbpages; $i++) {
          echo " <a href=\"#\" id=\"lienpage".$i."\"></a>";
        
       }
     
    
    
    //Show divs
    while($ligne=mysql_fetch_array($resultat)){
       if ($cpt2 == 0) {
          if ($cpt4 == 1) //Lors de la requète, on affiche les premiers enregistrements
             echo "<div id=\"page1\" style=\"display: inline;\">";
           else //Ensuite, les enregistements suivants sont cachés
             echo "<div id=\"page".$cpt4."\" style=\"display: none; position:absolute; top:100; left:140;\">";since the div contains the table i would like to put the div in a certain position on the page, but this aint working atm with the top left...
          
          echo "<table border=\"1\"><tr><td><b>Titre</b></td></tr>";//affichage de la légende
          $cpt4++;
       }
       $cpt2++;
       $cpt3++;
       echo "<tr><td>".$ligne["textNouvelle"]."<img src=".$ligne["path"]."></td></tr>";//Affichage des enregistrements]
       if ($cpt2 == $rpp || $cpt3 == $cpt) {//Lorsque l'on affiché rpp enregistrements ou que tous les enregistrements ont été affichés, on ferme le calque
          echo "</table></div>";
          $cpt2 = 0;
       }
    }
    ?>
    
    <button onClick="pagePrecedente()">Page précédente</button>
    <button onClick="pageSuivante()">Page suivante</button>
    <button onClick="play()">Play</button>
    <script type="text/javascript">
       var nbpages=<?php echo $nbpages;?>
    </script>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    </body>
    </html>
    this is the table im working with
    CREATE TABLE upload2 (
    id INT NOT NULL AUTO_INCREMENT,
    name VARCHAR(30) NOT NULL,
    type VARCHAR(30) NOT NULL,
    size INT NOT NULL,
    path VARCHAR(60) NOT NULL,
    textNouvelle VARCHAR(120) NOT NULL,
    PRIMARY KEY(id)
    );

    http://img219.imageshack.us/my.php?image=imagescv5.jpg
    the path in the database is all fine

    so i dunno why the image aint showing right

    ty for the help in advance hope someone will help me out

    p.s. i know my english aint the best lol so if im not clear let me know so we can discuss about it
    Last edited by nicnicnic; 11-14-2008 at 05:50 AM.

  2. #2
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    1,160
    Thanks
    17
    Thanked 277 Times in 275 Posts

    Default

    Try to echo that line of the source:
    PHP Code:
    echo $ligne["path"]; 
    Now check if that is you're expected output.
    Learn how to code at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph!

  3. #3
    Join Date
    Nov 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default hi rangana

    ty to have reply
    well i try it but this it

    i show you where i put the new change dunno if its where i need to put it ? but when i do this its shows me just the results
    of the path name like i show it in the screenshot

    it shows D:\lol\Autumn_Leaves.jpg

    http://img219.imageshack.us/my.php?i...aaaaawalo2.jpg

    p.s. i know i will have to change the button place i didnt have time to do it yet

    so i really dunno how to resolve this problem, thats why im asking for help
    and ty to take your time to help me i really appreciate it
    hope you can help me out


    while($ligne=mysql_fetch_array($resultat))
    {
    if ($cpt2 == 0) {
    if ($cpt4 == 1) //Lors de la requète, on affiche les premiers enregistrements
    echo "<div id=\"page1\" style=\"display: inline; position:absolute; top:100; left:140;\">";
    else //Ensuite, les enregistements suivants sont cachés
    echo "<div id=\"page".$cpt4."\" style=\"display: none; position:absolute; top:100; left:140;\">";


    echo $ligne["path"];


    echo "<table border=\"1\"><tr><td><b>Titre</b></td></tr>";//affichage de la légende
    $cpt4++;
    }
    $cpt2++;
    $cpt3++;
    echo "<tr><td>".$ligne["textNouvelle"]."<img src=".$ligne["path"]."></td></tr>";//Affichage des enregistrements
    if ($cpt2 == $rpp || $cpt3 == $cpt) {//Lorsque l'on affiché rpp enregistrements ou que tous les enregistrements ont été affichés, on ferme le calque
    echo "</table></div>";
    $cpt2 = 0;
    }
    }
    Last edited by nicnicnic; 11-14-2008 at 05:30 AM.

  4. #4
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    1,160
    Thanks
    17
    Thanked 277 Times in 275 Posts

    Default

    Does that image exist on that said folder?

    The generated source is D:\lol\Autumn Leaves.jpg and not D:\lol\Autumn_Leaves.jpg
    Learn how to code at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph!

  5. #5
    Join Date
    Nov 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default hi:)

    yeah i upload the files into this folder

    http://img221.imageshack.us/my.php?i...nleavesmr9.jpg

    i move the file to this folder with move_upload_file


    this is my upload.php file to load the file in the mysql phpmyadmin database
    PHP Code:
    <?php
    $uploadDir 
    'D:\\lol\\';

    if(isset(
    $_POST['upload']))
    {
    $fileName $_FILES['userfile']['name'];
    $tmpName $_FILES['userfile']['tmp_name'];
    $fileSize $_FILES['userfile']['size'];
    $fileType $_FILES['userfile']['type'];

    $filePath $uploadDir $fileName;

    $result move_uploaded_file($tmpName$filePath);

    $fileName addslashes($fileName);
    $filePath addslashes($filePath);


    $texteNouvelle $_POST['texteNouvelle'];


    $connection mysql_connect("localhost","root","") or die("impossible de se connecter au serveur mysql.<p>Veuillez réessayer plus tard");
    $res mysql_select_db("test") or die("impossible de sélectionner la base de données <b>ecole</b>.<p>Veuillez réessayer plus tard");
    $requeteStr "INSERT INTO upload2 (name, size, type, path,textNouvelle ) "."VALUES ('$fileName', '$fileSize', '$fileType', '$filePath','$texteNouvelle')";
    $resultatRequete mysql_query($requeteStr) or die("la requete de sélection a échoué.<p>Veuillez réessayer plus tard");
    $result=mysql_query($requeteStr); 

    }
    ?>
    Code:
    <form action="" method="post" enctype="multipart/form-data" name="uploadform">
      <table width="350" border="0" cellpadding="1" cellspacing="1" class="box">
        <tr> 
          <td width="246" style="height: 95px"><input type="hidden" name="MAX_FILE_SIZE" value="2000000"><input name="userfile" type="file" class="box" id="userfile">
    		<br>
    		<br>
    		<textarea name="texteNouvelle" style="width: 263px; height: 61px"></textarea><br>
    		<br>
    		<br>
    		 </td>
          <td style="height: 95px; width: 51px" class="style1"><input name="upload" type="submit" class="box" id="upload" value="  Upload  "></td>
        </tr>
      </table>
    </form>
    $uploadDir = 'D:\\lol\\';

    is my two \\ slashes right ?

    $fileName = addslashes($fileName);
    $filePath = addslashes($filePath);

    and addslashes too ? im wondering if thats correct now

    i wish so hard this image thing can be resolve its giving me a headeache... and ty for ur time again

    i can do some research of my news with a select like query

    but without showing the image its sucks ...
    Last edited by nicnicnic; 11-14-2008 at 05:51 AM.

  6. #6
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    1,160
    Thanks
    17
    Thanked 277 Times in 275 Posts

    Default

    It appears to be confusing now. Why would you move the file? Do you have a link instead?

    The slashes seem right.

    Are you using a cross-platform web server like XAMPP or WAMPP?
    Learn how to code at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •