StirCrazy Posted November 22, 2006 Share Posted November 22, 2006 Hi folks,Firstly can I just say thanks to all the regulars that have helped me recently - thanks guys :DI have another question for ya ;)I want to set up a post function that on one page has a textarea where I can enter order numbers on each lineEG[code]<textarea>2342323425363662353464565345342443525234</textarea>[/code]...and then after pressing submit list just those order numbers from database central_ordersHow would you do that?ThanksS.C> Quote Link to comment Share on other sites More sharing options...
mb81 Posted November 22, 2006 Share Posted November 22, 2006 first, you have to name your textarea so that the variable will be sent, let's go with "orders"on the submit page[code]<?php $arr_orders = explode("\n",$_REQUEST['orders']); foreach ($arr_orders AS $int_ordernum) { // display code for orders here using $int_ordernum to get info }?>[/code] Quote Link to comment Share on other sites More sharing options...
StirCrazy Posted November 22, 2006 Author Share Posted November 22, 2006 Many thanks mb81Still a novice at this ~ so how would I use that in the below code?[code]<font class="Title"><strong>Preview Orders</strong></font><br><form name="email" method="post" action="index.php?page=preview-orders"><p align="center" class="PlainText" ><textarea name="orders" rows=17 cols=68></textarea><center><br><input type="submit" class="mainoption" value=" Send "></center></form>[/code][code]$r = my_query("select order,user_id,offer,timedate,browser,trackingid,status from central_orders " . "$where_clause" ); <table border="1" cellspacing="0" cellpadding="2"> <tr> <th bgcolor="#dddddd">Order Number</th> <th bgcolor="#dddddd">User</th> <th bgcolor="#dddddd">Offer</th> <th bgcolor="#dddddd">Date / Time</th> <th bgcolor="#dddddd">Browser</th> <th bgcolor="#dddddd">SID</th> <th bgcolor="#dddddd">Status</th> </tr> <?php while (list($order,$user_id,$offer,$timedate,$browser,$trackingid,$status) = mysql_fetch_row($r)) { ?> <tr> <td width="75" align="center"><?php echo $order; ?></td> <td width="75" align="center"><?php echo $user_id; ?></td> <td width="125" align="center"><?php echo $offer; ?></td> <td width="110" align="center"><?php echo date("d-m-Y H:i",$timedate); ?></td> <td align="center"><?php echo $browser; ?></td> <td width="50" align="center"><?php echo $trackingid; ?></td> <td width="50" align="center"><?php echo $status; ?></td> </tr> <?php } ?> </table>[/code] Quote Link to comment Share on other sites More sharing options...
mb81 Posted November 22, 2006 Share Posted November 22, 2006 Based on that code, you can just add these two lines at the top:[code]<?php$arr_orders = explode("\n",$_REQUEST['orders']);$where_clause = "WHERE order IN ('",implode("','",$arr_orders),"')";?>[/code]I would suggest learning how to use an array from mysql_fetch_array or object from mysql_fetch_object would make more sense, rather than using list(); Quote Link to comment Share on other sites More sharing options...
StirCrazy Posted November 22, 2006 Author Share Posted November 22, 2006 getting a parse error, unexpected ',' on this line:-[code]$where_clause = "WHERE order IN ('",implode("','",$arr_orders),"')"; [/code] any ideas?S.C> Quote Link to comment Share on other sites More sharing options...
simcoweb Posted November 22, 2006 Share Posted November 22, 2006 I'm 99% on this one. Take the two commas out of this part (as shown):$where clause = "WHERE order_IN ('"imlpode("','",$arr_orders)"')"; Quote Link to comment Share on other sites More sharing options...
mb81 Posted November 22, 2006 Share Posted November 22, 2006 [quote author=StirCrazy link=topic=115912.msg472156#msg472156 date=1164218490]getting a parse error, unexpected ',' on this line:-[code]$where_clause = "WHERE order IN ('",implode("','",$arr_orders),"')"; [/code] any ideas?S.C>[/quote]Sorry, change the commas to periods (.)[code]<?php$arr_orders = explode("\n",$_REQUEST['orders']);$where_clause = "WHERE order IN ('".implode("','",$arr_orders)."')";?>[/code] Quote Link to comment Share on other sites More sharing options...
StirCrazy Posted November 22, 2006 Author Share Posted November 22, 2006 YAY, no errors :D only problem is that if I submit 100 (or more than 2) orders it only lists the last order on the list ??? Quote Link to comment Share on other sites More sharing options...
StirCrazy Posted November 22, 2006 Author Share Posted November 22, 2006 Still baffled:If I put in three order numbers and echo the $where_clause [quote]WHERE order IN ('166254052 ','166094039 ','165904030') [/quote] but only pulls up order 165904030S.C> Quote Link to comment Share on other sites More sharing options...
StirCrazy Posted November 23, 2006 Author Share Posted November 23, 2006 Can anyone work out what is wrong with this code?This is my my_query function:-[code]<?php$link = mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) or die ("Could not connect to database. Try later<BR>");@mysql_select_db(DB_NAME, $link);function my_query($sql) { global $link; $result = @mysql_query($sql, $link); if ($result) return $result; if (DEBUG_MODE) { error_report(10); }; return false;} ?>[/code]$_REQUEST['credit'] has a list for order numbers from a textarea:-[code]<?php$arr_orders = explode("\n",$_REQUEST['credit']);$where_clause = "WHERE trackingid IN ('".implode("','",$arr_orders)."')";$r = my_query("select user_id,site,offer,points,timedate,trackingid,status from offer_clicks " . "$where_clause"); ?> <h1>Preview Accounts</h1><br> <table border="1" cellspacing="0" cellpadding="2"> <tr> <th bgcolor="#dddddd">Site</th> <th bgcolor="#dddddd">User ID</th> <th bgcolor="#dddddd">Username</th> <th bgcolor="#dddddd">Offer</th> <th bgcolor="#dddddd">Credit</th> <th bgcolor="#dddddd">Date / Time</th> <th bgcolor="#dddddd">Tracking ID</th> <th bgcolor="#dddddd">Status</th> <th bgcolor="#dddddd">Credit</th> <th bgcolor="#dddddd">Pending</th> <th bgcolor="#dddddd">Reject</th> </tr> <?php while (list($user_id,$site,$offer,$points,$timedate,$trackingid,$status) = mysql_fetch_array($r)) { $sql = my_query("select username from central_users where id='$user_id'");list($username) = mysql_fetch_row($sql);$sql = my_query("select site_name from site_options where site_prefix='$site'");list($site_name) = mysql_fetch_row($sql); if ('0' == $status) { $status = "Clicked" ; } if ('1' == $status) { $status = "Credited" ; } if ('2' == $status) { $status = "Pending" ; } if ('3' == $status) { $status = "Rejected" ; } if ($points < 100) {$points = $points ." Credit"; } if ($points > 99) {$points = "Full Credit";} ?> <tr> <td width="75" align="center"><?php echo $site_name; ?></td> <td width="75" align="center"><?php echo $user_id; ?></td> <td width="125" align="center"><?php echo $username; ?></td> <td width="125" align="center"><?php echo $offer; ?></td> <td width="100" align="center"><?php echo $points; ?></td> <td width="110" align="center"><?php echo date("d-m-Y H:i",$timedate); ?></td> <td width="110" align="center"><?php echo $trackingid; ?></td> <td width="75" align="center"><?php echo $status; ?></td> <td width="75" align="center"><INPUT TYPE=RADIO NAME="<?=$trackingid?>" VALUE="<?=$trackingid?>" CHECKED></td> <td width="75" align="center"><INPUT TYPE=RADIO NAME="<?=$trackingid?>" VALUE="<?=$trackingid?>"></td> <td width="75" align="center"><INPUT TYPE=RADIO NAME="<?=$trackingid?>" VALUE="<?=$trackingid?>"></td> </tr> <?php } ?> </table> <?php return(0);} ?>[/code]Problem is it only displays the last order...any ideas?S.C> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.