Jump to content

nezbie

Members
  • Posts

    31
  • Joined

  • Last visited

    Never

Everything posted by nezbie

  1. SELECT DISTINCT id FROM table WHERE languages_id = "1" AND id NOT IN (SELECT DISTINCT id FROM table WHERE languages_id = "2") works fine - thanx for both answer, really appreciate it!
  2. Hi I have a table consisting of following data: id name languages_id None of those fields are unique, so one id can have multiple languages_id's.. My problem is, that I'd need to select all id's from the table where languages_id has a value of x, but not y.. So the idea in php is to copy all the fields to language y if it does not exists.. Example: id 20 does not exists in german (languages_id = 2), select this id. I've tried like (as simple as I thought it COULD be.. wasn't): SELECT DISTINCT id FROM table WHERE languages_id = "1" AND languages_id != "2" I'll try to work this out
  3. Hi I have a small question, would be nice if you could give me at least some hints or point me to the right direction.. anyways: My page has a list of products in a javascript-generated table. I'd need some help with my "add to cart" -button. It's not really a shopping cart but works kinda the same way. For you to understand let's call it shopping cart. I have an inframe php-page which should display all the items i add from the products list to the shopping cart. I thought the shopping cart would use PHP session variables. Now my question is, what would be the easiest way to perform this action? I use the iFrame becase I need to use PHP in the cart and also - the main page which contains the products table should not reload itself unless user decides to (else loses search and sorting options) So, shortly: Button that contains a certain value -> when clicked, pass that value to inframe -> update this value into PHP session variable with possible inframe pagereload Any suggestions and replies are more than welcome a big thank you - nez
  4. Hi Does anyone know any good php scripts that would change text as image, letter by letter or create a new phrase using a predefined font. I'd need to use a non-standard font (not Arial, Verdana etc) to create page headers and other dynamic text for my page. I thought the best way was to convert the text as an image using this special font. Is this possible? I'm not asking anyone to do the code for me. Just a hint or two, or a link to a script someone has made earlier I've tried to search the web a little, but since my native language is not English, correct search terms are a mystery :)
  5. I use it for: structure of textfields = mytextfield[rowNR][colNR] (has a value), like mytextfield[0][5] = value (can also be "value") all the data are read and written to a [b]textfile[/b] [b]// save post as CSV foreach ($_POST['mytextfield'] as $key=>$value) {     $parsedData .= implode(';', $value) . "\r\n"; } [/b] so when foreaching an array, or otherwise handling arrays but I print out $_POST before any action after I have submitted the form, the "errorneus data" is visible there already. So in the foreach loop, the $value could be anything like 1234 or "1234" or Jim or "Jim"
  6. Let's say i have lots of inputfields that have values where doublequotes are used, like: <input type="text" value="\"myvalue\"" name="mytextfield[0][0]"> ( used addslashes to prevent value=""myvalue""> ) In page, this displays correctly, also in sourcecode But when posting, $_POST array shows only \\ or " or \ where there should be a "myvalue". I've tried to search the forums and google / manual but no matter what i do the post array returns one of the following useless values described above.. What am I doing wrong with this? :'(
  7. Ok, that works, thank you very much :)
  8. Ok, I solved this. Gladly there was nothing wrong with the javascript code, but form positions on page. It seems to be "illegal" to build forms like <table><tbody><form><tr><td></td></tr></form></tbody></table>, Mozilla and evidently Opera cannot read the form properly, at least not with "dynamic fields". I didn't think this the first because I've never had this kind of trouble with forms. When I changed the form -tags right before and after the table tags, my page started working perfectly :S I'm glad though, I just have a lot to repair in my other scripts now x)
  9. Yes I have. It's just as clear as usual ;) I didn't quite understand the keys and headers thing.. should it be something like columnName=>[rowNumber] = value ? I've never been too good with these anyways - and if there is no at least moderately easy solution with current code logic I will just leave this feature not to be included.. It's not so important, rather "nice to have". I don't want to rewrite my script for this. Would I have to?
  10. [code] <head>   <script type="text/javascript"> <!-- function addEvent(maxCols) {   var ni = document.getElementById('myDiv');   var numi = document.getElementById('theValue');   var num = (document.getElementById('theValue').value -1)+ 2;   numi.value = num;   var divIdName = "my"+num+"Div";     var divContents = "";     for(a=0; a < maxCols; a++) {       divContents += "<input class=\"inputFields\" name=\"rowContents["+num+"]["+a+"]\" style=\"width: 150px;\" value=\"\" type=\"text\">&nbsp;";       }     var newdiv = document.createElement('div');   newdiv.setAttribute("id",divIdName);   newdiv.setAttribute("id",divIdName);   newdiv.innerHTML = "Rivi "+num+" "+divContents+"&nbsp;<a href=\"javascript:;\" onclick=\"removeEvent(\'"+divIdName+"\')\">Poista rivi "+num+"</a>";   ni.appendChild(newdiv); } function removeEvent(divNum) {   var d = document.getElementById('myDiv');   var olddiv = document.getElementById(divNum);   d.removeChild(olddiv); } //-->   </script> </head> <body> <input type="hidden" value="' { my start value goes here, numeric } '" id="theValue" /> <a href="javascript:;" onclick="addEvent(\'' . $colCount . '\');">Lisää rivejä</a><br /><br /> <div id="myDiv"> </div> </body> Live example on web, but not using forms (this is where I adapted my code and modified): [url]http://www.dustindiaz.com/add-and-remove-html-elements-dynamically-with-javascript/[/url] [/code]
  11. [quote]$row = my starting row(code from php as well the whle "add rows thingy")[/quote] It is filled correctly - so that is not the problem. For some reason mozilla ignores these fields created with javascript when posting the form. If I echo out print_r($_POST) after form submission with PHP, Mozilla only prints out values for fields generated with php. IE echoes out lines generated with PHP and Javascript.
  12. The console gives no errors/notices/warnings What might the problem be, did you know? ;)
  13. I don't get it.. Really. So if I want to sort array $foo[x][y] ascending by "y", I can't find any clear answers to that, if it's even possible with as little code as possible?
  14. [code] function addEvent(maxCols) {   var ni = document.getElementById('myDiv');   var numi = document.getElementById('theValue');   var num = (document.getElementById('theValue').value -1)+ 2;   numi.value = num;   var divIdName = "my"+num+"Div";     var divContents = "";     for(a=0; a < maxCols; a++) {       divContents += "<input class=\"inputFields\" name=\"rowContents["+num+"]["+a+"]\" style=\"width: 150px;\" value=\"\" type=\"text\">&nbsp;";       }     var newdiv = document.createElement('div');   newdiv.setAttribute("id",divIdName);   newdiv.setAttribute("id",divIdName);   newdiv.innerHTML = "Row "+num+" "+divContents+"&nbsp;<a href=\"javascript:;\" onclick=\"removeEvent(\'"+divIdName+"\')\">Poista rivi "+num+"</a>";   ni.appendChild(newdiv); }         <input type="hidden" value="' . $row . '" id="theValue" />         <a href="javascript:;" onclick="addEvent(\'' . $colCount . '\');">Add row</a><br /><br />         <div id="myDiv"> </div>[/code] $row = my starting row(code from php as well the whle "add rows thingy" Firefox (1.5.0.8) cannot read the field values that are dynamically added but IE(7) can. How should I modify this code that mozilla could read the field values? So when I post a form the elements dynamically created are posted within. No trouble in IE. Thanks
  15. Hi, this consideres my csv manager. It reads a csv file and drops the info to a table and to inputfields so they are editable. The basic structure goes like the following (example with 2 rows and 3 columns: [b] |  index  |  First name  | Last name  |  ID      |[/b] |    1    |  John          | Smith        |  2920    | |    2    |  Harry        |  Shearer  |  1032    | in the very first line of my csv file the column headers are defined. (in this case first name, last name, id) I'd need to be able to sort these information by column index (name is also possible if that is what is needed) I mentioned earlier that those information are found in inputfields. They are named like: [b]contents[rowNR][columnNR][/b], so "Shearer" is found in [b]$contents[2][2][/b] After I edit this info it is send via form to be rewritten to it's original sourcefile using the following simple piece of code: [code] foreach ($_POST['contents'] as $key=>$value) {     $parsedData .= implode(';', $value) . "\r\n"; } [/code] So what I'd need help with is sorting the array $contents[row][[b]with this key[/b]]. Also I'd need to be able to s[b]kip the row with index "0"[/b] because it is used to save the column header information. I hope you understand what I'm after here.. All help and ideas highly appreciated, thanks =)
  16. Thanks, I'll try these and see if I can get my app working. I have editable inputfields but I'll try to adapt your ideas to my own code. Thanks again.
  17. I've created a shitty csv editor to display and edit csv data. I'd need to be able to delete rows and colums (selected column for all the rows) with it. I've managed so far to delete rows only and I'm having a headache trying to think the column part through.. Although I believe I'm trying to do it the hard way - again.. The table consists of i[b]nputfields named data[rowIndex][columnIndex][/b], so when I have like 2 rows and 4 columns the output is following: data[0][0] data[0][1] data[0][2] data[0][3] data[1][0] data[1][1] data[1][2] data[1][3] and so on.. [code] foreach ($_POST['data'] as $key=>$value) {     // remove rows?   if(!empty($_POST['delete'])) {         // current row will NOT be deleted - if it is deleted do nothing (do not save info to $parsedData -variable        if(!array_search($key, $_POST['delete'])) {             $parsedData .= implode(';', $value) . "\r\n";     }   }   // no rows are selected for deletion - save all information to $parsedData normally   else {     $parsedData .= implode(';', $value) . "\r\n";       }   } // END foreach [/code] Columns to be deleted are selected with checkboxes, named as an array $deleteColumn[valueOfColumnIndex] like $selected[2] What would be the easiest (and hopely most performanced) way to check (and delete all array data with that index), for example if deleteColumn has a value of "2" So the hoped output therefore woud be (using the output example above): data[0][0] data[0][1] (deleted) data[0][3] data[1][0] data[1][1] (deleted) data[1][3] and so on.. Thank you so very much for your ideas and help on this one! :)
  18. *thinking* So I have these two tables. I have a form to select users. Those [b]users IDs[/b] are saved in this [b]$givenIDs[/b] variable. (comma separated, in php). My tables are [b]USERS[/b] and [b]DISTRIBUTION_LISTS[/b] [b]All users[/b] available for my form [b]are already found on USERS table[/b]. Anyhow, on this certain case I have to know if user has [b]already received email[/b]. This info is found on [b]DISTRIBUTION_LISTS[/b] table. Now, the DISTRIBUTION_LIST table might not hold the [b]userID[/b] in progress. If so, [b]email_sent[/b] should be [b]set to 0.[/b] So the problem with my current query is that if the [b]user_id[/b] exists in [b]USERS table[/b] but NOT in [b]DISTRIBUTION_LISTS[/b] table, mysql for some reason skips this row and [b]returns NO user_id OR NO value for email_sent[/b] - regardless if the user is found on one of the tables.. I have to get some value (null or 0) for [b]email_sent[/b] field for my php script to handle on..
  19. SELECT u.user_id, d.email_sent FROM users AS u LEFT JOIN distribution_list AS d ON u.user_id = d.user_id WHERE d.dlist_id = "' . $_POST['dlist_id'] . '" AND u.user_id IN (' . $givenIDs . ') ORDER BY u.user_id ASC Now that's the query. It works half. It now selects the right value for email sent IF THE USER IS FOUND ON distribution_lists TABLE. There will be a situation that all the IDs given in a comma separated list variable, $givenIDs won't be found on this table. Considering the query this way might help: 1) select the users info from USERS table. Then join DISTRIBUTION_LISTS to check if users info exists on that table and get only the EMAIL_SENT value true or false. Half way of winning this :)
  20. Hi I have two database fields looking like this: [b]distribution_lists[/b] (only relevant fields regarding this question dlist_id user_id email_sent [b]users[/b] (only relevant fields regarding this question user_id $toNewListQ = 'SELECT user_id, (SELECT d.email_sent FROM distribution_lists AS d LEFT JOIN users AS u ON u.user_id = d.user_id WHERE d.dlist_id = "' . $_POST['dlist_id'] . '" LIMIT 0,1) AS email_sent FROM users WHERE user_id IN (' . $givenIDs. ') ORDER BY user_id ASC'; Now, the problem is with this query, that the user who exists on users -table might not exists in distribution_list -table. My goal is to join the users table to the distr.list table and get info about if a certain user has sent email or not, if he/she has the row should return 1. If the user is on the distribution list and he/she has not sent email, it would return 0. If the user does not exist on the distribution list, it should return 0 (for email_sent -field value) Any ideas ? Thanx
  21. document.notifications_form.elements['lopullinen[]'] solved the problem.
  22. [code]<script language="javascript">   function doCopy(list1, list2) {          for (var i=0; i< list1.length; i++) {              if (list1.options[i].selected == true) {                  var cancopy = true;                  for (var j=0; j< list2.length; j++) {                      if (list1.options[i].value == list2.options[j].value) {                          cancopy = false; break;                    }                    }                  if (cancopy == true) {                      list2.options[list2.options.length] = new Option(list1.options[i].text, list1.options[i].value, false, true); }              }            }        } </script> <form name="notifications_form"> <select multiple size=5 name="jakelulista" style="width: 150px;">   <option value="1">1   <option value="2">2   <option value="3">3 </select> <input type="button" value="Siirrä arvo" onClick="doCopy(document.notifications_form.jakelulista,document.notifications_form.lopullinen);" /> <select multiple size=5 name="lopullinen" class="inputFields" style="width: 150px;"></select> </form>[/code] Ok, the code is above. It works fine. But, I'd need to pass multiple values in this selection list via the form. Now, when the name is just "lopullinen" it passes the last value in this list. I've tried different things to change this lists name in an array type name, like "lopullinen[]" when it can pass multiple values via the form, but the script stops working. Can someone help me with this, please?
  23. Hi I'd need an example of a query how to SELECT data between two given dates in mysql, I need it for my search function.. I think I'd need to somehow make sql convert given dates to different format than regular date (LIKE 2006-06-05).. So basicly something like this my query would be (english good, me Ralph :D): SELECT id FROM lists WHERE list_date_added BETWEEN 2006-06-01 AND 2006-06-06 That doesn't ofcourse work, it's like I told SQL to SEE if an elephant is more than 3.. Any help with this is appreciated greatly, thank you in advance!
  24. [!--quoteo(post=351199:date=Mar 2 2006, 08:33 PM:name=fenway)--][div class=\'quotetop\']QUOTE(fenway @ Mar 2 2006, 08:33 PM) [snapback]351199[/snapback][/div][div class=\'quotemain\'][!--quotec--] This makes no sense to me -- and obviously is the problem. With latin1, there shouldn't be any issues -- I dont' see how it can return _all_ the records. Could you post some examples? I'm stumped. [/quote] [code]// searchphrase is given? if($_GET['phrase']) {   // change special characters to umlauts   $toreplace = array(special characters); // these work, don't worry   $replacewith = array(umlauts..); // these work, don't worry   // change       $searchFor = htmlentities(str_replace($toreplace, $replacewith, $_GET['phrase']), ENT_QUOTES);   // search query   $searchQuery = 'SELECT n.news_id, n.categories_id, nv.news_header, nv.news_content FROM news AS n LEFT JOIN news_values AS nv ON n.news_id = nv.news_id WHERE MATCH(nv.news_header, nv.news_content) AGAINST("' . addslashes($searchFor) . '") AND nv.languages_id = "' . $_SESSION['languages_id'] . '"';   $searchResult = executeQuery($searchQuery, $conn); if(mysql_num_rows($searchResult) > 0) {   // loop through search results   $nr = 1;   echo '   <table>';   while($searchRow = mysql_fetch_array($searchResult)) {     $url = '<a href="index.php?pageID=news&categoriesID=' . $searchRow['categories_id'] . '&newsID=' . $searchRow['news_id'] . '">' . $searchRow['news_header'] . '</a>';          // show result in a row     echo '     <tr>       <td style="width: 18px; padding: 8px 0px 8px 0px;"><img src="' . dir_ws_images . 'arrow.gif"></td>       <td class="searchSmallHeader">' . $url . '</td>       <td style="width: 30px; text-align: right;">' . $nr . '.<td>     </tr>';   } echo ' </table>'; } // END if [/code] That's my search code. I've tried to keep it as simple as it gets..
  25. [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]CREATE TABLE `news_values` ( `news_values_id` int(11) NOT NULL auto_increment, `news_id` int(10) NOT NULL default '0', `news_header` varchar(255) NOT NULL default '', `news_content` text NOT NULL, `news_active` tinyint(1) NOT NULL default '1', `news_edited` datetime NOT NULL default '0000-00-00 00:00:00', `news_edited_id` int(11) NOT NULL default '1', `languages_id` tinyint(3) NOT NULL default '0', PRIMARY KEY (`news_values_id`), FULLTEXT KEY `news_fulltext` (`news_header`,`news_content`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=32 ; [/quote]
×
×
  • 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.