Jump to content
#StayAtHome ×

KenHorse

Members
  • Content Count

    16
  • Joined

  • Last visited

Community Reputation

0 Neutral

About KenHorse

  • Rank
    Member
  1. Consider the following snippet: print " <td align=\"center\">"; if($row[changed]){print "<B><RED>";} print "<a href=\"editmacrorc.php?id=$row[id]&port=$port&tab=$tab\">"; The tag <RED> is a CSS entry that works fine in other code I use: RED {color:red} As you may see, we read in data from a MySQL database and if the 'changed' field contains a '1', we want to make the displayed character bolded and also RED. And if that character is clicked, take us to the new php file (that all works fine). But only the BOLD is displayed but it is not in RED. Not really sure if this an HTML or PHP issue but help! :D
  2. Well, I've tried all sorts of things and nothing works as expected. Guess I'll just have to leave things alone and format them as needed later on
  3. I'm trying to make his tables a little more consistent. Attached is a screen shot of how the page is displayed (I only show the first 3 entries but there are 105 total) These are the relevant lines from the table (copied & pasted from the .sql file) ------------------------------------------------------------------------------------------------------------------------------------------ INSERT INTO `config` (`command`, `port`, `sub`, `cdata`, `description`, `type`, `changed`, `comment`, `id`, `help`, `defaultdata`, `tab`, `inputspec`, `specalt`, `prompt`, `maxsize`) VALUES ('*205001', 0, NULL, '10901', 'Macro 1 recall', 'code', 0, '', 309, NULL, '10901', 'macrorecall', NULL, NULL, NULL, 8 ), ('*205002', 0, NULL, '10902', 'Macro 2 recall', 'code', 0, '', 145, NULL, '10902', 'macrorecall', NULL, NULL, NULL, 8 ), ('*205003', 0, NULL, '10903', 'Macro 3 recall', 'code', 0, '', 146, NULL, '10903', 'macrorecall', NULL, NULL, NULL, 8 ), ('*4002', 0, '01', '228 070 102 152 116 117 ', 'Macro 1', 'Macro', 0, '', 233, NULL, NULL, NULL, NULL, NULL, NULL, NULL), ('*4002', 0, '02', '210 123 027 ', 'Macro 2', 'Macro', 0, '', 290, 'Up to 15 three digit function numbers. Hint: click lookup function numbers are automaticly added', NULL, NULL, NULL, NULL, NULL, NULL), ('*4002', 0, '03', '211 119 ', 'Macro 3', 'Macro', 0, '', 200, NULL, NULL, NULL, NULL, NULL, NULL, NULL), ('*4005', 0, '01', '123', 'Macro 1 Port Limit', 'prog', 0, '', 677, '', '123', '', '1;2;3;12;13;23;123', '1;2;3;1 and 2;1 and 3;2 and 3;1, 2, and 3', 'Ports:', NULL), ('*4005', 0, '02', '123', 'Macro 2 Port Limit', 'prog', 0, '', 678, '', '123', '', '1;2;3;12;13;23;123', '1;2;3;1 and 2;1 and 3;2 and 3;1, 2, and 3', 'Ports:', NULL), ('*4005', 0, '03', '123', 'Macro 3 Port Limit', 'prog', 0, '', 679, '', '123', '', '1;2;3;12;13;23;123', '1;2;3;1 and 2;1 and 3;2 and 3;1, 2, and 3', 'Ports:', NULL), ------------------------------------------------------------------------------------------------------ Notice in the first group of 3 (starting with *205001, etc). I wanted to change the format of those entries to be more in line with with the other two groups where the 'command' entry is simply *2050 and the sub entry would be 01, 02. etc. Follow? Of course when I make that change to the table (as follows) ('*2050', 0, '01', '10901', 'Macro 1 recall', 'code', 0, '', 309, NULL, '10901', 'macrorecall', NULL, NULL, NULL, 8 ), ('*2050', 0, '02', '10902', 'Macro 2 recall', 'code', 0, '', 145, NULL, '10902', 'macrorecall', NULL, NULL, NULL, 8 ), ('*2050', 0, '03', '10903', 'Macro 3 recall', 'code', 0, '', 146, NULL, '10903', 'macrorecall', NULL, NULL, NULL, 8 ), The 2nd attachment is what is displayed As I said, I'm kind of a newbie at this and I appreciate the help. Let me know if you need anything else (if you're wondering why I want to change the table, this stuff is processed later and it would be much easier if the format was consistent)
  4. I'm taking over existing code from someone else but I am kind of a newbie with MySQL. Poking around the 'net I found some references to the following using aliases? One of the php files calls a database table named "config" and loads a webpage with the info. select m.sub, m.cdata, m.description, m.comment, m.tab, m.id, p.cdata as ports, cd.cdata as code, m.changed as changed from config m, config p, config cd where m.command = '*4002' and m.sub=p.sub and cd.command = CONCAT('*2050',m.sub) and p.command = '*4005' order by m.command"; I'm trying to understand exactly what it does because I'm trying to change how the table it reads is formatted and I'm kinda shooting in the dark.
  5. Thanks all who responded and especially requinix and gizmola. Both of these solutions worked (or perhaps I should say either of them do).
  6. The file contains 4,096 lines, each one representing 1 byte of data in the EEPROM of an embedded processor. The format of the file is the memory location in decimal, a comma and the value of that EEPROM location. The actual locations of the 4 bytes in question are below but that really shouldn't matter to this issue 283,0 284,0 285,220 286,66
  7. Sorry, yes..the value in those bytes should represent 110.0 (sorry, somewhat new to PHP and I inherited a file that I'm working my way though. Obviously I missed a few things along the way.... Those 4 bytes are actually read in - line by line - from a file. This file contains roughly 4,000 lines and format is: 1,0 2,0 3,220 4,66 So and so forth... Here is how I'm reading (and processing) this file <?php $myfile = fopen("myfile.dat", "r") or die("Unable to open file!"); while(!feof($myfile)) { $indata = fgets($myfile); $position = strpos($indata,","); $buffer1 = intval(trim(substr($indata, $position + 1))); $indata = fgets($myfile); $position = strpos($indata,","); $buffer2 = intval(trim(substr($indata, $position + 1))); $indata = fgets($myfile); $position = strpos($indata,","); $buffer3 = intval(trim(substr($indata, $position + 1))); $indata = fgets($myfile); $position = strpos($indata,","); $buffer4 = intval(trim(substr($indata, $position + 1))); } ?>
  8. Take the following 4 bytes, stored in the order shown: 0, 0, 220, 66 The above bytes represent the number 11000, stored as (from the compiler I use for embedded processor work) as a "single", which they define as a "signed 32 bit binary number". I take that to be the same as a float? How can I convert these 4 bytes to their actual value of 11000? (I've tried pack with no success)
  9. Take the following code that reads in the following lines from a text file: 1,161 2,169 3,1 4,0 5,117 Each value after the comma is a byte that contains 2 bytes (with a value of 0 - 15) that were stored by shifting a 1st byte to the left. You get the idea... Code: Select all $myfile = fopen("test.mem", "r") or die("Unable to open file!"); $substring =""; for($b = 1; $b <=1; $b++){ $indata = fgets($myfile); $position = strpos($indata,","); $sub = intval(substr($indata, $position + 1)); $low = $sub & 0x0F; $high = ($sub & 0xF0) >> 4; $sub = $high . $low; if($sub == "0"){ $b = 5 - $b; for($c = 1; $c <= $b; $c++){$indata = fgets($myfile);} break; } if($b < 5){$substring = $substring . $sub;} chop($substring); } echo "Result " . " $substring\r\n"; The values in the file should result in "10901" but the above code results in 10110901. I KNOW the values in the file are stored correctly as I can correctly extract the info in another language but I can't seem to make it work in PHP What am I missing here (integer versus byte thing?)
×
×
  • 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.