Jump to content

Ill Donate $100.00 to PHPFreaks.com if someone can step me this problem.


phpretard

Recommended Posts

I know I have been asking this question in different ways for most of the day.  Well, I feel someone should be compensated for the fantastic help I have received thus far.  I'll probably donate it anyway but I would like some more help.  By the way...I am not charging my neighbor for this site.  The money will come from my pocket.

 

Basically I need to allow someone to order different photos indicating the size and quantity.

 

I think I have most of the code done.  I am stuck with the sessions information being stored and displayed properly.

 

 

this takes you to the ordering page with a photo selected:

http://www.rememberthetimephotos.com/index.php?page=forms/order&picture=ALBUMS/FLM-MINC/P1090702.jpg&BM=P1090702.jpg

 

this takes you to the photo select page...CLICK ON A PHOTO TO GO TO THE ORDRING PAGE.

http://www.rememberthetimephotos.com/index.php?page=albums/get_album&event=Sports&loc=FLM-MINC&name=Fondville%20Lewis%20Foote%20and%20Messer%20vs%20M%20Inc.

Link to comment
Share on other sites

This code is executed when you submit the order form ... THANK YOU KEN:

<?php


if (isset($_POST['order_photo'])) {

$file = array();

$file[0] = $_POST['S46'];
$file[1] = $_POST['QU46'];
$file[2] = $_POST['S57'];
$file[3] = $_POST['QU57'];
$file[4] = $_POST['S810'];
$file[5] = $_POST['QU810'];
$file[6] = $_POST['file'];
$file[7] = $_POST['picture'];

foreach($file as $val){

    $_SESSION[$val] = $val;
}

}

header( 'Location: http://www.rememberthetimephotos.com/index.php?page=checkout&BM=$file' );
?>



I am trying to display the stored information on the next page with this:

<?
THE SESSION IS BEING STARTED

echo"
<div id='content_container'>
        <!-- rounded corners - top **** -->
        <div class='rtop'><div class='r1'></div><div class='r2'></div><div class='r3'></div><div class='r4'></div></div>
        <div id='content'>
          <h1>A good snapshot stops a moment from running away.</h1>
          <div class=sub_title>$title</div>
          <p>Checkout page UNDER CONSTRUCTION<br><br>";
echo '<pre>$_SESSION:' . print_r($_SESSION,true) . '</pre>';

foreach ($_SESSION as $file => $val){

echo"
<br><br><br>Picture Number: ONE PEICE OF THE VARIABLE HERE<br>
<table bgcolor=$purple border=0 width=100% bgcolor=#FFECFF cellspacing=0 cellpadding=0 style='border: 2px solid $purple'>
<tr>
	<td width=10% rowspan=2><img src='ONE PEICE OF THE VARIABLE HERE'style='border: 2px solid $purple'></td>
</tr>
<tr>
<td bgcolor=#ffffff colspan=2 valign=top style='border-bottom: 2px solid $purple'>
<table border=0 width=100% cellspacing=0 cellpadding=0>
		<tr bgcolor=$purple>
			<td align=center style='color:white; padding-bottom:3px; font-family:arial narrow; ' colspan=2><font size=5>ORDER INFORMATION</font></td>
		</tr>
		<tr>
			<td align=right style='padding-right: 10px'><font size=4><u>Size</u></td>
			<td><font size=4><u>Quantity</u></font></td>
		</tr>
		<tr>
			<td align=right style='padding-right: 10px' height='30'><font color=$purple size=3>4 x 7:</td>
			<td height='30'><font size=3><b>".ONE PEICE OF THE VARIABLE HERE."</b></font></td>
		</tr>
		<tr>
			<td align=right style='padding-right: 10px' height='30'><font color=$purple size=3>5 x 7:</td>
			<td height='30'><font size=3><b>".ONE PEICE OF THE VARIABLE HERE."</b></font></td>
		</tr>
		<tr>
			<td align=right style='padding-right: 10px' height='30'><font color=$purple size=3>8 x 10:</td>
			<td height='30'><font size=3><b>".ONE PEICE OF THE VARIABLE HERE."</b></font></td>
		</tr>
</table>

</td>

</tr>
<tr>
	<td width=10% colspan=2 bgcolor=$purple>
	<!--<input type=button value='Update'>-->
	<input type=button value='Remove From Order'></td>
	<td bgcolor=$purple>
	 </td>
</tr>
</table>
		<br>

";

}			
echo"			
          </p>
        </div>
        <!-- rounded corners - bottom **** -->
        <div class='rbottom'><div class='r4'></div><div class='r3'></div><div class='r2'></div><div class='r1'></div></div>
      </div>
";

?>


 

If you follow the links and place an order you'll see my problem.

Link to comment
Share on other sites

Looking at your source code for this page

 

You may want to store your sessions like this

 

<?php
if(isset($_POST['order_photo'])){
  foreach($_POST as $key => $val){
   $_SESSION[$key] = $val;
  }
}
?>

 

now your session will look something like

 

