Jump to content

bulrush

Members
  • Posts

    185
  • Joined

  • Last visited

    Never

Everything posted by bulrush

  1. Anyone know how to send a Javascript string and store it in a php variable?
  2. In IE 8.0, in the top row of the toolbar, there is the back button, forward button, the URL box, 3 more buttons, and a Google search box. The URL box is too short to show the whole address of my URL and I need to view the whole address sometimes. How do I get rid of the Google search box? I have looked in Internet Options, and tried to drag it but I can't seem to get rid of it. I will never use it. I also tried to remove search engines from Internet Options with no luck. Thanks.
  3. Because with a tool, it will save me 2 minutes of typing each time I do this, and I do this a lot while developing. So I am saving 20 minutes, then 200 minutes, etc. The time saved adds up. I made my own tool to do this for MS Access but I don't have it anymore. EDIT: I did not realize I could do a multi-line query assigned to a PHP variable. Thanks!
  4. Your options are: 1) Get read-only access directly into the site database. Talk to the site owners and state you just want READ ONLY access, which will prevent you (or a hacker who hacks your program) from messing with their db. 2) Ask the site owners to provide data you need in a tab-delimited text file. Update the file each day. The site owners can automate this process using unix cron and use SQL to dump the data you need from a query into a text file. (Is once a day enough for your purposes?) 3) Write your own screen scraper.
  5. This is not quite working. A bullet is a line of descriptive text. Each part has one or more bullets associated with it. However, each part can appear under one or more brands. The user needs to be able to copy all bullet text from one brand to another, and change the bullet text as they desire. My task: if the current brand for a given part has no bullets, allow the user to copy bullet text from another brand. List in a SELECT box only brands which are not the current brand, and which have more than zero bullets. This SELECT box contains the brand to copy bullets from. The SELECT box contents is based on the query below. Here is my current query: $query2="SELECT brands.brand, brands.partid, bullets.bullid, ". "bullets.bullettext, bullets.buorder, ". "count(bullets.partid) as bucnt, bullets.partid as bupartid ". "FROM brands ". "JOIN bullets ON (brands.partid=bullets.partid) ". "WHERE (brands.partid=".$partid.") ". "AND (brands.brand<>'".$brand."') ". "GROUP BY brand ". "HAVING bucnt > 0 ". "ORDER BY brand, partid ". ";"; It correctly excludes the current brand, but it incorrectly lists a brand with zero bullets, which I will call brand "C". Anyone know how to fix this? I double checked my bullets table and there are no bullets for brand "C", but brand "C" appears in my <SELECT> box.
  6. I'm looking for a Windows utility to convert this: SELECT brands.brand, brands.partid, bullets.bullid, bullets.bullettext, bullets.buorder, count(bullets.partid) as bucnt, bullets.partid as bupartid FROM brands JOIN bullets ON (brands.partid=bullets.partid) WHERE (brands.partid=".$partid.") AND (brands.brand<>'".$brand."') GROUP BY brand HAVING bucnt > 0 ORDER BY brand, partid; to this: $query2="SELECT brands.brand, brands.partid, bullets.bullid, ". "bullets.bullettext, bullets.buorder, ". "count(bullets.partid) as bucnt, bullets.partid as bupartid ". "FROM brands ". "JOIN bullets ON (brands.partid=bullets.partid) ". "WHERE (brands.partid=".$partid.") ". "AND (brands.brand<>'".$brand."') ". "GROUP BY brand ". "HAVING bucnt > 0 ". "ORDER BY brand, partid ". ";";
  7. Are you trying to grab data from a generated web page, like from the link you gave? I would call that "screen scraping". Basically, you put the whole webpage into a string and parse the string, one line at a time. Or, make it an array, each entry in the array is a line in the html file. HTML is just text, after all. I did this once using MS Access and the Yahoo stock quote page.
  8. $source=preg_replace('/\.$/', '', $source); param1=regex to search for, must be enclosed in 2 slashes, one at each end. param2=string to replace with param3=string to search and replace on If (preg_match('/\+([\d\.])+k/', $change, $matches)) { //Full match of whole regex is in $matches[0]. //First parenthesis match in $matches[1]. $amt=$matches[1]; $fullamt=$amt*1000; } //If k is 1000, then m must mean a million. If (preg_match('/\+([\d\.])+m/', $change, $matches)) { $amt=$matches[1]; //Full match of whole regex is in $matches[0]. $fullamt=$amt*1000000; } In your case: $change=preg_replace('/^\+/', '', $change); //Drop + at beginning of string, + must be escaped with backslash. $change=preg_replace('/[km]$/', '', $change); //Drop k or m at end of string ^ represents beginning of string $ represents end of string That will get you started.
  9. So, in PHP would it look like this? echo 'Date: '.<script>document.write(new Date().toString());</script>.'<br/>'; Or, how would I assign this string to a PHP variable? Thanks. I learn by asking questions.
  10. Begin new to Javascript, how would I output that JS string to the browser? Instead of via a JS window? The browser is viewing a page which will be printed on paper, and the paper must have the local date and time on it.
  11. I just double checked the LIKE docs and SQL does support Abdbuet's [0-9] syntax. His way is less typing. OTOH, if you want to show all items that DON'T begin with letters, you can also do this: SELECT * FROM mytable WHERE myfield like '[!a-zA-Z]%'; ! is a negator.
  12. SELECT * FROM mytable WHERE mytextfield like 'a%'; % is a wildcard representing zero or more characters, just like * in unix. For a single character wildcard in SQL, use underscore (_). Ooops, I see your question now. SELECT * FROM mytable WHERE (myfield like '0%') or (myfield like '1%') or (myfield like '2%') or (myfield like '3%') or (myfield like '4%') ... Get the idea?
  13. PHP 5.2.6 We rent PHP server space on a server in California. Several of my pages generated by PHP show the current date and time, so when the page is printed, the user knows when the data was printed. Our users could be anywhere in the US, I am in Michigan. How do I convert the server time (PDT) into local time, regardless of where the user is? Thanks.
  14. My server, which I do not control, does not have a browsecap file so I can't use that. Hence, I need this guy's series of IF/THEN statements just to get me somewhere in the ballpark.
  15. Ok, here is my query so far, but I'm getting an error "Unknown column bucnt in WHERE clause". Why do I get the error when I defined what bucnt is? SELECT brands.brand, brands.partid, bullets.bullid, bullets.bullettext, bullets.buorder, count(bullets.partid) as bucnt, bullets.partid as bupartid FROM brands JOIN bullets ON (brands.partid=bullets.partid) WHERE (brands.partid=31537) AND (bucnt>0) GROUP BY brand ORDER BY brand, partid
  16. Well, I got the query to run but all records returned show bullets. My DB is arranged like this: Table: parts For each part there are 1 or more brands. For each brand there are 1 or more bullets. Given a part number stored on table "parts", I need to show which brands have at least one bullet and construct a SELECT list from those records.
  17. Mysql 4.1.11 I'm having trouble with a join. I need to list all records on the "brands" table which have at least one record on the "bullets" table. However, these tables are linked by 2 fields. This list of brands will be used to make a SELECT box in PHP. Here is the basic layout of the tables. Table: brands Fields: bid (key field, autoinc, and links to bullets!brandid) partid (links to bullets!partid) brand (varchar(50)) Table: bullets Fields: bullid (key field, autoinc) partid (links to brands!partid) brandid (bigint, links to brands!bid) bullettext (varchar(255)) I'm not real good at joins. Can anyone help me out please? Thanks.
  18. Thank you. This appears to be working. The working CSS code is now: .modelnumcat { font-style:italic; padding-top:6px; padding-bottom:6px; display:block; }
  19. I would like to put a little padding above and below a text element, but not enough for a whole line (I don't want to use <p>). PLEASE NOTE: there are multiple rows of text in this single table cell. I have created a CSS class like this: .modelnumcat { font-style:italic; /*padding-top:8px; padding-bottom:8px; */ margin-top:8px; margin-bottom:8px; } The style.css file is included in my html file like this: <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Print Draft Report like Catalog v.10d</title> <link rel="stylesheet" type="text/css" href="style.css" /> </head> I call it out like this: <tr><td valign="top"><b>Product name goes here</b><br/> Subname goes here<br/> <span class="modelnumcat">34 5/8`` blah blah blah offset this text with a little space above and below</span><br/> I have also tried using the class in a <br> tag: <br class="modelnumcat">34 5/8`` blah blah blah offset this text with a little space above and below</br> But it doesn't work. The italics work but not the padding. In my CSS I have tried using "padding" and "margin" but neither works. Does it matter that I am inside a table? Thanks.
  20. I want to show several buttons, then a SELECT box, at the top of my form (just inside the form) but before my table starts. Is this legal? Because the select box is not showing up, only the command buttons are. Here is my form source: <form action="/toolbox/training/masttest/editbullets.php?&partid=24022&brandid=22554&model=V1235FHL&prodcat=Vanity Cabinets&brand=Thomasville Nouveau" method="post"> <hr/>Commands: <input type="submit" name="cmdSave" value="Save" title="Save all changes on this screen" /> <input type="submit" name="cmdDelete" value="Delete" title="Delete checked bullets" /> <button type='submit' name='cmdCopybullet' value='1' disabled="disabled" >Copy</button> <hr/> <table> ... The SELECT box should appear right before the <button> that says "Copy". Here is my code: $buttons='<hr/>Commands: <input type="submit" name="cmdSave" value="Save" '. 'title="Save all changes on this screen" /> '; $buttons.='<input type="submit" name="cmdDelete" value="Delete" '. 'title="Delete checked bullets" /> '; //Copy bullets to another brand combo box. //Now show only brands that are not this brand. //Only show combo box if brand is checked. $query2="SELECT partid,bullettext FROM bullets ". "WHERE (partid=".$partid.") ". "AND (brandid='".$brandid."') ". ";"; //crDebug($query2); //DEBUG $numbull=crqryCount($query2,false); //Number of bullets. $bullets.=' From '; $query2 = "SELECT brd ". "FROM zzbr ". "WHERE (br <> '".$brand."') ". "AND (ng>0) ". "ORDER BY brand ". ";"; $t=crCreateSelectStr($query2,'cbxCopyto','brand'); crDebug($t); //DEBUG. Display variable to screen. $bullets.="$t\n"; $buttons.="\n<button type='submit' name='cmdCopybullet' value='1' "; if ($numbull>0) { $buttons.='disabled="disabled" '; } $buttons.='>Copy</button>'."\n"; //echo "$s\n"; //crDebug($query2); //DEBUG $buttons.='<hr/>'."\n"; echo 'Please note:'."\n"; echo '<ul>'."\n"; echo '<li><b>Text fields</b>: '.NOTALLOWED.'</li>'."\n"; echo '<li>Edits and deletions must be separate steps.</li>'."\n"; echo '<li>Last period deleted from each bullet. Other trailing punctuation not deleted.</li>'."\n"; echo '</ul>'."\n"; $act=$_SERVER['PHP_SELF'].'?'.SID.'&partid='.$partid. '&brandid='.$brandid. '&model='.$model.'&prodcat='.$prodcat. '&brand='.$brand; echo '<form action="'.$act.'" method="post">'."\n"; echo $buttons; //Select parts based on $partid. Then fill in text boxes. echo '<table>'."\n";
  21. Thanks, sasa. I did some work over the weekend and apparently the count() function does not work properly for an array of checkboxes. So I must keep track of how many checkboxes there are, and loop through them using that variable. Below is a complete test program which illustrates the fix. Let's call it tstchk.php. It does not require any connection to any database. <?php session_start(); //require_once('connectvars.php'); //require_once('constants.php'); //require_once('crutil.php'); $title='Checkbox test v.12a'; ?> <!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" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <?php echo '<title>'.$title.'</title>'; ?> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <?php //require_once('navmenu.php'); echo '<h2>'.$title.'</h2>'; echo '<p>Testing check box array. Check some boxes then click the Save button. The value of each entry in the checkbox array will then be printed. '; echo 'If you check boxes 0, 1, and 4, only the values for boxes 0, 1 and 4 SHOULD be set to 1 (indicating checked). However, what happens is, only the values for entries 0 and 1 are 1 (indicating checked). '; echo '<br/>'; ?> <!-- comment --> <?php define("MAXCHECKBOX","9"); // Connect to the database //$dbc = mysqli_connect($host, $user, $password, $database); $oldbrandarr=$_SESSION['oldbrandarr']; $brandarr=array(); $brandarr=$_POST["chkBrand"]; if (isset($_POST['cmdSave'])) //Save records that were changed. { echo '<hr/>'; //$arrcnt=count($brandarr); $arrcnt=MAXCHECKBOX; for ($i=1; $i<$arrcnt; $i++) { if ((is_null($brandarr[$i])) or (empty($brandarr[$i])) ) {$brandarr[$i]=0; } else { $brandarr[$i]=$brandarr[$i]+0; } $s='box '.$i.'='.$brandarr[$i].'<br/>'; echo "$s\n"; } //for i echo '<hr/>'; foreach ($brandarr as $b) { echo "$b<br/>"; } echo '<hr/>'; } //if isset($_POST['cmdSave'] ?> <!--------------------------------------------------------> <form action="<?php echo $_SERVER['PHP_SELF'].'?'.SID; ?>" method="post"> <?php //$oldbrandarr=array(); //Init array. echo "<table>\n"; for ($i=1; $i<=MAXCHECKBOX; $i++) { $s='<tr><td>Box '.$i.' <input type="checkbox" name="chkBrand['.$i.']" '. 'id="chkBrand['.$i.']" value="1" />'; /* $s='<tr><td>Box '.$i.' <input type="checkbox" name="chkBrand[]" '. 'id="chkBrand[]" value="1" />'; */ echo "$s</tr>\n"; } // for i echo '</table>'."\n"; //$_SESSION['oldbrandarr']=$oldbrandarr; //Save for use above in this file. ?> <p> <p>Commands: <input type="submit" name="cmdSave" value="Save" /> </form> </body> </html>
  22. Your SELECT in $query does not include a FROM clause. It should say something like "SELECT field1, field2 FROM tablename WHERE foo=bar;". Don't forget that trailing semicolon in SQL.
×
×
  • 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.