trying to pass multiple row entries through a single select list.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • veriwide
    New Member
    • Jul 2012
    • 1

    trying to pass multiple row entries through a single select list.

    I'm fairly new to php. I am trying to get my php to send multiple fields from a database record row from a single drop down box selection. I can pass my image name"imgName", and I'd also like to be able to pass a pdf file name "pdfName" as well.
    Here is my select code:

    Code:
    <select name="imgName" onChange="chkFrm(this)">
                            <option value="" <?php if (!(strcmp("Choose", $_POST['imgName']))) {echo "selected";} ?>>Choose Proof Image</option>
                            <?php
          
          do {
    ?>
                            <option value="<?php echo $row_proofImages['imgName']?>"<?php if (!(strcmp($row_proofImages['id'], $_POST['imgName']))) {echo "selected";} ?>><?php echo $row_proofImages['imgName']?></option>
                            <?php
    } while ($row_proofImages = mysql_fetch_assoc($proofImages));
      $rows = mysql_num_rows($proofImages);
      if($rows > 0) {
          mysql_data_seek($proofImages, 0);
    	  $row_proofImages = mysql_fetch_assoc($proofImages);
      }
    ?>
                          </select>
  • Exequiel
    Contributor
    • Jul 2012
    • 288

    #2
    Code:
    <select name="imgName" onChange="chkFrm(this)">
                    	<?php
    					$id=$_GET['id'];
                            $query=mysql_query("Select * from tbl_images where id_name='$id'");
    							while($que=mysql_fetch_array($query))
    							{
    								echo '<option value="'.$que['imgName'].'"> '.$que['imgName'].'</option>';
    							}	
    					?>
                    
                    </select>
    This code is a sample on how to view records came from database to select tag....

    Comment

    • programDragon
      New Member
      • Jul 2012
      • 2

      #3
      What you might try is passing the variables with a char to separate them.
      Code:
      <select name="varPass" onChange="chkFrm(this)">
      <option value="<?php echo imgName . ':' . pdfName;?>"Choose Proof Image</option>
      Then in the processing page just split the variables by the ':'.

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        The normal operating procedure is to pass a unique key. Display it however you want in the select list, but pass the unique key. Then, when you need the rest of the information, you retrieve it by the key.

        Comment

        Working...