Jump to content


Photo

Replacing database results to save space


  • Please log in to reply
6 replies to this topic

#1 helpmeplease2

helpmeplease2
  • Members
  • PipPipPip
  • Advanced Member
  • 87 posts

Posted 03 March 2006 - 03:17 AM

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?

$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";
}


#2 AV1611

AV1611
  • Members
  • PipPipPip
  • Advanced Member
  • 997 posts

Posted 03 March 2006 - 04:08 AM

please post the contents of

'mailinglist_inc1.php'

#3 helpmeplease2

helpmeplease2
  • Members
  • PipPipPip
  • Advanced Member
  • 87 posts

Posted 03 March 2006 - 04:36 AM

<?php
while($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);
}
?>


#4 AV1611

AV1611
  • Members
  • PipPipPip
  • Advanced Member
  • 997 posts

Posted 04 March 2006 - 03:28 AM

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!
or
type1
or
type2

Unless there is some more code I'm not seeing...

#5 helpmeplease2

helpmeplease2
  • Members
  • PipPipPip
  • Advanced Member
  • 87 posts

Posted 04 March 2006 - 03:52 AM

Sorry, I didn't know it was all needed. Here it is:

<?php
require("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 options
select.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> &nbsp;
<button type="reset" class="buttons">Cancel</button>
</td>
</tr></form>
</table>
<?php

}else{
echo "removedforpost<br><br>";
}
?>


#6 AV1611

AV1611
  • Members
  • PipPipPip
  • Advanced Member
  • 997 posts

Posted 04 March 2006 - 05:22 PM

Can you tell me which row return has the * in it? It's not apparent from your script...


#7 helpmeplease2

helpmeplease2
  • Members
  • PipPipPip
  • Advanced Member
  • 87 posts

Posted 04 March 2006 - 08:54 PM

In this select box is where the * displays.
<td rowspan="4" valign="top"><b>Send Mail To:</b><br>
<select Name="SubCategory" size="30" style="width:475px;"></select>

This part says that if "type" is selected using javascript then it will display all different 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.
}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>";

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users