Jump to content

gurroa

Members
  • Posts

    87
  • Joined

  • Last visited

    Never

Everything posted by gurroa

  1. Ok, try this: http://php.gurroa.cz/topics.php <?php mysql_connect('localhost', '*******', '******'); mysql_select_db('gurroa'); ?> <html> <body> <form name="test" method="post" action="topics.php"> Pick topic id:<br /> <input type="text" name="topic_id" /> <input type="submit" value="show" /> </form> <br /> <? if (isset($_POST['topic_id'])) { $id = $_POST['topic_id']; $que = mysql_query("SELECT * FROM topics WHERE ( (topics = '$id') or (topics like '$id-%') or (topics like '%-$id') or (topics like '%-$id-%') ) "); if (mysql_num_rows($que) > 0) { echo 'Topics with topic_id '.$id.'<br />'. '<table>'. '<tr><th>ID</th><th>Topics IDs</th></tr>'; while($row = mysql_fetch_assoc($que)) { echo '<tr><td>'.$row['id'].'</td><td>'.$row['topics'].'</td></tr>'; } echo '</table>'; } else { echo 'Now topics were found!'; } } ?> </body> </html>
  2. lets explain why this mysql_query("SELECT * FROM tbl WHERE field IN (".implode(',',$myvar)."); will never work if field value will be "42-32-4" because WHERE '42-32-4' in (4) will always fail...
  3. My solution is really for your problem... :-)
  4. gurroa

    Hi Guys

    select FIELDWITHPRODUKTNAME, count(FIELDWITHPRODUKTNAME) from YOURTABLE group by FIELDWITHPRODUKTNAME, FIELD1, FIELD2, FIELD3... all field identifing a duplicate
  5. How about this? SELECT * FROM users where groupid = 2 or groupid = 4 group by userid
  6. Solution: mysql_query("SELECT * FROM tbl WHERE ( (fieldArray = '$myvar') or (fieldArray like '$myvar,%') or (fieldArray like '%,$myvar') or (fieldArray like '%,$myvar,%') ) "); This all because of this example: lets $myvar become 1 now you want all records from your table with this fieldArray values "1", "1,42,45", "45,1,42", "42,45,1"
  7. I would do it in different way: First count winnings and loosings: $arteam = array(); $query = mysql_query('select team_id from teams order by team_id'); while($row = mysql_fetch_array($query)) { $arteam[$row['team_id']] = array( 'won' => 0, 'lost' => 0 ); } $query = mysql_query('select winner, team_id_1, team_id_2 from matches'); while($row = mysql_fetch_array($query)) { $tm1id = $row['team_id_1']; $tm2id = $row['team_id_2']; if ($row['winner'] == $tm1id) { $arteam[$tm1id]['won'] += 1; $arteam[$tm2id]['lost'] += 1; } else { $arteam[$tm1id]['lost'] += 1; $arteam[$tm2id]['won'] += 1; } } reset($arteam); while(list($id, $wonlostarray) = each($arteam)) { mysql_query(sprintf(" update teams set games_won = %d, games_lost = %d WHERE team_id = %d ", $id, $wonlostarray['won'], $wonlostarray['lost'] )); }
  8. As written in the manual: resource mysql_query ( string $query [, resource $link_identifier ] ) So try this: $result = mysql_query($query, $dbc) or better (if you have only one connection): $result = mysql_query($query);
  9. You get your warning because of definition of mysql_affected_rows() function: int mysql_affected_rows ([ resource $link_identifier ] ) If you got no echo statements it could mean that php stop on error... Try this one: <?php $DBConnect = mysql_connect("localhost", "root"); if(isset($_POST['submit'])) { mysql_select_db("dietetics", $DBConnect) or die(mysql_errno() . ": " . mysql_error() . "<br>"); $delete = sprintf("delete from members where id = '%s'", isset($_POST['name']) ? $_POST['name'] : null ); $result = mysql_query($delete); if (mysql_affected_rows() > 0) { echo "The row has been deleted, successfully"; } else { echo "No rows have been deleted"; } } ?> ...
  10. Syntax error on line 39 (= instead of ==) if(value==null || value=='') Syntax error on line 81 (: instead of ; ) chapter.focus(); Syntax error on line 103 (missing end of if statement) if(required(zip, 'Please enter your zip code.')==false) Syntax error on line 115 (missing end of if statement) if(required(ctitle, 'Please enter your title.')==false) Syntax error on line 57 (dotpos instead of fotpos) if(apos<1 || fotpos-apos<2) I think that's all.
  11. You have to call setTimeout in the same way you've called animatePath for the first time. Considering that setTimeout will call it's function from the global scope. Maybe if you post bigger part of your script...
  12. echo Date("F", strtotime("+1 month", strtotime(Date("Y-m-01")) ));
  13. function f($x) { return $x > 0 ? 1 : 0; } function f2($x) { return floor(abs($x / abs($x+0.00000001)+0.001)); }
  14. You will need more scripts to include in your page. See http://demos.mootools.net/Tips docs references.
  15. <a href="javascript:q_search.submit();">Search</a>
  16. And what is ppoly? Object? Than you can't use setTimeout syntax as you did. Because in fact it than call somethink like animatePath([object]). If ppoly is stored in some global array or it is an element of the document use setTimeout('animatePath(document.getElementById("'+ppoly.id+'")', tick); or setTimeout('animatePath(getPoly(ppoly.id))', tick); where getPoly is function that retrieve ppoly object.
  17. And how do you store images into the database? If you don't store them base64 encoded than you can't retrieve them as base64 decode.
  18. You have to pick elements by their ID not refer them directly. Like selFont select. I've changed it to have ID value set to "selFont" instead of Name value. And the same with other select boxes. Try it. <html> <head> <title> Browser Based HTML Editor </title> <script language="JavaScript"> var viewMode = 1; // WYSIWYG var broswer; browser = navigator.appName; function Init() { if(browser == "Netscape") { document.getElementById('iView').contentDocument.designMode = "on"; } else if(browser == "Microsoft Internet Explorer") { iView.document.designMode = 'On'; } } function selOn(ctrl) { ctrl.style.borderColor = '#000000'; ctrl.style.backgroundColor = '#B5BED6'; ctrl.style.cursor = 'hand'; } function selOff(ctrl) { ctrl.style.borderColor = '#D6D3CE'; ctrl.style.backgroundColor = '#D6D3CE'; } function selDown(ctrl) { ctrl.style.backgroundColor = '#8492B5'; } function selUp(ctrl) { ctrl.style.backgroundColor = '#B5BED6'; } function doBold() { if(browser == "Netscape") { document.getElementById('iView').contentDocument.execCommand('bold', false, null); } else if(browser == "Microsoft Internet Explorer") { iView.document.execCommand('bold', false, null); } } function doItalic() { if(browser == "Netscape") { document.getElementById('iView').contentDocument.execCommand('italic', false, null); } else if(browser == "Microsoft Internet Explorer") { iView.document.execCommand('italic', false, null); } } function doUnderline() { if(browser == "Netscape") { document.getElementById('iView').contentDocument.execCommand('underline', false, null); } else if(browser == "Microsoft Internet Explorer") { iView.document.execCommand('underline', false, null); } } function doLeft() { if(browser == "Netscape") { document.getElementById('iView').contentDocument.execCommand('justifyleft', false, null); } else if(browser == "Microsoft Internet Explorer") { iView.document.execCommand('justifyleft', false, null); } } function doCenter() { if(browser == "Netscape") { document.getElementById('iView').contentDocument.execCommand('justifycenter', false, null); } else if(browser == "Microsoft Internet Explorer") { iView.document.execCommand('justifycenter', false, null); } } function doRight() { if(browser == "Netscape") { document.getElementById('iView').contentDocument.execCommand('justifyright', false, null); } else if(browser == "Microsoft Internet Explorer") { iView.document.execCommand('justifyright', false, null); } } function doOrdList() { if(browser == "Netscape") { document.getElementById('iView').contentDocument.execCommand('insertorderedlist', false, null); } else if(browser == "Microsoft Internet Explorer") { iView.document.execCommand('insertorderedlist', false, null); } } function doBulList() { if(browser == "Netscape") { document.getElementById('iView').contentDocument.execCommand('insertunorderedlist', false, null); } else if(browser == "Microsoft Internet Explorer") { iView.document.execCommand('insertunorderedlist', false, null); } } function doForeCol() { var fCol = prompt('Enter foreground color', ''); if(browser == "Netscape") { if(fCol != null) document.getElementById('iView').contentDocument.execCommand('forecolor', false, fCol); } else if(browser == "Microsoft Internet Explorer") { if(fCol != null) iView.document.execCommand('forecolor', false, fCol); } } function doBackCol() { var bCol = prompt('Enter background color', ''); if(browser == "Netscape") { if(bCol != null) document.getElementById('iView').contentDocument.execCommand('backcolor', false, bCol); } else if(browser == "Microsoft Internet Explorer") { if(bCol != null) iView.document.execCommand('backcolor', false, bCol); } } function doLink() { if(browser == "Netscape") { document.getElementById('iView').contentDocument.execCommand('createlink'); } else if(browser == "Microsoft Internet Explorer") { iView.document.execCommand('createlink'); } } function doImage() { var imgSrc = prompt('Enter image location', ''); if(browser == "Netscape") { if(imgSrc != null) document.getElementById('iView').contentDocument.execCommand('insertimage', false, imgSrc); } else if(browser == "Microsoft Internet Explorer") { if(imgSrc != null) iView.document.execCommand('insertimage', false, imgSrc); } } function doRule() { if(browser == "Netscape") { document.getElementById('iView').contentDocument.execCommand('inserthorizontalrule', false, null); } else if(browser == "Microsoft Internet Explorer") { iView.document.execCommand('inserthorizontalrule', false, null); } } function doFont(fName) { if(browser == "Netscape") { if(fName != '') document.getElementById('iView').contentDocument.execCommand('fontname', false, fName); } else if(browser == "Microsoft Internet Explorer") { if(fName != '') iView.document.execCommand('fontname', false, fName); } } function doSize(fSize) { if(browser == "Netscape") { if(fSize != '') document.getElementById('iView').contentDocument.execCommand('fontsize', false, fSize); } else if(browser == "Microsoft Internet Explorer") { if(fSize != '') iView.document.execCommand('fontsize', false, fSize); } } function doHead(hType) { if(browser == "Netscape") { if(hType != '') { document.getElementById('iView').contentDocument.execCommand('formatblock', false, hType); doFont(document.getElementById('selFont').options[document.getElementById('selFont').selectedIndex].value); } } else if(browser == "Microsoft Internet Explorer") { if(hType != '') { iView.document.execCommand('formatblock', false, hType); doFont(document.getElementById('selFont').options[document.getElementById('selFont').selectedIndex].value); } } } function doToggleView() { if(viewMode == 1) { if(browser == "Netscape") { iHTML = document.getElementById('iView').innerHTML; document.getElementById('iView').innerText = iHTML; // Hide all controls document.getElementById('tblCtrls').style.display = 'none'; document.getElementById('selFont').style.display = 'none'; document.getElementById('selSize').style.display = 'none'; document.getElementById('selHeading').style.display = 'none'; document.getElementById('iView').focus(); viewMode = 2; // Code } else if(browser == "Microsoft Internet Explorer") { iHTML = iView.document.body.innerHTML; iView.document.body.innerText = iHTML; // Hide all controls tblCtrls.style.display = 'none'; document.getElementById('selFont').style.display = 'none'; document.getElementById('selSize').style.display = 'none'; document.getElementById('selHeading').style.display = 'none'; iView.focus(); viewMode = 2; // Code } } else { if(browser == "Netscape") { iText = document.getElementById('iView').innerText; document.getElementById('iView').innerText = iText; // Show all controls document.getElementById('tblCtrls').style.display = 'inline'; document.getElementById('selFont').style.display = 'inline'; document.getElementById('selSize').style.display = 'inline'; document.getElementById('selHeading').style.display = 'inline'; iView.focus(); viewMode = 1; // WYSIWYG } else if(browser == "Microsoft Internet Explorer") { iText = iView.document.body.innerText; iView.document.body.innerHTML = iText; // Show all controls tblCtrls.style.display = 'inline'; document.getElementById('selFont').style.display = 'inline'; document.getElementById('selSize').style.display = 'inline'; document.getElementById('selHeading').style.display = 'inline'; iView.focus(); viewMode = 1; // WYSIWYG } } } </script> <style> .butClass { border: 1px solid; border-color: #D6D3CE; } .tdClass { padding-left: 3px; padding-top:3px; } </style> <body onLoad="Init()"> <table id="tblCtrls" width="415px" height="30px" border="0" cellspacing="0" cellpadding="0" bgcolor="#D6D3CE"> <tr> <td class="tdClass"> <img alt="Bold" class="butClass" src="bold.gif" onMouseOver="selOn(this)" onMouseOut="selOff(this)" onMouseDown="selDown(this)" onMouseUp="selUp(this)" onClick="doBold()"> <img alt="Italic" class="butClass" src="italic.gif" onMouseOver="selOn(this)" onMouseOut="selOff(this)" onMouseDown="selDown(this)" onMouseUp="selUp(this)" onClick="doItalic()"> <img alt="Underline" class="butClass" src="underline.gif" onMouseOver="selOn(this)" onMouseOut="selOff(this)" onMouseDown="selDown(this)" onMouseUp="selUp(this)" onClick="doUnderline()"> <img alt="Left" class="butClass" src="left.gif" onMouseOver="selOn(this)" onMouseOut="selOff(this)" onMouseDown="selDown(this)" onMouseUp="selUp(this)" onClick="doLeft()"> <img alt="Center" class="butClass" src="center.gif" onMouseOver="selOn(this)" onMouseOut="selOff(this)" onMouseDown="selDown(this)" onMouseUp="selUp(this)" onClick="doCenter()"> <img alt="Right" class="butClass" src="right.gif" onMouseOver="selOn(this)" onMouseOut="selOff(this)" onMouseDown="selDown(this)" onMouseUp="selUp(this)" onClick="doRight()"> <img alt="Ordered List" class="butClass" src="ordlist.gif" onMouseOver="selOn(this)" onMouseOut="selOff(this)" onMouseDown="selDown(this)" onMouseUp="selUp(this)" onClick="doOrdList()"> <img alt="Bulleted List" class="butClass" src="bullist.gif" onMouseOver="selOn(this)" onMouseOut="selOff(this)" onMouseDown="selDown(this)" onMouseUp="selUp(this)" onClick="doBulList()"> <img alt="Text Color" class="butClass" src="forecol.gif" onMouseOver="selOn(this)" onMouseOut="selOff(this)" onMouseDown="selDown(this)" onMouseUp="selUp(this)" onClick="doForeCol()"> <img alt="Background Color" class="butClass" src="bgcol.gif" onMouseOver="selOn(this)" onMouseOut="selOff(this)" onMouseDown="selDown(this)" onMouseUp="selUp(this)" onClick="doBackCol()"> <img alt="Hyperlink" class="butClass" src="link.gif" onMouseOver="selOn(this)" onMouseOut="selOff(this)" onMouseDown="selDown(this)" onMouseUp="selUp(this)" onClick="doLink()"> <img alt="Image" class="butClass" src="image.gif" onMouseOver="selOn(this)" onMouseOut="selOff(this)" onMouseDown="selDown(this)" onMouseUp="selUp(this)" onClick="doImage()"> <img alt="Horizontal Rule" class="butClass" src="rule.gif" onMouseOver="selOn(this)" onMouseOut="selOff(this)" onMouseDown="selDown(this)" onMouseUp="selUp(this)" onClick="doRule()"> </td> </tr> </table> <iframe id="iView" style="width: 415px; height:205px; display: block;"> <table> <tr> <td>dsds</td> </tr> </table> </iframe> <table width="415px" height="30px" border="0" cellspacing="0" cellpadding="0" bgcolor="#D6D3CE"> <tr> <td class="tdClass" colspan="1" width="80%"> <select id="selFont" onChange="doFont(this.options[this.selectedIndex].value)"> <option value="">-- Font --</option> <option value="Arial">Arial</option> <option value="Courier">Courier</option> <option value="Sans Serif">Sans Serif</option> <option value="Tahoma">Tahoma</option> <option value="Verdana">Verdana</option> <option value="Wingdings">Wingdings</option> </select> <select id="selSize" onChange="doSize(this.options[this.selectedIndex].value)"> <option value="">-- Size --</option> <option value="1">Very Small</option> <option value="2">Small</option> <option value="3">Medium</option> <option value="4">Large</option> <option value="5">Larger</option> <option value="6">Very Large</option> </select> <select id="selHeading" onChange="doHead(this.options[this.selectedIndex].value)"> <option value="">-- Heading --</option> <option value="Heading 1">H1</option> <option value="Heading 2">H2</option> <option value="Heading 3">H3</option> <option value="Heading 4">H4</option> <option value="Heading 5">H5</option> <option value="Heading 6">H6</option> </select> </td> <td class="tdClass" colspan="1" width="20%" align="right"> <img alt="Toggle Mode" class="butClass" src="mode.gif" onMouseOver="selOn(this)" onMouseOut="selOff(this)" onMouseDown="selDown(this)" onMouseUp="selUp(this)" onClick="doToggleView()"> </td> </tr> </table> </body> </html>
  19. You have error in the query. select * FROM TABLE where item_name = ....
  20. Add first call to updatePos() at the end of toolTip() function. function toolTip(text,me) { theObj=me; theObj.onmousemove=updatePos; document.getElementById('toolTipBox').innerHTML=text; document.getElementById('toolTipBox').style.display="block"; window.onscroll=updatePos updatePos(); } I've try it in IE and Mozilla and everythink seem to be ok.
  21. Yes. You can atleast join them into one script. <?php // joinscript.php // optionally disable cache Header("Pragma: no-cache"); Header("Cache-Control: no-cache"); Header("Expires: ".GMDate("D, d M Y H:i:s")." GMT"); function GetCont($file) { if (file_exists($file)) { $arr = explode("\r\n", file_get_contents($file)); $retarr = array(); reset($arr); while(list(,$l) = each($arr)) { $l = trim($l); if (!empty($l)) $retarr[] = $l; } return "\n".implode("\n", $retarr)."\n"; } } echo GetCont('./first_script.js'); echo GetCont('./second_script.js'); ?> To call such joining use <script type="text/javascript" language="JavaScript1.2" src="joinscript.php"></script>
  22. First is the query for "select MAX(id)". And the loop try to fetch 132 rows started from id = 1 to id = 132.
  23. Disagree. Imagine that you have three rows in such table id cola 85 boo 93 foo 132 boo2 Now you will query dbase 133times to read 3 rows with 129 error messages.
  24. $res = mysql_query("select cola from table"); while($row = mysql_fetch_assoc($res)) { echo $row['cola']."<br />"; }
×
×
  • 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.