Kano Posted March 7, 2007 Share Posted March 7, 2007 Hi there, using select * sql I have created a list of products on a page, I print this list and store it into arrays as well, the prob I am having is accessing the arrays on another script (process order script): The arrays on the first script look like this: while { extract($variable); $array[$num] = $variable; } Can anyone help me? thanks. Link to comment https://forums.phpfreaks.com/topic/41601-solved-getting-to-an-array-from-a-different-script/ Share on other sites More sharing options...
monk.e.boy Posted March 7, 2007 Share Posted March 7, 2007 Script 1: <?php $a = array( 1,2,3 ); ?> Script 2: <?php include_once( '1.php' ); print_r( $a ); ?> This should work. Did i understand your problem? monk.e.boy Link to comment https://forums.phpfreaks.com/topic/41601-solved-getting-to-an-array-from-a-different-script/#findComment-201560 Share on other sites More sharing options...
Kano Posted March 7, 2007 Author Share Posted March 7, 2007 Hi there, I understand what you mean , but I wish just to get to the arrays only not include the whole script. part of first script: $sqlqry_getwsi = "select * from tbl_wsi"; $sqlres_getwsi = mysql_query($sqlqry_getwsi) or die ("Could not execute getwsi query"); $num = 0; $wsi_tn_arr= ""; $wsi_id_arr= ""; $wsi_desc_arr= ""; $wsi_dim_arr= ""; $wsi_cm_arr= ""; $wsi_price_arr= ""; $wsi_qty_arr= ""; $wsi_nxtshiparr_arr= ""; $wsi_img_arr= ""; while($row_getwsi = mysql_fetch_array($sqlres_getwsi)) { extract($row_getwsi); $wsi_id_arr[$num] = $wsi_id; $wsi_desc_arr[$num] = $wsi_desc; $wsi_dim_arr[$num] = $wsi_dim; $wsi_cm_arr[$num] = $wsi_cm; $wsi_price_arr[$num] = $wsi_price; $wsi_qty_arr[$num] = $wsi_qty; $wsi_tn_arr[$num] = $wsi_tn; $wsi_img_arr[$num] = $wsi_img; $wsi_nxtshiparr_arr[$num] = $wsi_nxtshiparr; echo "<tr><td>$wsi_tn_arr[$num]</td><td>$wsi_id_arr[$num]</td><td>$wsi_desc_arr[$num]</td> <td>$wsi_dim_arr[$num]</td><td>$wsi_cm_arr[$num]</td><td>$wsi_price_arr[$num]</td> <td>$wsi_qty_arr[$num]</td><td>$wsi_nxtshiparr_arr[$num]</td> <td><select name='$wsi_id_arr[$num]'>"; for($selectcnt=0;$selectcnt<=$wsi_qty_arr[$num];$selectcnt++) { echo"<option value='$selectcnt'"; if(isset($remember_qty[$num])) { echo"selected='selected'"; } else if($selectcnt==0){ echo"selected='selected'"; } else{} echo">$selectcnt</option>"; } echo "</select></td><tr>"; Link to comment https://forums.phpfreaks.com/topic/41601-solved-getting-to-an-array-from-a-different-script/#findComment-201567 Share on other sites More sharing options...
monk.e.boy Posted March 7, 2007 Share Posted March 7, 2007 i don't understand. You need to run the script to fill the array. Why bother with the array anyway? Just query the database every time you want the data. You can configure MySQL to cache your results, so it won't even do any look ups, it'll just pass the cache back to you. monk.e.boy Link to comment https://forums.phpfreaks.com/topic/41601-solved-getting-to-an-array-from-a-different-script/#findComment-201573 Share on other sites More sharing options...
Kano Posted March 7, 2007 Author Share Posted March 7, 2007 Yes thanks monk.e.boy, I saw the prob whilst reading the post, thanks. I have created an sql query to select those records where qty is > 0 and = select name (which is product id). many thanks. Link to comment https://forums.phpfreaks.com/topic/41601-solved-getting-to-an-array-from-a-different-script/#findComment-201575 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.