Jump to content

cyberRobot

Moderators
  • Posts

    3,145
  • Joined

  • Last visited

  • Days Won

    37

Everything posted by cyberRobot

  1. I'm sure there is. Unfortunately, without getting more familiar with what you're trying to do, the database sturcture, and your PHP background I'm not sure how much more help I can be. If you have more specific question, I'll do my best to help.
  2. You can dynamically generate the array, using the database information. For example if $identifyrow["value"] contains KHS000, you can replace: $pcList['KHS000'][name] = 'PC-Basement'; $pcList['KHS000'][archived] = '10-01-2011'; with: $pcList[$identifyrow["value"]][name] = 'PC-Basement'; $pcList[$identifyrow["value"]][archived] = '10-01-2011'; You would then replace the "name" and "archived" part with something like the field column in the content table. And replace the "PC-Basement" and "10-01-2011" part with the content column of the content table. $pcList[$identifyrow["value"]][$identifyrow["field"]] = $identifyrow["content"]; For more information on multidimensional arrays (and multidimensional associative arrays), this tutorial might be helpful: http://www.webcheatsheet.com/PHP/multidimensional_arrays.php Note that they provide an example of how to loop through this type of array to display it.
  3. I don't see why you can't have both. For example, you could still utilize your fields table by adding an extra column for the corresponding table header from the content table: id | name | content_columnName | order | active 1 | PC-name | name | 1 | 1 1 | Archived | archiveDate | 1 | 1 Of course you would need to figure out how to utilize the modified database structure. But I think things would be a lot easier. If you don't want to modify the structure, you could look into changing the second loop so that it saves everything to an associative array. For example, you could create an array like: $pcList['KHS000'][name] = 'PC-Basement'; $pcList['KHS000'][archived] = '10-01-2011'; $pcList['KHS001'][name] = 'PC-entrance'; $pcList['KHS001'][archived] = '12-12-2010'; Once everything is in the array, you would start another loop to display the array contents. Unfortunately, I don't have time to write any code, but I'll try to answer any questions you might have along the way.
  4. I took another look at your database structure. Does the data need to be stored like this? Seems like you're not utilizing the full power of databases. It would be a lot easier if each entry was stored in it's own row. For example, you could create a table like: id | pc-name | archived | notes 1 | PC-basement | 10-01-2011 | MD 2 | PC-entrance | 10-10-2010 | LF But maybe there's a reason for storing the data as it is now.
  5. Sorry, I've been having a difficult time wrapping my mind around the issue is. After taking another look at the graphic you attached to Reply 8, I think I might understand. It looks like your records are being listed in three different rows: KHS0001|PC-basement KHS0002|PC-entrance KHS0001|10-01-2011 KHS0002|10-10-2010 KHS0001|MD KHS0002|LF Instead you want it listed as: KHS0001|PC-basement|10-01-2011|MD KHS0002|PC-entrance|10-10-2010|LF Is that correct?
  6. It should be fixed by removing the "position:fixed;" from your CSS declaration for #box. Sorry, that got buried by my side point.
  7. The footer is at the top of the page because of your CSS. If you remove the "position:fixed;" from the #box declaration, the footer will appear at the bottom of the page. Note that there is an HTML error also. At the end, this: ... </body> <head> <html> Should be: ... </body> </html>
  8. Yep, adding the target attribute to the anchor tag should work. Note that this should open the link in a new window (depending on the browser settings). I don't know if there is a way to open the link in a new tab. I think that's up to the browser settings.
  9. Did you try adding the open table row <tr> to your loop? Note that both your header row and data rows appeared to be missing the <tr> for your original code. If that doesn't help, it might be helpfult to post your code again since things have changed.
  10. I prefer to use Dreamweaver because of the auto-completion feature. As you type code, it will make suggestions which can be quickly selected saving you time. You can also use the Snippets feature for code that you use over and over again. The code collapse feature is handy for updating larger scripts. A while back I tried out phpDesigner which has some nice features. In addition to suggesting code as you type, it remembers your variable names. So when you start typing a variable name, it will make suggestions. I also like the convert HTML to PHP feature where it could for example change double quotes to single so that you could use the HTML code in a double quoted echo statement. I also liked the Code Explorer panel which counts things like how many times a variable was used. Unfortunately the panel wouldn't count variables used inside double quotes. They may have fixed this in the more recent version.
  11. It sounds like you just need to surround the "or" parts with parenthesis. (username LIKE '%$filter%' OR action LIKE '%$filter%' OR result LIKE '%$filter%' OR changes LIKE '%$filter%') AND (username LIKE '%$filter%' OR action LIKE '%$filter%' OR result LIKE '%$filter%' OR changes LIKE '%$filter%')
  12. I agree with Dan; it's best not to store login info inside the cookie. You'll be better off storing their table row ID for example. But keep in mind that cookies are very easy to edit if the user knows how. So it would be easy for them to change the ID to whatever they want. So you'll want to dynamically create some other key to help prevent tampering with the cookie.
  13. I'm not sure, but doesn't "...fields FLDS INNER JOIN identify IDNT JOIN content CNT ..." need to be "...fields AS FLDS INNER JOIN identify AS IDNT JOIN content AS CNT ..."? Note that I find table name shortcuts to be more confusing the helpful. You could use the full table names in the query: <?php ... $contentresult = mysql_query("SELECT fields.*, identify.*, content.* FROM fields INNER JOIN identify JOIN content WHERE content.identify = identify.id AND content.field = fields.id ORDER BY fields.order, identify.id"); ... ?>
  14. I'm not sure what the question is, but can use the mktime() and date() functions to get the last four months. http://php.net/manual/en/function.mktime.php http://us2.php.net/manual/en/function.date.php
  15. Does this work: <?php ... while($contentrow = mysql_fetch_array($contentresult)) { echo '<tr><td>' . $contentrow["value"] . '</td><td>' . $contentrow["content"] . '</td></tr>'; } ... ?> Note the <tr> tag at the beginning of the echo statement and the </tr> at the end. Looking at your previous examples, it seems like the while loops that display the data are missing the open row tag.
  16. You'll also need to make sure you didn't accidentally remove any dollar signs: <?php ... $Body .= "\nFlat Screen TV: LRFSTV"; ... ?> Note that there should be a $ before LRFSTV. I tend to make that mistake when cleaning up code in a hurry.
  17. Make sure you surround the output with double quotes: <?php ... $Body .= "\nFlat Screen TV: $LRFSTV"; ... ?> If you look at the output that doesn't show the value, you're probably using single quotes.
  18. You actually can, did you try the Left Join? Joining lets you pull data from multiple tables within a single query. It should make what you're trying to do a lot simpler. You'll only need two loops instead of four. Of course it takes a little work to get used to joining queries together.
  19. Unfortunately yes, you would need to add a test for each part. Of course, you can group things like: <?php if($Plumbing != '') { $Body .= "\n"; $Body .= "Plumbing: "; $Body .= $Plumbing; } ?> Yep, you can test for whatever value.
  20. You could test to see if the field is blank before adding it to the e-mail. For example: <?php ... if($Packing != '') { $Body .= "\nPacking: $Packing"; } ... ?>
  21. You should be able to simplify things by looking into MySQL Join. You should be able to merge the last three queries with a Left Join: http://www.tizag.com/mysqlTutorial/mysqlleftjoin.php
  22. Could you provide a sample of what the data looks like in your MySQL tables (fields, identify, content)? Also, could you provide a sample of what you want the HTML table to look like?
  23. Well you could store the header in a variable and echo it out later. ... <?php $tableHeader = '' //$tableHeader .= '<th style="width:128px">Options</th>'; $tableHeader .= ' <th> Identifier </th> '; $fieldresult = mysql_query("SELECT * FROM fields ORDER BY `order`"); while($fieldrow = mysql_fetch_array($fieldresult)) { $tableHeader .= ' <th> ' . $fieldrow["name"] . ' </th> '; } //DISPLAY TABLE HEADER echo $tableHeader . '</tr>'; ... ?> If that doesn't work, it might be helpful if you show us what you're doing with the rest of the loop.
  24. Should work if you change it to: <?php echo 'Hello ' . htmlspecialchars($_GET["name"]) . '!'; ?>
×
×
  • 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.