Array([picture] => ALBUMS/FLM-MINC/P1090702.jpg, [file] =>  P1090702.jpg, [QU46] => 3)

  and so on

 

Will be easier to retrieve the values of the keys like this rather than

[0] = 4

Doesn't really mean anything

 

Ray

 

Link to comment
Share on other sites

I am sorry.  When I said table I meant <table></table>

 

foreach ($_SESSION as $file => $val){

echo"
<table border=0 width=100% cellspacing=0 cellpadding=0>
		<tr bgcolor=$purple>
			<td align=center style='color:white; padding-bottom:3px; font-family:arial narrow; ' colspan=2><font size=5>ORDER INFORMATION</font></td>
		</tr>
		<tr>
			<td align=right style='padding-right: 10px'><font size=4><u>Size</u></td>
			<td><font size=4><u>Quantity</u></font></td>
		</tr>
		<tr>
			<td align=right style='padding-right: 10px' height='30'><font color=$purple size=3>4 x 7:</td>
			<td height='30'><font size=3><b>".$_SESSION['QU46']."</b></font></td>
		</tr>
		<tr>
			<td align=right style='padding-right: 10px' height='30'><font color=$purple size=3>5 x 7:</td>
			<td height='30'><font size=3><b>".$_SESSION['QU57']."</b></font></td>
		</tr>
		<tr>
			<td align=right style='padding-right: 10px' height='30'><font color=$purple size=3>8 x 10:</td>
			<td height='30'><font size=3><b>".$_SESSION['QU810']."</b></font></td>
		</tr>
</table>
";
}
?>

Link to comment
Share on other sites

Put your title and cell heading outside the loop

 

<?php
echo "<table border=0 width=100% cellspacing=0 cellpadding=0>
		<tr bgcolor=$purple>
			<td align=center style='color:white; padding-bottom:3px; font-family:arial narrow; ' colspan=2><font size=5>ORDER INFORMATION for Picture $_SESSION['file']</font></td>
		</tr>
		<tr>
			<td align=right style='padding-right: 10px'><font size=4><u>Size</u></td>
			<td><font size=4><u>Quantity</u></font></td>
		</tr>\n";
foreach ($_SESSION as $file => $val){
  if($file == "QU46" || $file == "QU57" || $file == "QU810"){

echo"		      <tr>
			<td align=right style='padding-right: 10px' height='30'><font color=$purple size=3>$file</td>
			<td height='30'><font size=3><b>$val</b></font></td>
                       </tr>\n";
  }
}
</table>
?>

 

Since your session is holding more than just the size and quantity you have to tell it to look for just that. Might be a little off on it since I do not know what your session array looks like as of now.

 

Ray

Link to comment
Share on other sites

Sorry had a couple errors in that code. try this

 

<?php
echo "<table border=0 width=100% cellspacing=0 cellpadding=0>
		<tr bgcolor=$purple>
			<td align=center style='color:white; padding-bottom:3px; font-family:arial narrow; ' colspan=2><font size=5>ORDER INFORMATION for Picture {$_SESSION['file']}</font></td>
		</tr>
		<tr>
			<td align=right style='padding-right: 10px'><font size=4><u>Size</u></td>
			<td><font size=4><u>Quantity</u></font></td>
		</tr>\n";
$pic_size = array("4 x 6" => "QU46", "5 x 7" => "QU57", "8 x 10" => "QU810");
foreach ($_SESSION as $file => $val){
  if($file == "QU46" || $file == "QU57" || $file == "QU810"){

echo"		      <tr>
			<td align=right style='padding-right: 10px' height='30'><font color=$purple size=3>".array_search($file, $pic_size)."</td>
			<td height='30'><font size=3><b>$val</b></font></td>
                       </tr>\n";
  }
}
echo "</table>\n";
?>

 

Ray

Link to comment
Share on other sites

Please keep in mind my objective is to store multiple sesion arrays all with different values.

 

If you look at the result of an order on the link above I think it would best describe my problem.

 

ie.

 

$_SESSION:Array1
(
    [picture] => ALBUMS/Holmes_Adams/P1040050.jpg
    [file] => P1040050.jpg
    [s46] => 4 x 6
    [QU46] => 10
    [s57] => 5 x 7
    [QU57] => 20
    [s810] => 8 x 10
    [QU810] => 30
    [order_photo] => Order This Photo
)

$_SESSION:Array2
(
    [picture] => ALBUMS/Holmes_Adams/DIFFERENT NUMBER.jpg
    [file] => DIFFERENT NUMBER.jpg
    [s46] => 4 x 6
    [QU46] => DIFFERENT QUANTITY
    [s57] => 5 x 7
    [QU57] => DIFFERENT QUANTITY
    [s810] => 8 x 10
    [QU810] => DIFFERENT QUANTITY
    [order_photo] => Order This Photo
)

and so on....

 

Then each would be displayed seperatly in there own HTML table.

 

I keep relating it (in my head) to a while loop.

 

I am trying the code change you gave me.

Link to comment
Share on other sites

well then count the arrays

