Jump to content

Help wit populating a select box


SA Rob

Recommended Posts

I would like to save this delimted file to my hard drive in my C Drive at location C:/SMS/filename.txtThe filename is determined by the name selcted in the tournament select box.How do I specify the "data" to write ? to the text file?I am not sure what you mean by PHP having permission to do so?Sorry for all the questions but I guess this is the only way to learn.

Link to comment
Share on other sites

Would I then be correct in saying this:

<?php$fname = 'C:\SMS\filename.txt';$data = '$SMS_Player[$smsloop].'|'.$SMS_Cellphone[$smsloop].'|'.$_POST['tournament'].'|'.$SMS_Time[$smsloop].'|;file_put_contents($fname, $data);?>

Link to comment
Share on other sites

You can replace or build the filename and data however you want. These instructions only apply to saving the file on the server, not the client. If you want to download the file from the browser and save it on your computer the instructions are different. When you say you want to save the file on "my hard drive", I don't know if you're talking about the server's hard drive or the client's hard drive. These instructions are for saving on the server.If you have the filename in a variable, you can put that into whatever other path you want to use.

$name = 'some_name';$fname = 'C:\files\' . $name . '.txt';

You can put a value from the database or $_POST or wherever you want into the filename. This assumes that the data you're using for the filename does not contain invalid characters. If the data might contain characters that are not valid in a filename then you'll need to replace those first.

How do I specify the "data" to write ? to the text file?
Right now your code just echos the data. Instead of echoing the data you would build a string instead, and once it's build then write it to the file. You can use the string concatenation operator, a period, to build the string.
$array = (  'item 1',   'item 2',  'item 3');$data = ''; // start with an empty stringfor ($i = 0; $i < count($array); $i++){  $data .= $array[$i] . "\n"; // build the string}echo $data; // output the result

I am not sure what you mean by PHP having permission to do so?
In order for PHP to save files on the server, it needs permission to do so. Each directory has write permissions for each user account on the computer, and the user account that PHP runs under needs write permission to the place you want to save the files. I would need to know more about your server environment to be much more help than that.
Link to comment
Share on other sites

Thanks for your help.Maybe explaining this file will help.The file is a simple delimted txt file which has to be saved on my home computer in a specific directory, when I press submitThe reason for this is that another software program will then use the file say, Kyalami GC.txt to send SMS (Cell phone text) to the players listed for a specific tournament.The tournament name is a variable and is best kept as such, if I do not do it like this the file will be overwritten each time I send/submit to my home computer in the specifc location.I hope that helps. The link above sort of shows the section I wan tsaved to my computer

Link to comment
Share on other sites

OK. PHP can't save files anywhere except the server, so you need to have it open a download prompt instead, and then you save the file wherever you want to. In order to do that, PHP needs to send several headers which tell the browser to download the file, and then it sends the file data. You cannot send any data except the file data, you can't output any other HTML or anything because it will be considered part of the file data.There are several examples of sending headers to force a download box:http://www.google.com/search?client=opera&...channel=suggestAfter you send the headers, you just echo the data you want in the file. Like I said, all data that you echo gets included as part of the file.

<?php$name = 'some_name.txt';// send download headersheader('Content-Type: application/octet-stream');header('Content-Disposition: attachment; filename="'.$name.'"');header("Cache-control: private");header('Pragma: private');header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");// send file dataecho "line 1\n";echo "line 2\n";echo "line 3\n";?>

So the main changes to your code are to generate the filename and send the headers. You're already outputting the data, so that's fine. Don't include any HTML <br> tags or anything else though, only the data you want to be in the file.

Link to comment
Share on other sites

Hi,Thanks for the thorough explination.In doing this, and please excuse me if I havent understood it correctly - where does this script know where to store the file?(i.e. I would like to store it in this directry C:\SMS\"Filename".txt)In this script how does it know to change the "filename A.txt" to "filename B.txt" for example ?By this I mean if I select the Tournament Select box and pick a tournament say Bryanston GC then the file that will be saved to C:\SMS\.... would be C:\SMS\Bryanston.txt and similarly if I select KYALAMI GC the effect would mean that the file stored would be stored as C:\SMS\Kyalami.txtThis might only be able to be done by using Javascript but that is something you guys in the know would be able to tell.

Link to comment
Share on other sites

Hi ,Thanks for the input.I am not quite sure what you mean by "download prompt" for the file.I have tried this:

<?php$name = 'some_name.txt';// send download headersheader('Content-Type: application/octet-stream');header('Content-Disposition: attachment; filename="'.$name.'"');header("Cache-control: private");header('Pragma: private');header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");// send file dataecho "$SMS_Player[$smsloop].\n";echo ".$SMS_Cellphone[$smsloop]."\n";echo ".$_POST['tournament']."\n";?>

and the entire file no longer appears - so what I am doing is obviously incorrect.

Link to comment
Share on other sites

it's when a small window opens up in your web browser to ask you where you want to download something. If you want to download an application for your computer. Like when you got Firefox's home page and click the link to download their browser.

Link to comment
Share on other sites

Right! finally got round to this yesterday, see you have been moving flag pole again, tut, tut. sure that not allowed.try Again! 2 of 6sms_message_form.php

<?phprequire_once('../databasetest/Connections/golf_conn.php');include('functions.php');$SMS_Time = array();$SMS_Player = array();$SMS_Tee_off = array();$SMS_Phone = array();$SMS_Count=0;$total_col=4;$teereftwo="First";$teerefone="Tenth";$teeperiod=6;$bordtop="";$trgroupcount=0;$row1time="8:00";mysql_select_db($database_golf_conn, $golf_conn);$quey1 = "SELECT * FROM golf_db_form_nr_3 ORDER BY i_wish_to_play, my_handicap_is BETWEEN 7 AND 18, my_handicap_is, my_handicap_is BETWEEN 19 AND 36, my_handicap_is BETWEEN -5 AND 6 DESC";$result = mysql_query($quey1) or die(mysql_error());while ($row = mysql_fetch_assoc($result))	{	$club_tournament=$row['i_wish_to_play'];	break;	}?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Untitled Document</title>	<script type="text/javascript" src="ajax_update.js"></script><script type="text/javascript">/*<![CDATA[*//*---->*/window.onload=function(){document.getElementById("show_game_fixture").display="none";document.getElementById("showhide_link").style.display="none";var y=document.getElementById("club_tournament");var z=document.getElementById("tournament");ajax_updatemessage('options', z.selectedIndex, y.value, z.id)}function HideShow_on_message_selection(){message=document.getElementById("tournament");if(message.selectedIndex ==0){document.getElementById("SMS_message_table").style.display="none";document.getElementById("showhide_link").style.display="none";document.getElementById("show_game_fixture").style.display="none";}else{document.getElementById("SMS_message_table").style.display="block";document.getElementById("showhide_link").style.display="block";}}function update_game_listing(){var v=document.getElementById("show_game_fixture");var w =document.getElementById("SMS_message_table");var z=document.getElementById("tournament");HideShow_on_message_selection();if(z.selectedIndex!=0){club_tourn = document.getElementById("club_tournament").value;players_pg = document.getElementById("players_per_group").value;first_tee_off = document.getElementById("firstrowtee").value;second_tee_off = document.getElementById("secondrowtee").value;start_time = document.getElementById("row1time").value;time_interval = document.getElementById("timeperiod").value;tournament_message = document.getElementById("tournament").value;ajax_update_listing('table', z.selectedIndex, club_tourn, players_pg,first_tee_off,second_tee_off ,start_time ,time_interval, 'tournament_listing', v.style.display, w.style.display);}}function update_game_listingtest(){y=document.getElementById("club_tournament");x=document.getElementById("tournament");HideShow_on_message_selection()ajax_updatemessage('options', x.selectedIndex, y.value, x.id);}function ShowHide(element){var x=document.getElementById(element);x.style.display=="none" ? x.style.display="block" : x.style.display="none";}function resetselectindex(){z=document.getElementById("tournament");z.selectedIndex=0;document.getElementById("SMS_message_table").style.display="none";document.getElementById("showhide_link").style.display="none";document.getElementById("show_game_fixture").style.display="none";}function hideMessageTable(){document.getElementById('SMS_message_table').style.display='none';}/*--*//*]]>*/</script><style type="text/css">body{font-family:Arial, Helvetica, sans-serif; }table {border:2px solid #D3E2FE;  width:100%;  font-size:12px;  font-family:Arial; color:#00008B;margin-bottom:20px;}table tr td {border-right:1px solid #D3E2FE;border-top:1px solid #D3E2FE; padding:0 5px;}tr.header{background-color:#D6D6D8; font-weight:bold;}.rowcol1 {background-color:#F0FFFF;}.rowcol2 {background-color:#FFFFCC;}.rowcol3 {background-color:#CCCCFF;}td.fullname { padding-left:2px; font-size: 11px;}td.hcap {text-align:center;}#wrapper {width:95%; margin:0 auto;}.starter {background-color:#D3E2FE;text-align:center}.time {text-align:center}.blank {background-color:#FFF; }.blank td { border-width:0;}.bordertop td {border-top:1px solid #D3E2FE;}.teeinput_outer {margin-top:10px;}.teeinput_outer div span { display:block;float:left;width:160px;margin-left:10px;}.highlight_tee_error{color:#FF0000; font-weight:bold;}#SMS_form_container {width:900px;border:2px solid #A7B7CE; margin: 20px auto; padding:2px 5px; background-color:#DCEEF0; color:#0B007A; overflow:hidden;}#SMS_form_container h4 {text-transform:uppercase; margin: 0 0 4px 0;font-size:80%;}.SMS_select_group { float:left; text-align:center; padding:1px 5px 3px; background-color:#F5F9FC;margin:0 4px 4px 0;border:1px solid #9CBBD7;}.SMS_select_group p{ text-transform:uppercase; margin: 0; font-size:0.5em;}#SMS_form_container select {background-color:#FFF8E1;color:#0B007A;}#tournament{width:615px; font-size:10px;}#showhide_link {outline:none; display:block; margin:15px;float:left;}#tournament_listing {clear:both;}.clear {clear:both; height:0;}</style></head><body><div id="wrapper">		<form action="create_sms_file.php" method="post" name="tablecontroller"  id="tablecontroller">	<div id="SMS_form_container">	<h4>Message Board SMS developer</h4><!-- Tournament DDrop down --><div class="SMS_select_group"><p>Tournament</p>	<select id="club_tournament" name="club_tournament" onchange="resetselectindex();update_game_listing();">	<?php		$quey1 = "SELECT *, MAX(date1) FROM golf_db_form_nr_3 GROUP BY i_wish_to_play ORDER BY i_wish_to_play ASC, date1 DESC";	$result = mysql_query($quey1) or die(mysql_error());	$current_table_count=-1;	while ($row = mysql_fetch_assoc($result))		{			if($club_tournament == $row['i_wish_to_play'])				{				echo '<option value="'.$row['i_wish_to_play'].'" selected="selected">'.$row['i_wish_to_play'].' </option>'."\n";				}			else				{			echo '<option value="'.$row['i_wish_to_play'].'">'.$row['i_wish_to_play'].'</option>'."\n";				}		}	?>	</select>	</div>	<!-- Players Per group 2 ball to 4 ball Drop down -->	<div class="SMS_select_group"><p>Players Per Group</p>	<select name="players_per_group" id="players_per_group" onchange="update_game_listing();">	<?php	for($j=2;$j<5;$j++)		{		if($total_col == $j)			{			echo '<option value="'.$j.'" selected="selected">'.($j).' Ball</option>'."\n";			}		else			{			echo '<option value="'.$j.'">'.($j).' Ball</option>'."\n";			}		}	$teeholetext= array('First', 'Second', 'Third', 'Fourth', 'Fifth',  'Sixth', 'Seventh', 'Eighth', 'Ninth', 'Tenth', 'Eleventh', 'Twelve', 'Thirteenth', 'Fourteenth', 'Fifteenth', 'Sixteenth', 'Seventeenth', 'Eighteenth');	?>	</select></div>	<div class="SMS_select_group"><p>First Group 'T' Box</p>			<select id="firstrowtee" name="1rowtee" onchange="update_game_listing();">			<?php			for($t=0;$t<18;$t++)				{				if($teerefone == $teeholetext[$t])					{					echo '<option selected="selected" value="'.$teeholetext[$t].'">'.$teeholetext[$t].'</option>'."\n";					}				else					{					echo '<option value="'.$teeholetext[$t].'">'.$teeholetext[$t].'</option>'."\n";					}				}			?>			</select>			</div><!--End teeinput_outer INNER DIV-->		<div class="SMS_select_group"><p>Second Gruop 'T' Box</p><select name="2rowtee" id="secondrowtee" onchange="update_game_listing();">			<?php			for($t=0;$t<18;$t++)				{				if($teereftwo == $teeholetext[$t])					{					echo '<option selected="selected" value="'.$teeholetext[$t].'">'.$teeholetext[$t].'</option>'."\n";					}				else					{				echo '<option value="'.$teeholetext[$t].'">'.$teeholetext[$t].'</option>'."\n";					}				}			?>			</select>			</div>	<div class="SMS_select_group"><p>Start Time</p>			<select id="row1time" name="row1time" onchange="update_game_listing();">			<?php			for($t=8;$t<21;$t++)				{				if($row1time == $t.':00')					{					echo '<option selected="selected" value="'.$t.':00">'.$t.':00</option>'."\n";					}				else					{					echo '<option value="'.$t.':00">'.$t.':00</option>'."\n";					}				}			?>			</select>			</div>	<div class="SMS_select_group"><p>Playing Intervals</p>			<select name="timeperiod" id="timeperiod" onchange="update_game_listing();">			<?php			for($t=6;$t<=10;$t++)				{				if($teeperiod == $t)					{					echo '<option selected="selected" value="'.$t.'">'.$t.'</option>'."\n";					}				else					{					echo '<option value="'.$t.'">'.$t.'</option>'."\n";					}				}			?>			</select>	</div> <div class="clear"></div>	<div class="SMS_select_group"><p>Message Choice</p><select name="tournament" id="tournament" onfocus="update_game_listingtest();resetselectindex();" onchange="update_game_listing();"></select></div><div style="margin:8px 0px; text-align:center;"><input name="SMS_Submit" type="submit" value="Create SMS Text File" /></div></div><a href="java script:void(0);" onclick="ShowHide('show_game_fixture')" id="showhide_link">Show Tournament Fixture Listing</a><div id="tournament_listing"> <div id="show_game_fixture"></div><div id="SMS_message_table"></div></div></form> </div></body></html>

functions.php

<?php### POPULATE table , select option and text Filerequire_once('../databasetest/Connections/golf_conn.php');mysql_select_db($database_golf_conn, $golf_conn);function message_populate($type, $itemno, $tournament, $date1, $player, $time, $teeoff, $phone){//message 1 text$message1a="The tournament has been cancelled at ";//message 2 text$message2a="Your Tee off time for the Glacier Series event to be held at ";$message2b=" on the ";$message2c=" is";$thismesarray= array();if($type=="table") //populate table	{	$thismesarray[1] ='<tr><td>'.$player.'</td><td>'.$phone.'</td><td>'.$message1a.$tournament.'</td><td>'.$time.'</td><td>'.$teeoff.'</td></tr>'."\n";	$thismesarray[2] ='<tr><td>'.$player.'</td><td>'.$phone.'</td><td>'.$message2a.$tournament.$message2b.$date1.$message2c.'</td><td>'.$time.'</td><td>'.$teeoff.'</td></tr>'."\n";	if($itemno>0)		{		echo $thismesarray[$itemno];		}	}if($type=="options")//populate options fron dropdown	{	$thismesarray[0]='<option value="0">---Select SMS Message---</option>';	$thismesarray[1] ='<option value="'.$message1a.$tournament.'">'.$message1a.$tournament.'</option>';	$thismesarray[2] ='<option value="'.$message2a.$tournament.$message2b.$date1.$message2c.'">'.$message2a.$tournament.$message2b.$date1.$message2c.'</option>';		for($i=0;$i<count($thismesarray);$i++)		{		if($itemno==$i)			{			$thismesarray[$i] = str_replace('<option ', '<option selected="selected" ', $thismesarray[$i]);			}			echo $thismesarray[$i];		}	}	if($type=="textfile") //populate textfile	{	$thismesarray[1] =$player.'|'.$phone.'|'.$message1a.$tournament.'|'.$time.'|'.$teeoff.'|'."\r\n";	$thismesarray[2] =$player.'|'.$phone.'|'.$message2a.$tournament.$message2b.$date1.$message2c.'|'.$time.'|'.$teeoff.'|'."\r\n";	if($itemno>0)		{		return $thismesarray[$itemno];		}	}	}#### FILL empty table rows/cellsfunction fillemptygrouprows($trcount,$total_col, $thisrowvalue)	{	if($trcount<(ceil($thisrowvalue/4)*4) && $trcount>0)		{		for($r=$trcount;$r<(ceil($thisrowvalue/4)*4);$r++)			{			echo '<tr><td class="time">  :  </td>';			for ($i=0;$i<$total_col;$i++)				{				echo '<td> </td><td> </td>';				}			echo '</tr>';			}		}	}		?>

Link to comment
Share on other sites

Thanks very much for all your effort.I so wish I could say what you say - I only got to do this yesterday - I can only imagine the things that ar epossible having such a wealth of knowledge.Again I appreciate all you do to help - THANK YOU.As you can see I have also been fidling on my side to get it to do certain things - more look and feel.In terms of reply:Must I know save the AJAx file as ajax.js as a file in order for it to action later?

Link to comment
Share on other sites

hang on ! Huston we have a problem, post going haywire, not accepting whole scripts, last one here.5 of 6 i hopetournament.php

<?php ## GATHER DATE FOR DROPDOWN SMS MESSAGES require_once('../databasetest/Connections/golf_conn.php'); include('functions.php');  $element_type=$_GET['elementtype']; $sel_index=$_GET['sel_indx']; $tournament_club=$_GET['club'];  mysql_select_db($database_golf_conn, $golf_conn);	 	 $quey1 = "SELECT *, MAX(date1) FROM golf_db_form_nr_3 WHERE i_wish_to_play='$tournament_club' GROUP BY i_wish_to_play ORDER BY i_wish_to_play ASC, date1 DESC LIMIT 1"; 	 $result = mysql_query($quey1) or die(mysql_error());	 $current_table_count=-1; 	 while ($row = mysql_fetch_assoc($result))	 {	 $date= $row['date1'];	 }  message_populate($element_type,$sel_index,$tournament_club, $date , '', ''); 	 ?>

create_sms_file.php

<?php include('functions.php');  $SMS_Index=$_POST['SMS_Index']; $SMS_Player=$_POST['SMS_Player']; $SMS_Time=$_POST['SMS_Time']; $SMS_Tee_off=$_POST['SMS_Tee_off']; $SMS_Phone=$_POST['SMS_Phone']; $SMS_Date=$_POST['SMS_Date']; $club_tournament = $_POST['club_tournament'];  //Save file to localhost directory  /*$SMS_File = 'SMS_'.str_replace(" ","_",$club_tournament).'.txt';	 $SMS_Open = fopen($SMS_File, 'w') or die("can't open file"); for($smsloop=0; $smsloop<count($SMS_Player); $smsloop++) { $SMS_Data = message_populate('textfile',$SMS_Index,$club_tournament, $SMS_Date , $SMS_Player[$smsloop], $SMS_Time[$smsloop], $SMS_Tee_off[$smsloop], $SMS_Phone[$smsloop]); fwrite($SMS_Open, $SMS_Data); } fclose($SMS_Open);*/   //read localhost file /*$SMS_File = 'SMS_'.str_replace(" ","_",$club_tournament).'.txt';	 $SMS_Open = fopen($myFile, 'r');  while(!feof($SMS_Open)) { $SMS_Data = fgets($SMS_Open, 1024); echo nl2br($SMS_Data);  } fclose($SMS_Open); */  //redirect to form page //header("Location: golf01.php");   header("Content-type: application/octet-stream"); header("Content-Disposition: attachment; filename=\"SMS_".str_replace(" ","_",$club_tournament).".txt\"");  $SMS_Data=""; for($smsloop=0; $smsloop<count($SMS_Player); $smsloop++) { $SMS_Data .= message_populate('textfile',$SMS_Index,$club_tournament, $SMS_Date , $SMS_Player[$smsloop], $SMS_Time[$smsloop], $SMS_Tee_off[$smsloop], $SMS_Phone[$smsloop]); } echo $SMS_Data;   ?>

ajax_update.js

// JavaScript Document    var xmlhttp    var current_id_ref="";    function ajax_updatemessage(elementtype, sel_indx, club, id_ref)  {  current_id_ref=id_ref;    xmlhttp=GetXmlHttpObject();  if (xmlhttp==null)	{	alert ("Your browser does not support AJAX!");	return;	}    var url=id_ref+".php?elementtype="+elementtype+"&sel_indx="+sel_indx+"&club="+club;  url=url+"&sid="+Math.random();  //alert(url)  xmlhttp.onreadystatechange=stateChanged;  xmlhttp.open("GET",url,true);  xmlhttp.send(null);  }    function message_populator(elementtype, sel_indx, club, id_ref)  {  current_id_ref=id_ref;  xmlhttp=GetXmlHttpObject();  if (xmlhttp==null)	{	alert ("Your browser does not support AJAX!");	return;	}  var url=id_ref+".php?elementtype="+elementtype+"&sel_indx="+sel_indx+"&club="+club;  url=url+"&sid="+Math.random();    xmlhttp.onreadystatechange=stateChanged;  xmlhttp.open("GET",url,true);  xmlhttp.send(null);  }    function ajax_update_listing(elementtype, sel_indx, club_tournament, players_pg, first_tee_off, second_tee_off ,start_time ,time_interval, id_ref, displaystatus, displaystatus2)  {  current_id_ref=id_ref;  xmlhttp=GetXmlHttpObject();  if (xmlhttp==null)	{	alert ("Your browser does not support AJAX!");	return;	}    var url=id_ref+".php?elementtype="+elementtype+"&sel_indx="+sel_indx+"&club_tournament="+club_tournament+"&players_per_group="+players_pg+"&1rowtee="+first_tee_off+"&2rowtee="+second_tee_off+"&row1time="+start_time+"&timeperiod="+time_interval+"&displaystatus="+displaystatus+"&displaystatus2="+displaystatus2;  url=url+"&sid="+Math.random();  xmlhttp.onreadystatechange=stateChanged;  xmlhttp.open("GET",url,true);  xmlhttp.send(null);  }    function stateChanged()  {  if (xmlhttp.readyState==4)  {  document.getElementById(current_id_ref).innerHTML=xmlhttp.responseText;  }  }    function GetXmlHttpObject()  {  if (window.XMLHttpRequest)	{	// code for IE7+, Firefox, Chrome, Opera, Safari	return new XMLHttpRequest();	}  if (window.ActiveXObject)	{	// code for IE6, IE5	return new ActiveXObject("Microsoft.XMLHTTP");	}  return null;  }

Link to comment
Share on other sites

last one the biggytournament_listing.php

<?php##Produce tournament fixture list, SMS Message List, and gather information for SMS text filerequire_once('../databasetest/Connections/golf_conn.php');include('functions.php');mysql_select_db($database_golf_conn, $golf_conn);$SMS_Time = array();$SMS_Player = array();$SMS_Tee_off = array();$SMS_Phone = array();$SMS_Count=0;$total_col=4;$teereftwo="First";$teerefone="Tenth";$teeperiod=6;$row1time="8:00";$total_col=$_GET['players_per_group'];$teereftwo=$_GET['2rowtee'];$teerefone=$_GET['1rowtee'];$teeperiod=$_GET['timeperiod'];$row1time=$_GET['row1time'];$displaystatus = $_GET['displaystatus'];$displaystatus2 = $_GET['displaystatus2'];$club_tournament=$_GET['club_tournament'];$element=$_GET['elementtype'];$bordtop="";$trgroupcount=0;$col_count=0;$currentclub="";$trcount=0;$trclass="";		/////////////////////////  determine total row value and store in array ////////////////////////////////$rowsarray = array();$current_row_count=0;$quey1 = "SELECT * FROM golf_db_form_nr_3 WHERE i_wish_to_play='$club_tournament' ORDER BY i_wish_to_play, my_handicap_is BETWEEN 7 AND 18, my_handicap_is, my_handicap_is BETWEEN 19 AND 36, my_handicap_is BETWEEN -5 AND 6 DESC";$result = mysql_query($quey1) or die(mysql_error());				while ($row = mysql_fetch_assoc($result))	{	  $datet=$row['date1'];	if($currentclub != $row['i_wish_to_play'] && $currentclub!="")		{			$rowsarray[$current_row_count]=$trcount;		$trcount=0;		$col_count=0;		$current_row_count++;		}	if($col_count==0)		{		$trcount++;		}	$col_count++;			if($col_count==$total_col)		{		$col_count=0;		}	$currentclub = $row['i_wish_to_play'];   }//end while loop   $rowsarray[$current_row_count]=$trcount;	$col_colunt=0;$currentclub="";$trcount=0;$trclass="";$currentclub="";$quey1 = "SELECT * FROM golf_db_form_nr_3 WHERE i_wish_to_play='$club_tournament' ORDER BY i_wish_to_play, my_handicap_is BETWEEN 7 AND 18, my_handicap_is, my_handicap_is BETWEEN 19 AND 36, my_handicap_is BETWEEN -5 AND 6 DESC";$result = mysql_query($quey1) or die(mysql_error());	$current_table_count=-1;$teecount=0;while ($row = mysql_fetch_assoc($result))	{	if($currentclub != $row['i_wish_to_play'])		{		$current_table_count++;		$teecount=0;		if($col_count<$total_col && $col_count!=0 && $currentclub !="") /// use to fill empty cells			{			for($i=$col_count;$i<$total_col;$i++)				{				echo "<td> </td><td> </td>";				}			echo "</tr>";			fillemptygrouprows($trcount,$total_col, ceil($rowsarray[$current_table_count]));			echo "</table>";			$trcount=0;			}		else if ($currentclub !="")			{			fillemptygrouprows($trcount,$total_col, ceil($rowsarray[$current_table_count]));			echo "</table> ";			$trcount=0;			}/////////////////////////////////////////// Show tables ////////////////////////////////////////////////////////////  ?>			<div id="show_game_fixture" style="display:<?php echo $displaystatus; ?>;">			<table border="0" cellpadding="0" cellspacing="0">				  <tr>					  <th colspan="<?php echo ($total_col*2)+1; ?>"><span id="tourname"><?php echo $row['tournament']; ?></span></th>				  </tr><?php		echo '<tr class="blank'.$bordtop.'"><td> </td>';		for ($i=0;$i<$total_col;$i++) // adds top tee number header			{			if($i == 0)				{				echo '<td style="font-weight:bold; text-align:center;">'.strtoupper($teerefone).' TEE</td><td> </td>';				$SMSteeoff=strtoupper($teerefone);				}			else				{				echo '<td> </td><td> </td>';				}			}		echo '</tr>';?>				  <tr class="header"><td style="width:40px; text-align: center;">TIME</td><?php		for ($i=0;$i<$total_col;$i++)//add fullname and h/cap header			{			echo '<td class="fullname" width="'.(78/$total_col).'%">FULL NAME</td><td class="hcap" width="'.(16/$total_col).'%">H/CAP</td>';			}?>				</tr><?php		$col_count=0;		}				if($col_count==0)		{		if($trcount == ceil($rowsarray[$current_table_count]/4) || $trcount == (ceil($rowsarray[$current_table_count]/4)+ceil($rowsarray[$current_table_count]/4)*2))			{			$timestamp=strtotime($row1time);			$timeinterval=$trgroupcount*$teeperiod;			$teetime=date('H:i', strtotime("+$timeinterval minutes", $timestamp));			$trgroupcount++;			echo '<tr class="starter"><td>'.$teetime.'</td>';			for ($i=0;$i<$total_col;$i++)				{				echo '<td class="fullname" width="'.(78/$total_col).'%">STARTER</td><td class="hcap" width="'.(16/$total_col).'%"> </td>';				}			echo '</tr>';			}		else			{			if($trcount  % ((ceil($rowsarray[$current_table_count]/4)*2)) ==0 && $trcount!=0)				{				for($j=0;$j<2;$j++)					{					if($j==0)						{						$bordtop=" bordertop";						}					else						{						$bordtop="";						}					 echo '<tr class="blank'.$bordtop.'"><td> </td>';					for ($i=0;$i<$total_col;$i++)						{						if($i == 0 && $j !=0)							{							$trgroupcount=0;							$teetexterror="";							$SMSteeoff=strtoupper($teereftwo);							if($teereftwo==$teerefone)								{								$teetexterror="highlight_tee_error";								$teereftwo="Matching Tee holes";								}														echo '<td style="font-weight:bold; text-align:center;"><span class="'.$teetexterror.'">'.strtoupper("$teereftwo").'</span> TEE</td><td> </td>';							}						else							{							echo '<td> </td><td> </td>';							}						}					echo '</tr>';					}				}			}			$timestamp=strtotime($row1time);			$timeinterval=$trgroupcount*$teeperiod;			$teetime=date('H:i', strtotime("+$timeinterval minutes", $timestamp));			echo '<tr><td class="time">'.$teetime.'</td>';			$trcount++;			   $trgroupcount++;		}  		if($row['my_handicap_is'] >= -5 && $row['my_handicap_is'] <=6)		   {			$trclass="rowcol1";			}		elseif($row['my_handicap_is'] >= 7 && $row['my_handicap_is'] <=18)			{			$trclass="rowcol2";			}		else			{			$trclass="rowcol3";			}				if($col_count < (ceil($rowsarray[$current_table_count]*$total_col)/$total_col)+1)			{			//gather info for sms text file			$SMS_Time[$SMS_Count]=$teetime;			$SMS_Player[$SMS_Count] = strtoupper($row['name']).', '.strtoupper($row['surname']);			$SMS_Phone[$SMS_Count]=substr_replace($row['phone'], "27", 0, 1);			$SMS_Tee_off[$SMS_Count]=$SMSteeoff;			$SMS_Count++;?>					<td class="fullname <?php echo $trclass; ?>" width="<?php echo 78/$total_col; ?>%"><?php echo strtoupper($row['name']); ?>, <?php echo strtoupper($row['surname']); ?></td>					 <td class="hcap <?php echo $trclass; ?>" width="<?php echo 16/$total_col; ?>%"><?php echo $row['my_handicap_is']; ?>					</td><?php  			}		 $col_count++;		 if($col_count==$total_col)			  {			  echo "</tr>";			  $col_count=0;			  }		   $currentclub = $row['i_wish_to_play'];	   }//end while loop  	if($col_count<$total_col && $col_count!=0 && $currentclub !="") /// use to fill empty cells		{		for($i=$col_count;$i<$total_col;$i++)			{			echo "<td> </td><td> </td>";			}		   echo "</tr>";		}		fillemptygrouprows($trcount,$total_col, ceil($rowsarray[$current_table_count]));	?></table></div><div id="SMS_message_table" style="display:<?php echo $displaystatus2; ?>;"><table border="0" cellpadding="0" cellspacing="0" style="width:950px;margin:0 auto; font-size:11px;"><tr><th colspan="5">SMS MESSAGE SELECTION TO BE SAVED TO FILE</th></tr>	<?php 	$element_type=$_GET['elementtype'];$sel_index=$_GET['sel_indx'];		//produce list of players to send selected SMS messsage			for($smsloop=0; $smsloop<count($SMS_Time); $smsloop++)			{	message_populate($element,$sel_index,$club_tournament, $datet , $SMS_Player[$smsloop], $SMS_Time[$smsloop], $SMS_Tee_off[$smsloop], $SMS_Phone[$smsloop]);			}//Store SMS array info in hidden inputsforeach ($SMS_Player as $key => $value){ echo '<input type="hidden" name="SMS_Player[]" value="'.htmlspecialchars($value).'">';}foreach ($SMS_Time as $key => $value){ echo '<input type="hidden" name="SMS_Time[]" value="'.htmlspecialchars($value).'">';}foreach ($SMS_Tee_off as $key => $value){ echo '<input type="hidden" name="SMS_Tee_off[]" value="'.htmlspecialchars($value).'">';}foreach ($SMS_Phone as $key => $value){ echo '<input type="hidden" name="SMS_Phone[]" value="'.htmlspecialchars($value).'">';}echo '<input type="hidden" name="SMS_Date" value="'.$datet.'">';echo '<input type="hidden" name="SMS_Index" value="'.$sel_index.'">';			?>						</table></div>

Link to comment
Share on other sites

Thanks very much for all your effort.I so wish I could say what you say - I only got to do this yesterday - I can only imagine the things that ar epossible having such a wealth of knowledge.Again I appreciate all you do to help - THANK YOU.As you can see I have also been fidling on my side to get it to do certain things - more look and feel.In terms of reply:Must I know save the AJAx file as ajax.js as a file in order for it to action later?
you MUST have the ajax file 'ajax_update.js' with extension .js. It is a javascript file, which sends values to php file through 'get' method, the php file process the data, and shows the results, the js file then retrieves the results and shows it in a element with specific id reference, instantly without reload.
Link to comment
Share on other sites

You sure have done such a huge amount of work - thank youDo I just go and join them all up in one file one after the other, for it all to come together and work?
you should keep them separate, with the names i have given them, the only one you can change without causing linking problems, is the page with form 'sms_message_form.php'you will see links to the other files such as include('functions.php'); most php files<script type="text/javascript" src="ajax_update.js"></script> sms_message_form.php<form action="create_sms_file.php" method="post" name="tablecontroller" id="tablecontroller">sms_message_form.phptournament.php, and tournament_listing are the php pages which process the data passe fron js file and the name relates to the id reference, they are processing the data for, so don't rename those (id references or pages).EDIT: the script/code is exactly all that is required within the page for that specific filename for it to work, and nothing else.
Link to comment
Share on other sites

Ok,So I basically save them all as is - as .php files (5 off them) save one as a .js file and then leave all the names the same.The only changes then would be the " olf_db_form_nr_3" which would become "_Form_Nr_4" and then obviously the login and password.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...