Jump to content

scottybwoy

Members
  • Posts

    532
  • Joined

  • Last visited

    Never

Everything posted by scottybwoy

  1. str_replace($CONSTANT, 'replace text', $string); Is what you want for that. So if you combine mine and skali's post then all you need to do is set up a assosiative array of the $CONSTANTS you want to change and maybe edit the str_replace() in the first post if your feeling brave. Don't worry about being a newb either, u gotta start somewhere. I'm no programmer, by a long shot and I've been playing with php 4 6mnts now and am feeling loads more confident now, keep it up
  2. Can't remember where I got these functions from and I'm not using them anymore, but I think that they are on the lines that you want : <?php function loadTemplate($file) { global $template; $strfile = $file; if (!file_exists($strfile)) print"Loading template failed!"; $thisfile = file($strfile); while(list($line,$value) = each($thisfile)) { $value = ereg_replace("(\r|\n)","",$value); $template .= "$value\r\n"; } return $template; } function insertTempData($file, $recordset_array) { global $template; $this->loadTemplate($file); foreach ($recordset_array as $key => $value) { $template = str_replace("id='" . $key . "' value=''", "id='" . $key . "' value='" . $value . "'", $template); } return $template; } ?> So what you need to do is pass your file to function loadTemplate($file), That will turn your file into one big long string called $template. Then create an array of constants you want to change, then pass them to function insertTempData($file, $recordset_array). Then do what you want with $template. Hope that helps
  3. OK I understand now, thanks. You have two css files for the page : <link rel="stylesheet" type="text/css" href="../httpd/styles/style.css" /> <link rel="stylesheet" type="print" href="../httpd/styles/print.css" /> Like so. Thanks
  4. How do you mean? <input type="Button" name="printit" class="print" value="print" onclick="javascript:window.print();"> or use onclick="javascript:printversion();" Then have that change the css source for the page and print?
  5. I have a function for that : <?php function selectSpecificMenu($field1, $field2, $table, $i) { $sql = mssql_query("SELECT $field1, $field2 FROM $table") or trigger_error("SQL", E_USER_ERROR); echo "<select action='submit' id='$field1' name='$field1' tabindex='$i'>"; while ($row = mssql_fetch_array($sql)) { // Loop through each element print("<option value='" . $row[0] . "'>" . $row[1] . "</option>"); } echo "</select>"; } ?> Then you can call that function in your html like so : <?php <div> <label for='select'>Select Menu :</label> <?php selectSpecificMenu('col1', 'col2', 'table', 'tabindex (must be an integer)'); ?> <input type='submit' name='select' id='select' value='Select' /> </div> ?> Then you need a function for you form data to do the next bit, happy programming ; )
  6. I use global quite a bit and thought I understood it. However When I call it in a function it seems to delete the contents let me show you how I'm utilising it: <?php function salesPrep($data_array) { global $data_array; echo '<u><b>$data_array</b></u><br>'; print_r($data_array); ?> I thought that would make it available to the code it returns too however it completely wipes the array. If I remove it, it works fine, but is not accessible to the rest of my code which I want, any pointers? Thanks.
  7. Could we have the modify mod back as sometimes as you get further towards the solution, you can point people to skip some entries.  Also Remove your own post might be good too and would save your servers some space ;)  Do like the Solved mod tho. keep it up
  8. Thanks to all, got mine fixed too now thanks.
  9. Is there a way to make it print out a printer friendly version?
  10. scottybwoy is different from timbrown, sorry to hijack the thread, but I am suffering the same problem. And why is it ugly, I just selected the settings I have set, cos I'm sure everyone has the same comments in their php.ini file. And isn't it down to the provider how they want their sessions handled. But I can see that mine isn't working how I want it too, any pointers would be helpful.
  11. Just a suggestion, if you are not using all the data from the database, you could select just the fields you want by specifying : <?php $sql = "SELECT DISTINCT 0, 4, 5, 6, 8 FROM players WHERE eventid = '$eventid')" while($row = mysql_fetch_row($result9)) { $playerid = $row[0] ; $fname = $row[1] ; $lname = $row[2] ; $gkname = $row[3] ; $rounds_comp = $row[4]; } etc... ?> Then you can look back at you qry to reference what the cols are and it'll speed up your script.
  12. Hi Tom, I tried your script and it did not increment. These are my session settings : session.save_handler = files session.save_path = "C:/php/tmp" session.use_cookies = false session.name = PHPSESSID session.auto_start = 0 session.cookie_lifetime = 20 session.cookie_path = / session.cookie_domain = session.serialize_handler = php session.gc_probability = 10 session.gc_divisor = 1000 session.gc_maxlifetime = 9000 session.bug_compat_42 = 0 session.bug_compat_warn = 1 session.referer_check = session.entropy_file = session.cache_limiter = nocache session.cache_expire = 180 session.use_trans_sid = 0 session.hash_function = 0 session.hash_bits_per_character = 5 url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry" Any ideas, where I have gone wrong?
  13. Hi I am having similar problems in this Post http://www.phpfreaks.com/forums/index.php/topic,128033.0.html here. I am using Win 2K SP4 IIS 5 I believe, although it seems to access data stored in a session from another page but clears data just omitted.
  14. I'm using classes, so it's already started elsewhere. I tried that but it just gave me a message telling me that its ignoring that command as it's already started. Also if you read my post it does mention that it is holding the data stored prior to this script execution. Thanks anyway
  15. I want to use $_SESSION array as I want to hold some other data too, and this isn't working for some reason. This script is run three times; 1st - Without any data sent - the form is just called. 2nd - With 'custId' sent - this data is then returned to the form. 3rd -With 'company' and 'clientId' sent - then back to the rest of the form. What I want is all of that data stored as it comes available. Seems simple enough, until I try it. So what I have created is a $_SESSION var for each piece of data to make it simple; $_SESSION['scustId'] = $custId, $_SESSION['scompany'] = $company, $_SESSION['sclientId'] = $clientId, $_SESSION['sclient'] = $client. Then further down I produce a printout of the $_SESSION data: <?php foreach($_SESSION as $key => $value){ echo "<strong>".$key." : </strong>".$value."<br>"; } ?> This holds all my $_SESSION vars from other pages in my script, but when it comes to this particular function, it works in a peculiar way. 1st execution - Prints out all previous $_SESSION data. 2nd execution - Prints out previous and 'scustId' + 'scompany', so far so good. 3rd execution - Prints out previous and 'sclientId' + 'sclient, 'scustId' + 'scompany' are gone! What could be unsetting this data? Here's the complete code : <?php function saleLoad() { global $data_array; $data_array = $_POST; if (isset($data_array['custId']) && empty($data_array['company'])) { $_SESSION['scustId'] = $data_array['custId']; $_SESSION['scompany'] = $this->selectRecord('company', 'customers', 'custId', $data_array['custId']); } if (isset($data_array['clientId']) && empty($data_array['name'])) { $_SESSION['sclientId'] = $data_array['clientId']; $_SESSION['sclient'] = $this->selectRecord('name', 'client', 'clientId', $data_array['clientId']); } foreach($_SESSION as $key => $value){ echo "<strong>".$key." : </strong>".$value."<br>"; } if (!empty($_SESSION['scustId']) && !empty($_SESSION['sclientId'])) { //$this->salesPrep($_SESSION['s*']); } include_once(MK_SALE_PAGE); } ?> Thanks for your help.
  16. If you give each $row_rsExtConst['$k'], a separate id Key possibly in a 3D array, then you can post that id number with value="<?php echo $row_rsExtConst['extConstDesc'][0]?>" Which will return the unique id number so the script doesn't get confused. Hope that makes sense
  17. What you need to incorporate here is classes, you can have all your defined functions stored in a few scripts/directories then call them at will. It's too big a topic to explain in one forum post, so what I suggest is that you look for a few tutorials / explanations on the net good luck
  18. Back to this problem, sorry. I will need to use $_SESSION array as I want to hold some other data too, and this isn't working for some reason. This script is run three times; 1st - Without any data sent - the form is just called. 2nd - With 'custId' sent - this data is then returned to the form. 3rd -With 'company' and 'clientId' sent - then back to the rest of the form. What I want is all of that data stored as it comes available. Seems simple enough, until I try it. So what I have created is a $_SESSION var for each piece of data to make it simple; $_SESSION['scustId'] = $custId, $_SESSION['scompany'] = $company, $_SESSION['sclientId'] = $clientId, $_SESSION['sclient'] = $client. Then further down I produce a printout of the $_SESSION data: <?php foreach($_SESSION as $key => $value){ echo "<strong>".$key." : </strong>".$value."<br>"; } ?> This holds all my $_SESSION vars from other pages in my script, but when it comes to this particular function, it works in a peculiar way. 1st execution - Prints out all previous $_SESSION data. 2nd execution - Prints out previous and 'scustId' + 'scompany', so far so good. 3rd execution - Prints out previous and 'sclientId' + 'sclient, 'scustId' + 'scompany' are gone! What could be unsetting this data? Here's the complete code : <?php function saleLoad() { global $data_array; $data_array = $_POST; if (isset($data_array['custId']) && empty($data_array['company'])) { $_SESSION['scustId'] = $data_array['custId']; $_SESSION['scompany'] = $this->selectRecord('company', 'customers', 'custId', $data_array['custId']); } if (isset($data_array['clientId']) && empty($data_array['name'])) { $_SESSION['sclientId'] = $data_array['clientId']; $_SESSION['sclient'] = $this->selectRecord('name', 'client', 'clientId', $data_array['clientId']); } foreach($_SESSION as $key => $value){ echo "<strong>".$key." : </strong>".$value."<br>"; } if (!empty($_SESSION['scustId']) && !empty($_SESSION['sclientId'])) { //$this->salesPrep($_SESSION['s*']); } include_once(MK_SALE_PAGE); } ?> Thanks for your help.
  19. thought $GLOBALS might hold the answer, but that pushed me to work out how I could keep all the info I wanted, script looks a bit like this now : <?php global $data_array, $product, $prodId, $template; $data_array = $_POST; if (isset($data_array['custId']) && empty($data_array['company'])) { $data_array['company'] = $this->selectRecord('company', 'customers', 'custId', $data_array['custId']); } if (isset($data_array['clientId']) && empty($data_array['name'])) { $data_array['name'] = $this->selectRecord('name', 'client', 'clientId', $data_array['clientId']); } include_once(MK_SALE_PAGE); ?> And my template still looks the same. Thanks anyway
  20. This is my array_push_assoc() if anyone want's it or think it may help unravelling my problem, thanks. <?php function array_push_associative(&$arr) { $args = func_get_args(); foreach ($args as $arg) { if (is_array($arg)) { foreach ($arg as $key => $value) { $arr[$key] = $value; //$ret++; } } else { $arr[$arg] = ""; } } //return $ret; } ?>
  21. Is their a way of telling what data is added first to use as a handle for the row you want to add the data too, then you can use UPDATE table SET col1='$var1', col2='$var2' WHERE col3='$var3' Otherwise there is no way of testing where you put the data. So use Select on a column where you will know the data i.e name or timestamp both would be better then use one of those to update the specific row, good luck
  22. I think from your code it is $channel_list, is that your incrementing number that orders your list, sorry can't be arsed to make sense of it all. But that is what papaface is trying to tell you. The &1 option seperates the odd items in the list from the even ones. Good Luck
  23. I'm using classes so my session is already started elsewhere so that it doesn't get messed up by headers and stuff, thanks though.
  24. What your If statement will do is see if the $var that you are checking does not equal exactly what you have between the quotes. You may find a more accurate fuction on this page http://fr3.php.net/manual/en/ref.strings.php pluss loads more things you can do with strings, enjoy.
  25. Hi, No that didn't do anything. I was in a bit of a rush yesterday so didn't write it clearly. What I am doing is passing data from the user via selection boxes. Each time its sent this script is called but is sent different bits of data. But I want it to hold the data that was sent b4. Until it has done what it needs to do with it. I have amended the script as above and below is my html : <?php if (isset($data_array['clientId']) && isset($data_array['company'])) { ?> <form name="clientAdmin" action='home.php' method='POST'> <input type='hidden' name='content' value='sale' /> <div class='l'> <label for='company' class='labelL'>Company :</label> <input type='text' id='company' value='<?php echo $data_array['company'] ?>' name='company' size='25%' class='required labelL' readonly /> </div> <div class='r'> <label for='clientId' class='labelL'>Client :</label> <input type='text' id='clientId' value='<?php echo $data_array['clientId'] ?>' name='clientId' size='25%' class='required labelL' readonly /> </div> <?php } elseif (isset($data_array['company']) && isset($data_array['custId']) && $_REQUEST['select'] == 'Select Company') { ?> <form name="clientSelect" action='home.php' method='POST'> <input type='hidden' name='content' value='sale' /> <div class='l'> <label for='company' class='labelL'>Company :</label> <input type='text' id='company' value='<?php echo $data_array['company'] ?>' name='company' width='22%' class='required labelL' readonly /> </div> <div class='r'> <label for='clientId'>Client ID :</label> <?php Template::selectWhereMenu('clientId', 'name', 'client', 'custId', $data_array['custId'], '1'); ?> <input type='submit' name='select' id='select' value='Select Client' class='btn' onmouseover="this.className='btn btnhov'" onmouseout="this.className='btn'" /> </div> <?php } else { ?> <form name="custSelect" action='home.php' method='POST'> <input type='hidden' name='content' value='sale' /> <div> <label for='custId' class='labelL'>Company :</label> <?php Template::selectSpecificMenu('custId', 'company', 'customers', '1'); ?> <input type='submit' name='select' id='select' value='Select Company' class='btn' onmouseover="this.className='btn btnhov'" onmouseout="this.className='btn'" /> </div> <?php } ?> The rest is the rest of my form. Any ideas, how I can do this?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.