Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    13
    Rep Power
    0

    CSV Resume page to detail page


    Hello,

    I have a script that allows me to show some field of my csv file:

    php Code:
    <?php     
    session_start();     
    $cat=array();     
    $fichier="ventes.csv";     
    $var=fopen("$fichier","r+" ); 	
    $counter = 0;	 	
    $ligne = fgets($var,4096);      
    while( !feof($var))     { 		      
    $ligne=fgets($var);      
    $partie=explode(";",$ligne);      
    $id=$partie[1]; 	 
    $img=$partie[2]; 	 
    $txt=$partie[6]; 	 
    $status=$partie[8];      
    if (!isset($_SESSION[$id])) 	       { 		 
    if ( $counter === 0 || $counter === 1 || $counter === 2){ 			  ?>           
    <div id="showcase"> <div class="stxt-bg"> 
    <h3><?php echo $id ?></h3> 
    <div class="smaltext">
    <a href="detail.php">
    <img src="<?php echo $img ?>.jpg" alt="" width="150" height="95" border="0"/>
    </a>  
    <div class="clear">
    </div>
    <?php echo $txt ?>
    </div> 
    <div style="clear:right; height:25px;"> 
    <span class="read-more">
    <?php echo $status ?>
    </span>
    </div> </div> </div> 
    <?php      
    ++$counter;      
    $_SESSION[$id]="aa"; 	      
    $_SESSION[$town]="aa"; } 	} 	 }     
    session_destroy();     ?>


    I wish I could click on a picture and the link shows the details of this line only.

    How?

    Thanks
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,502
    Rep Power
    594
    1) Please enclose your code in [ PHP ] tags. See the sticky at the top of this forum that says READ THIS BEFORE POSTING.

    2) Change your href to a page that generates the details page. Pass a parameter in the href URL that provides the necessary information, then test for that parameter and generate the page as appropriate.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    13
    Rep Power
    0
    Originally Posted by gw1500se
    1) Please enclose your code in [ PHP ] tags. See the sticky at the top of this forum that says READ THIS BEFORE POSTING. I change it

    2) Change your href to a page that generates the details page. Pass a parameter in the href URL that provides the necessary information, then test for that parameter and generate the page as appropriate.
    which parameter do I need to provide to select the second line to the detail page?

    I know normally I put something like detail.php?csv=data in the url and use $get['data'] in the detail page.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,502
    Rep Power
    594
    You can provide any parameter you want. It depends only on what you need to process the details page.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  8. #5
  9. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,908
    Rep Power
    6351
    You haven't written the page you need. Write a page that gives the details you need, and whatever information that page needs (like the ID of the row) should be the parameter you put in the link.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    13
    Rep Power
    0
    The page for the detail will be like this:

    PHP Code:
    <?php
        session_start
    ();
        
    $cat=array();
        
    $fichier="ventes.csv";
        
    $var=fopen("$fichier","r+" );
        
    $counter 0;    
        
    $ligne fgets($var,4096); 
        while( !
    feof($var))
        {
            
         
    $ligne=fgets($var);
         
    $partie=explode(";",$ligne);
         
    $id=$partie[1];
         
    $img1=$partie[2];
    $img2=$partie[3];
         
    $img3=$partie[4];
    $img4=$partie[5];
         
    $txt=$partie[7];
         
    $status=$partie[8];
         if (!isset(
    $_SESSION[$id]))
         
         {
                 
    ?>
    <div id="showcase"> 
    <div class="stxt-bg"> 
    <h3><?php echo $id ?></h3> 
    <div class="smaltext"> 
    <img src="<?php echo $img1 ?>.jpg" alt="" width="150" height="95" border="0"/>
    <img src="<?php echo $img2 ?>.jpg" alt="" width="150" height="95" border="0"/>
    <img src="<?php echo $img3 ?>.jpg" alt="" width="150" height="95" border="0"/>
    <img src="<?php echo $img4 ?>.jpg" alt="" width="150" height="95" border="0"/>
    <div class="clear"> </div> 
    <?php echo $txt ?> </div> 
    <div style="clear:right; height:25px;"> 
    <span class="read-more"> <?php echo $status ?> </span> 
    </div> </div> </div>
    <?php     
        
    }
         }
        
    session_destroy();
        
    ?>
    But how to set the link to chose whatever row?
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,502
    Rep Power
    594
    You can put the row in the parameter of the href that loads this page.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  14. #8
  15. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,908
    Rep Power
    6351
    Do you know how to use URL parameters?

    Make your link like this:
    Code:
    http://www.yoursite.com/someFile.php?id=123
    Then, in someFile.php, there will be an array automatically created by PHP called $_GET. Inside that array will be the values of all the "parameters" in the URL. So, in your code:
    PHP Code:
    echo $_GET['id']; 
    That will echo "123", as "123" is the value of "id" in the URL. You use this method to pass variables into PHP scripts and control their behavior.

    This is actually the primary purpose of PHP.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  16. #9
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    13
    Rep Power
    0
    I already know how to use the URL parameters but as I got multiple row the id of the row is unknow.
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,502
    Rep Power
    594
    Then how do you expect to select the details?
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  20. #11
  21. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,908
    Rep Power
    6351
    Write this down on paper. How would you identify these rows if you were going to tell another person about them? Would you say "the third row"? Would you say "the row where the 'name' column is 'Sherlock Holmes'"? Answer that question, then write code that does that to uniquely identify rows.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  22. #12
  23. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    13
    Rep Power
    0
    Let me explain.

    On one page I ask with PHP to display some column of the csv file until the end of file (eof), each column got an url and I want, when I click on the url, to go to another page to display all the column of this link.

    I got maybe 4 row, but eventualy I will have several other row.

    Here is some data of my csv file:

    Code:
    enregistrement;car name;img1;img2;intro;txt;
    
    1;Ford F-250 XLT Diesel;big_ford-f-250-2009;big_ford-f-250-2010;;2006<br>154 000km<br>Lorm ipsum;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi auctor sapien egestas
    
    2;Ford Mustang GT;big_mustang-001;big_mustang-002;Lorem ipsum b;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi auctor sapien egestas
    
    3;etc
    Thanks
  24. #13
  25. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,502
    Rep Power
    594
    I think we have a help vampire here.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  26. #14
  27. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    13
    Rep Power
    0
    Ok, I understand, you don't want to help, to understand
  28. #15
  29. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,908
    Rep Power
    6351
    On one page I ask with PHP to display some column of the csv file until the end of file (eof), each column got an url and I want, when I click on the url, to go to another page to display all the column of this link.
    This sentence was not valid English. Note you never refer to ROWS, only COLUMNS.

    Each ROW of this file has a unique identifier. It is the first column of the data (the first cell in every row). That is your ID.

    All of this should be in a database, anyway.

    Until you can explain why these solutions are not adequate in plain language, we cannot help you any more. I have explained it as deeply as it is possible to explain without simply doing the work for you. If you need more help than that, you should hire someone or perhaps find a forum in your native language.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo