Jump to content

[SOLVED] array?


jakebur01

Recommended Posts

How could I store the rows from this into something to where I could retrieve it later? Like if I wanted to store these rows into an email message.

echo "<TABLE align=center width=650 BORDER=1 CELLSPACING=0 CELLPADDING=5>";

while ($myrow = mysql_fetch_array($result))
{
echo"<tr><TD WIDTH=160 align=center>";
//echo "<a href=\"maptest.php?id=".$myrow[id]."&productselect=".$productselect."&dname=".$dname."&displayimage=".$displayimage."&dealerinfo=".$dealerinfo."\"><img //src='../Images/globe.gif'/></a>";
//echo"</td><TD WIDTH=120><small>";
echo$myrow["orderid"];
echo"</td><TD WIDTH=160 align=center>";
echo$myrow["isbn"];
echo"</td><TD WIDTH=160 align=center>";
echo$myrow["item_price"];

echo"</td><TD WIDTH=160 align=center>";
echo$myrow["quantity"];


$testingsamicans = $myrow['isbn'];

$testingsamicans2 = $myrow['quantity'];


//echo"</small></td><TD WIDTH=30><small>";
//echo$myrow["Zip"];
//echo"</small></td><TD WIDTH=80><small>";
///echo$myrow["Phone"];
//echo"</small></td><TD WIDTH=10><small>";
//echo $value;
echo"</td>";
//echo "Zip code <b>$key</b> is <b>$value</b> miles away from <b>97214</b>.<br />";
//$dealerinfo = " You are $value miles away from this $dname dealer.";


echo"</tr>";

  }
echo "</table>";

Link to comment
https://forums.phpfreaks.com/topic/63927-solved-array/
Share on other sites

would it be something like this? and call $rowvalue later/

$query = "SELECT * FROM order_items WHERE orderid = '$coolid'";
$result = mysql_query($query, $db) or die(mysql_error());

while ($row = mysql_fetch_assoc($result)) {
   $rows[] = $row;
}

$i = 1;

foreach($rows as $rowid => $rowarray) {
//echo "<b>---- Row $rowid ----</b><br />\n\n";
foreach($rowarray as $rowfield => $rowvalue) {
// echo " $rowfield = $rowvalue<br />\n";


echo " $rowvalue";
}
}


echo "<br />";

Link to comment
https://forums.phpfreaks.com/topic/63927-solved-array/#findComment-318622
Share on other sites

You could store them in either a string...

 

<?php

  $tmp = "";
  while() {
    $tmp .= $val;
    $tmp .= $val;
  }

  echo $tmp;

?>

or yes, an array.

 

<?php

  $tmp = array();
  while() {
    $tmp[] = $val;
    $tmp[] = $val;
  }

  foreach($tmp as $v) {
    echo $v;
  }

?>

Link to comment
https://forums.phpfreaks.com/topic/63927-solved-array/#findComment-318623
Share on other sites

You could use a two dimensional array so that everything stays in order:

 

array([index] => array(field => value))

 

Then you could iterate through it just like the table.

 

Or, what I do for simple temporary table storage, just make a new table put query in it and kill it after you've accessed it.

Link to comment
https://forums.phpfreaks.com/topic/63927-solved-array/#findComment-318633
Share on other sites

Here's what i'm trying to do with it. I want the rows to go in this e-mail message:

$message = "<h2>My Company Order # $coolid </h2> <br /> <h3>Shipping Information</h3><br />$shipname<br />$shipaddress<br />$shipcity<br />$shipstate<br />$shipzip<br />$shipcountry<br /><h3>Items Ordered</h3><br /><table border=1 width=500><tr><td><b>Item</b></td><td><b>Quantity</b></td></tr><tr><td>ITEMS GO IN THIS COLUMN</td><td>QUANITY NUMBERS GO IN THIS COLUMN</td></tr></table><br />";

 

where i have "ITEMS GO IN THIS COLUMN" i want $myrow['isbn']

where i have "QUANITY NUMBERS GO IN THIS COLUMN" i want $myrow['quantity']

 

the while ($myrow = mysql_fetch_array($result)) is further up in the script. This mail script is at the bottom. I just need that table with the items and quantities in my mail message.

 

 

Link to comment
https://forums.phpfreaks.com/topic/63927-solved-array/#findComment-318643
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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