<?php
$count = count($_SESSION);
for($i=0; $i<$count; $i++){
echo "<table border=0 width=100% cellspacing=0 cellpadding=0>
		<tr bgcolor=$purple>
			<td align=center style='color:white; padding-bottom:3px; font-family:arial narrow; ' colspan=2><font size=5>ORDER INFORMATION for Picture {$_SESSION[$i]['file']}</font></td>
		</tr>
		<tr>
			<td align=right style='padding-right: 10px'><font size=4><u>Size</u></td>
			<td><font size=4><u>Quantity</u></font></td>
		</tr>\n";
$pic_size = array("4 x 6" => "QU46", "5 x 7" => "QU57", "8 x 10" => "QU810");
foreach ($_SESSION[$i] as $file => $val){
  if($file == "QU46" || $file == "QU57" || $file == "QU810"){

echo"		      <tr>
			<td align=right style='padding-right: 10px' height='30'><font color=$purple size=3>".array_search($file, $pic_size)."</td>
			<td height='30'><font size=3><b>$val</b></font></td>
                       </tr>\n";
  }
}

echo "</table>\n";
}
?>

 

Ray

Link to comment
Share on other sites

Here is what I have now:

 

<?
echo"
<div id='content_container'>
        <!-- rounded corners - top **** -->
        <div class='rtop'><div class='r1'></div><div class='r2'></div><div class='r3'></div><div class='r4'></div></div>
        <div id='content'>
          <h1>A good snapshot stops a moment from running away.</h1>
          <div class=sub_title>$title</div>
          <p>PAGE UNDER CONSTRUCTION<br><br>";
echo '<pre>$_SESSION:' . print_r($_SESSION,true) . '</pre>';

echo"
<br><br><br>Picture Number: $file<br>
<table bgcolor=$purple border=0 width=100% bgcolor=#FFECFF cellspacing=0 cellpadding=0 style='border: 2px solid $purple'>
<tr>
	<td width=10% rowspan=2><img src='".$_SESSION['picture']."'style='border: 2px solid $purple'></td>
</tr>
<tr>
<td bgcolor=#ffffff colspan=2 valign=top style='border-bottom: 2px solid $purple'>";

$count = count($_SESSION);
for($i=0; $i<$count; $i++){

echo "
<table border=0 width=100% cellspacing=0 cellpadding=0>
		<tr bgcolor=$purple>
			<td align=center style='color:white; padding-bottom:3px; font-family:arial narrow; ' colspan=2><font size=5>ORDER INFORMATION for Picture {$_SESSION[$i]['file']}</font></td>
		</tr>
		<tr>
			<td align=right style='padding-right: 10px'><font size=4><u>Size</u></td>
			<td><font size=4><u>Quantity</u></font></td>
		</tr>\n";

$pic_size = array("4 x 6" => "QU46", "5 x 7" => "QU57", "8 x 10" => "QU810");

foreach ($_SESSION[$i] as $file => $val){               ////////////////////////////////////////////////LINE 38

if($file == "QU46" || $file == "QU57" || $file == "QU810"){

echo"		      
		<tr>
			<td align=right style='padding-right: 10px' height='30'><font color=$purple size=3>".array_search($file, $pic_size)."</td>
			<td height='30'><font size=3><b>$val</b></font></td>
                       </tr>\n";
  }
}

echo "</table>\n";
}
echo"		
</td>

</tr>
<tr>
	<td width=10% colspan=2 bgcolor=$purple>
	<!--<input type=button value='Update'>-->
	<input type=button value='Remove From Order'></td>
	<td bgcolor=$purple>
	 </td>
</tr>
</table>
		<br>

";

//}			
echo"			
          </p>
        </div>
        <!-- rounded corners - bottom **** -->
        <div class='rbottom'><div class='r4'></div><div class='r3'></div><div class='r2'></div><div class='r1'></div></div>
      </div>
";

?>

 

Here is what I get:

 

Warning: Invalid argument supplied for foreach() in /home/content/r/e/m/rememberthe/html/pages/checkout.php on line 38

 

 

I can't even explain what the page looks like???

 

I didn't realize that there was a place in this forum to pay for services.  Do you think it's wrong/offensive to offer the sight a donation as opposed to paying the person helping me?

Link to comment
Share on other sites

that is because the sessions are not being setup correctly.

 

The code that sets the session will have to be something like this

 

<?php
if(!is_array($_SESSION)){
$_SESSION = array();
  foreach($_POST as $key => $val){
   $_SESSION[0][$key] = $val;
  }

} else {
$x = count($_SESSION);
  foreach($_POST as $key => $val){
   $_SESSION[$x][$key] = $val;
  }
}
?>

 

Now your session will be like

Array ( [0] => Array ( [file] => johnny.jpg [QU46] => 3 [QU57] => 4 [QU810] => 4 ) [1] => Array ( [file] => Crap.jpg [QU46] => 1 [QU57] => 3 [QU810] => 6 ) ) 

 

Ray

 

 

Link to comment
Share on other sites

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.