helpmeplease2 Posted March 3, 2006 Share Posted March 3, 2006 In my database I have a column named type which includes one of 2 things. In the database I have either an asterik (*) or I leave it blank to tell the 2 apart. I would like it to display text instead of an asterik on my website, but to save space only have a symbol (*) in the database.I'm not sure it matters but the results are displayed within a <select> box. I'm using this code currently but it still displays an * on the website. Help?[code]$type=$_POST['SubCategory'];$results=mysql_query("select * from $month WHERE R='$type'");require('mailinglist_inc1.php');echo "EMAIL SENT!<br><br>";if ( $type == "*" ) { echo "type1";} else { echo "type2";}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/3975-replacing-database-results-to-save-space/ Share on other sites More sharing options...
AV1611 Posted March 3, 2006 Share Posted March 3, 2006 please post the contents of'mailinglist_inc1.php' Quote Link to comment https://forums.phpfreaks.com/topic/3975-replacing-database-results-to-save-space/#findComment-13815 Share on other sites More sharing options...
helpmeplease2 Posted March 3, 2006 Author Share Posted March 3, 2006 [code]<?phpwhile($row=mysql_fetch_assoc($results)){$msgtmp=$_POST['msgbody'];$usemail=$row['Email'];$headers = "From: removedforpost','-fremovedforpost";$headers .= "Content-Type: text/html";mail($usemail,$msgsubj,$msgtmp,$headers);}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/3975-replacing-database-results-to-save-space/#findComment-13819 Share on other sites More sharing options...
AV1611 Posted March 4, 2006 Share Posted March 4, 2006 I cannot see any reason your page should show an * .The only things your page could possible show, aside from an error message would be:EMAIL SENT!ortype1or type2Unless there is some more code I'm not seeing... Quote Link to comment https://forums.phpfreaks.com/topic/3975-replacing-database-results-to-save-space/#findComment-14076 Share on other sites More sharing options...
helpmeplease2 Posted March 4, 2006 Author Share Posted March 4, 2006 Sorry, I didn't know it was all needed. Here it is:[code]<?phprequire("secureadmin.php");require("config.php");if($password===$adminpass){include "admin/header.php";if(isset($_POST['SubCategory']) && isset($_POST['msgbody']) && isset($_POST['msgsubj'])){$msgsubj=$_POST['msgsubj'];$senderEmail="removedforpost";if($_POST['SubCategory']==='All'){$results=mysql_query("select * from $month");require('mailinglist_inc1.php');echo "EMAIL SENT!<br><br>";}elseif($_POST['category']==='TYPE'){$type=$_POST['SubCategory'];$results=mysql_query("select * from $month WHERE R='$type'");require('mailinglist_inc1.php');echo "EMAIL SENT!<br><br>";if ( $type == "*" ) { echo "type1";} else { echo "type2";}}elseif(($_POST['category']==='USERS') && (($_POST['SubCategory']!='All'))){$userinfotmp=$_POST['SubCategory'];$usnendpos=strpos($userinfotmp,' (');$memuserName=substr($userinfotmp,0,$usnendpos);$results=mysql_query("select * from $month WHERE Name='$memuserName'");$row=mysql_fetch_assoc($results);$msgtmp=stripslashes($_POST['msgbody']);$usemail=$row['Email'];if(mail($usemail,$msgsubj,$msgtmp,'From: removedforpost','-fremovedforpost')){echo "EMAIL SENT to $usemail! ($msgsubj)<br><br>";}else{echo "Send Mail FAILED! <br><br>";}}}echo "Mailing List: <em>All emails sent are in plain text format!</em> All fields must be entered!<hr>";?><script language="Javascript"> var arrayData = new Array(); arrayData[0]='USERS|All|'<?php$n=1;$results=mysql_query("select * from $month");while($row=mysql_fetch_assoc($results)){echo "arrayData[$n]='USERS|".$row['Name']." (".$row['Email'].")'";$n++;}$memtype=array();$results=mysql_query("select distinct R from $month");while($row=mysql_fetch_assoc($results)){array_push($memtype,$row['R']);}asort($memtype);foreach($memtype as $listtype){echo "arrayData[$n]='TYPE|".$listtype."'";$n++;}php?>function populateData(Name){ select=window.document.form1.SubCategory;string=""; count = 0; // 0: display the new options; 1:display first existing option plus new optionsselect.options.length = count; // Clear the old list (above element 0) // Place all matching categories into Options.for(i=0;i<arrayData.length;i++){string=arrayData[i].split("|");if(string[0]==Name){select.options[count++] = new Option(string[1]);}} //Set which option from subcategory is to be selected//select.options.selectedIndex=0;//Give subcategory focus and select it //select.focus(); }function addmsgtxt(symbol) { document.form1.msgbody.value+=symbol; document.form1.msgbody.focus()}</script><table style="font: normal normal 14px Verdana" valign="top"><form Name="form1" method="post" action="admin.php?p=mailinglist-sales"><tr> <td><b>Sort By:</b><br> <select Name="category" size="5" style="width:200px;" onChange='javascript:populateData(this.options[selectedIndex].text)'> <option>USERS</option><option>TYPE</option></select></td><td width="300" valign="top"><b>Insert:</b><br> <table valign="top" cellpadding="2"><tr><td style="border: 1px dashed #999999" valign="top" bgcolor="#FFFFFF" width="300"><?php $bar = <<<HTML_OUTPUT<img src="removedforpost">HTML_OUTPUT;?><a href="javascript:addmsgtxt('Dear Valued Members,\n\n<?php $bar ?>')">Greetings</a><br><a href="javascript:addmsgtxt('<?php echo date("l F d, Y h:i:s A") ?> ')">Date/Time</a><br><a href="javascript:addmsgtxt('Thank you,\nremovedforpost')">Closing</a><br><a href="javascript:addmsgtxt('Hello,\n\nremovedforpost')">removedforpost</a><br><a href="javascript:addmsgtxt('Hello,\n\nremovedforpost')">removedforpost</a><br></td></tr></table></td><td rowspan="4" valign="top"><b>Send Mail To:</b><br> <select Name="SubCategory" size="30" style="width:475px;"></select> </td> </tr><tr><td colspan="2"><b>Subject:</b> <input type="text" Name="msgsubj" size="70"></td></tr><tr><td colspan="2"><textarea Name="msgbody" rows="20" cols="60"></textarea></td></tr><tr><td colspan="3"><button type="submit" class="buttons">Send</button> <button type="reset" class="buttons">Cancel</button></td></tr></form></table><?php}else{echo "removedforpost<br><br>";}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/3975-replacing-database-results-to-save-space/#findComment-14083 Share on other sites More sharing options...
AV1611 Posted March 4, 2006 Share Posted March 4, 2006 Can you tell me which row return has the * in it? It's not apparent from your script... Quote Link to comment https://forums.phpfreaks.com/topic/3975-replacing-database-results-to-save-space/#findComment-14199 Share on other sites More sharing options...
helpmeplease2 Posted March 4, 2006 Author Share Posted March 4, 2006 In this select box is where the * displays.[code]<td rowspan="4" valign="top"><b>Send Mail To:</b><br><select Name="SubCategory" size="30" style="width:475px;"></select>[/code]This part says that if "type" is selected using javascript then it will display all [b]different[/b] values in the "R" column. When a type is selected from within the select box it will send send an email to those who have that value in the "R" column within the database. [code]}elseif($_POST['category']==='TYPE'){$type=$_POST['SubCategory'];$results=mysql_query("select * from $month WHERE R='$type'");require('mailinglist_inc1.php');echo "EMAIL SENT!<br><br>";[/code]I want it to keep having there just be an * in the database, but in the select box I want it to say "type1", "type 2" instead of "*", "". I hope I explained it ok. Quote Link to comment https://forums.phpfreaks.com/topic/3975-replacing-database-results-to-save-space/#findComment-14248 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.