Jump to content

Recommended Posts

I don't know where I'm going wrong on this sucker...

 

Want just a simple list: item in first column, photo of item in second column.

 

Photo of this code's output is attached below my post.

 

 

<?php $shopping_list = $_SESSION['wantlist'];
   ?> 
<?php
   echo "<pre>";
   print_r($shopping_list);
   echo "</pre>";
?>

<table width="300" border="1" cellpadding="20">
      <caption>
        My Bead Want List
      </caption>
      <?php 
      foreach ($shopping_list as $key_1 => $val) { 
         foreach ($val as $key_2 => $val_2) { echo('<tr>
            <td class="name">'.$shopping_list[$key_1][$key_2].'</td>
            <td class="thumbnail"><img width="87" height="87" src='.$shopping_list[$key_1][$key_2].' /></td>
           </tr>') ;
         }
      }
   ?>

 

I keep changing the code but can't get it to go through the array and pull out what I need, in the row and column I need it to be in.

 

[attachment deleted by admin]

<?php $shopping_list = $_SESSION['wantlist'];
   ?>
<?php
   echo "<pre>";
   print_r($shopping_list);
   echo "</pre>";
?>

<table width="300" border="1" cellpadding="20">
      <caption>
        My Bead Want List
      </caption>
      <?php 
      foreach ($shopping_list as $key_1 => $val) { 
         foreach ($val as $key_2 => $val_2) { echo('<tr>
            <td class="name">'.$shopping_list[$key_1][$key_2].'</td>
            <td class="thumbnail"><img width="87" height="87" src="'.$shopping_list[$key_1][$key_2].'" /></td>
           </tr>') ;
         }
      }
   ?>

 

i'm not sure it will work...

foreach ($shopping_list as $key_1 => $val) { 
         foreach ($val as $key_2 => $val_2) { echo('<tr>
            <td class="name">'.$key_2.'</td>
            <td class="thumbnail"><img width="87" height="87" src='.$val_2.' /></td>
           </tr>') ;
         }
      }

 

try that?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.