Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 42
  1. #16
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Post the code you have in use.

  2. #17
    Regular Coder
    Join Date
    Sep 2012
    Posts
    100
    Thanks
    5
    Thanked 3 Times in 3 Posts
    PHP Code:
    <?php

    $bValues 
    = array(
        
    'Compaq' => &$modelscompaq,
        
    'HP' => &$modelshp,
        
    'Compaq/HP' => &$modelsboth,
    );
    // Referencing was used since I don't know if these exist, but now I don't need to bother with 
    // an isset check.
    ?>
    <?php

    $aFiltered 
    array_filter($bValuescreate_function ('$a''return !empty($a);'));
    if (empty(
    $aFiltered))
    {
        print 
    '<i>No Data Available</i>';
    }
    else
    {
        foreach (
    $bValues AS $name => $value)
        {
            
    printf('<b>%s</b> - <i>%s</i><br />' PHP_EOLucwords($name), $value); 
        }
    };
    ?>

  3. #18
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    This doesn't match the code I previously posted.
    That foreach is iterating all records of $bValues. It should be iterating each record of $aFiltered.

  4. #19
    Regular Coder
    Join Date
    Sep 2012
    Posts
    100
    Thanks
    5
    Thanked 3 Times in 3 Posts
    Quote Originally Posted by Fou-Lu View Post
    This doesn't match the code I previously posted.
    That foreach is iterating all records of $bValues. It should be iterating each record of $aFiltered.


    I need to do some serious file cleaning too much of the same stuff of various age and edits

    Thanks

  5. #20
    Regular Coder
    Join Date
    Sep 2012
    Posts
    100
    Thanks
    5
    Thanked 3 Times in 3 Posts
    Another stage of the redevelopment of this site. I had an idea a while ago that I had inquired about on the phpBB forum, as this idea has to do with connecting to my forum to other pages...

    I have pages on the site that have missing bits of information (or in some cases wrong info). I have a section in my forum that contains topics for each page, which are connected to the webpages with links (i.e. Page X has a "discuss this page" link) that points to the apprporiate topic/thread.

    I know this will be coded completely wrong but it will get the idea across to build from...

    PHP Code:
    <?php
    $variable_word 
    "Random_Word"//
    //Check if topic exists in database. If topic exists echo the t_id.
    $sql "SELECT * FROM `phpbb_topics` WHERE `topic_title = `$variable_word && constant_word LIMIT 1";

    echo 
    '<a href="/forum/viewtopic.php?t_id=$row['t_id']">Discuss This Page</a>.';
    ?>

  6. #21
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Quote Originally Posted by Ctechinfo View Post
    Another stage of the redevelopment of this site. I had an idea a while ago that I had inquired about on the phpBB forum, as this idea has to do with connecting to my forum to other pages...

    I have pages on the site that have missing bits of information (or in some cases wrong info). I have a section in my forum that contains topics for each page, which are connected to the webpages with links (i.e. Page X has a "discuss this page" link) that points to the apprporiate topic/thread.

    I know this will be coded completely wrong but it will get the idea across to build from...

    PHP Code:
    <?php
    $variable_word 
    "Random_Word"//
    //Check if topic exists in database. If topic exists echo the t_id.
    $sql "SELECT * FROM `phpbb_topics` WHERE `topic_title = `$variable_word && constant_word LIMIT 1";

    echo 
    '<a href="/forum/viewtopic.php?t_id=$row['t_id']">Discuss This Page</a>.';
    ?>
    That's not completely wrong. If you are hooking into another app's DB, so long as the structure is correct that what you want(ish) to do. The query itself is wrong, you want to use SELECT t_id, topic_title FROM phpbb_topics WHERE topic_title IN ('$variable_word', 'constant_word') LIMIT 1. If these are searching on partials, you can use the LIKE syntax instead of equality/IN syntax. MySQL's wildcard characters are % for many, and _ for a char (so typically only % is used). If you can try to avoid wildcarding the beginning of a match since you cannot index it if you do.

    Quote Originally Posted by rajdeep01 View Post
    When writing classes in PHP, you can save time and speed up your scripts by working with object properties directly, rather than writing naive setters and getters. In the following example, the dog class uses the setName() and getName() methods for accessing the name property.

    class dog {
    public $name = '';

    public function setName($name) {
    $this->name = $name;
    }

    public function getName() {
    return $this->name;
    }
    }
    Aside from being completely off-topic, this is also the worst piece of advice I've ever heard. PHP is datatype weak; you cannot control a variable at a datatype level. If you allow public access to a variable that is an object type, you must then use an instanceof check any time you want to operate with it. Always create modifiable properties as protected or lower scope.

  7. #22
    Regular Coder
    Join Date
    Sep 2012
    Posts
    100
    Thanks
    5
    Thanked 3 Times in 3 Posts
    That's not completely wrong. If you are hooking into another app's DB, so long as the structure is correct that what you want(ish) to do. The query itself is wrong, you want to use SELECT t_id, topic_title FROM phpbb_topics WHERE topic_title IN ('$variable_word', 'constant_word') LIMIT 1. If these are searching on partials, you can use the LIKE syntax instead of equality/IN syntax. MySQL's wildcard characters are % for many, and _ for a char (so typically only % is used). If you can try to avoid wildcarding the beginning of a match since you cannot index it if you do.
    Thanks for the advice. The way things are setup. The webpages are motherboard codenames. The discussion threads are titled "board_codename Motherboard" so the return on the webpage would be just the one topic hence the limit 1 bit.

  8. #23
    Regular Coder
    Join Date
    Sep 2012
    Posts
    100
    Thanks
    5
    Thanked 3 Times in 3 Posts
    Time to think seriously about database(s).. While I havent done too much with migrating to a fully database driven site I have setup a non-forum database for one section of the site. I have been pondering the idea of switching over from a files/folders (hard coded) setup to a database driven setup for a while but haven't taken the plunge yet, mainly due to the old saying "if it ain't broke, don't fix it", well for the most part the hard coding is working out but no I am having to move pages, and even though the site is getting no real human interaction, I would like to get to a final format that wont trip up google, etc...

    for an example:
    http://www.mysite.com/boards/manufacturer/codname.php
    is the current format of the links to the motherboards.

    due to miguided information or new information for currently "unknown" boards the pages are getting shuffled around.

    What I was thinking of as a new method of pages is like similar to forums:
    http://www.mysite.com/viewboard.php?b_id=n (where n would be the id number from the database) so that when a page move the link would remain the same.

    idea in my head for the site database:
    b_id = Auto Incremented
    Image - (page has a thumnail that can be clicked for a larger view)
    codename = Varchar(50) -> (haven't encoutered any that are that long but some do have dashes in them)
    Real Name = Varchare(50) -> (haven't encoutered any that are that long but some do have dashes in them)
    chipset - Ultimately it would be cool to have this setup as a sub-table that has (but part of that problem is some of the chipset series names cover 30 different chipsets):
    Chipset Name (for instance Intel Bearlake Chipset)
    North Bridge -
    South Bridge -
    Socket/Slot
    Bus Speed - AMD uses MT/s, Intel uses mainly MHz/GHz (but IIRC there are some w/DMI that uses MT/s)
    RAM - Number & Types of Slots/Sockets | RAM Speed | Maximum (most of the newer boards list x for 32-b and x for 64-bit, whereas older boards list just one maximum)
    Audio - Type of audio (integrated HD audio, external only, etc) | brand of CODEC
    [b]Video[b] - Type of video (like the audio there are diffent setups) [For some odd reason I have been listing with the video specs as an example PCI Express x16 Graphic Cards, but in reality if your techie enough to look for technical specs your gonna figure it out by the expansion slot list]
    Expansion slots - A breakdown of the expansion slots on the board
    [b]Part Number(s) - Various formats (some 5421-0679, D9999-8888, 666666-222)
    Additional Images - For instance if a front panel pinout is availible, or a pic of the codename, etc. (would be super cool to have it expandable if more then one extra image was availbie), this is listed as text link to the image, but the description text changes based on what the type of image is.
    Models Found in - a breakdown by sytem series/models
    Compaq - Models
    Compaq/HP - Models
    HP - Models
    Documentation - A breakdown of what is availible for manuals, maintenance guides, or parts info (Quick Reference Guides)
    Retail Boad info -
    This is an MSI/Microstar MS-7612 motherboard.
    Retail Link Here
    Retal Link2 Here (if availible)
    biosver - effects the branding of the BIOS branding in the caution message. "The bios program has been altered to an HP specific version. It is not recommended to flash back to the original. If anyone does this successfully please notify us by <a href="">email</a>." Would be super cool to have is setup so that I could plug in Compaq, HP, or Compaq/HP and have the a/an accoringly instead of having to put in a Compaq, an HP, or an HP or Compaq.
    Update - This is information that replaces the caution message if somebody has flashed the BIOS back to the retail version.
    Notes - This is for extra information that has been found like if there is a known discrepency like if HP lists the board as being from x manufacturer but the information points to another, etc.
    Forum/Discussion Link - Link to a thread in the forum to discuss the board (for filling in the blanks essentially).


    Most all the current formating, etc has been previosly discussed in this thread.. No I am not asking for you to do this for me, just brainstorming and hoping for guidance as I have never tackled a project like this..

  9. #24
    Regular Coder
    Join Date
    Sep 2012
    Posts
    100
    Thanks
    5
    Thanked 3 Times in 3 Posts
    And in a corresponding idea/project. I am getting to the point I need to build a database for my own personal server that I will be able to collect information that I have found and have it searchable by vaious terms..

    Like for instance, PCB: FAB I have seen several different boards that have this marking, but there are differenc configuratiions, part numbers, etc. And there are several boards that have been previously unverifyably listed as a particular retail board like on ebay, but the information dechipered from the picture leads to another model, etc.

    Along the same premise as the above post this database would need to be much more detaied. so that I could collect tid bits such as common markings, etc. so that at some point I can piece together reliable information..

    Having a interface page to use for search and enter data would be much nicer then looking though a phpMyAdmin interface..

  10. #25
    Regular Coder
    Join Date
    Sep 2012
    Posts
    100
    Thanks
    5
    Thanked 3 Times in 3 Posts
    Quote Originally Posted by Ctechinfo View Post
    Another stage of the redevelopment of this site. I had an idea a while ago that I had inquired about on the phpBB forum, as this idea has to do with connecting to my forum to other pages...

    I have pages on the site that have missing bits of information (or in some cases wrong info). I have a section in my forum that contains topics for each page, which are connected to the webpages with links (i.e. Page X has a "discuss this page" link) that points to the apprporiate topic/thread.

    I know this will be coded completely wrong but it will get the idea across to build from...

    PHP Code:
    <?php
    $variable_word 
    "Random_Word"//
    //Check if topic exists in database. If topic exists echo the t_id.
    $sql "SELECT * FROM `phpbb_topics` WHERE `topic_title = `$variable_word && constant_word LIMIT 1";

    echo 
    '<a href="/forum/viewtopic.php?t_id=$row['t_id']">Discuss This Page</a>.';
    ?>
    So I finally got around to trying this out, on my local machine/test server.
    Parse error: syntax error, unexpected 't_id' (T_STRING) in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\ctechinfoNEW\templates\board.tpl on line 232
    PHP Code:
           <p align="left"><b> - </b>       <?php
    //Check if topic exists in database. If topic exists echo the t_id.
    SELECT t_idtopic_title FROM phpbb_topics WHERE topic_title IN ('$variable_word''Motherboard'LIMIT 1"; // This select line is line 232

    echo '<a href="
    /forum/viewtopic.php?t_id=$row['t_id']">Discuss This Page</a>.';
    ?>. </p>
    The above codeblock is in the .tpl file and I put the $variable_word variable info in the sample board page that connects to the .tpl file in order to create the page.

    I do not know if I am simply missing backticks (or whatever these (`) are called). or missing brackets. But I also need to extend the code with an else statement:

    PHP Code:
    else {
          echo 
    "No Discussion topic added yet."

    Or have an insert script to automatically add the topic information as a new thread.
    At the top of the .tpl file I did add
    PHP Code:
    <?php
    define
    ('IN_PHPBB'true);
    define('ROOT_PATH'"/forum");

    if (!
    defined('IN_PHPBB') || !defined('ROOT_PATH')) {
        exit();
    }

    $phpEx "php";
    $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH ROOT_PATH '/';
    include(
    $phpbb_root_path 'common.' $phpEx);

    $user->session_begin();
    ?>
    as mentioned to do on the phpBB site.

    Thanks

  11. #26
    Regular Coder
    Join Date
    Sep 2012
    Posts
    100
    Thanks
    5
    Thanked 3 Times in 3 Posts
    PHP Code:
    <?php 
    if (isset($manual)) { 
       echo 
    '<a href='."$manual".'>Motherboard Manual</a>'
    } elseif (isset(
    $quickref)) { 
       echo 
    '<a href='."$quickref".'>Quick Reference Guide</a>'
    } elseif (isset(
    $msgs)) {
        echo 
    '<a href='."$msgs".'>Maintenance/Service Guide</a>';
    } elseif (isset(
    $quickspecs)) {
        echo 
    '<a href='."$quickspecs".'>Quick Specs</a>';
    } else {
        echo 
    "No Documentation Availible";
    }
    if (isset(
    $manual2)) {
        echo 
    '<br /><a href='."$manual2".'>Motherboard Manual</a>';
    }
    ?>
    Trying to do more with less code is the premice. The dilema with this block of code. Some of the pages have more then one manual availible, or have a manual, AND a Quick Reference Guide or a Quickspec Sheet.

    Trying to get the code to function as:
    Link 1
    Link 2

    Without adding another 10 lines of code to get the desired result.

    PHP Code:
    <?php 

    $cValues 
    = array( 
        
    $manual => 'Motherboard Manual'
        
    $quickref => 'Quick Reference Guide'
        
    $quickspecs => 'Quick Specs'
    ); 
    // Referencing was used since I don't know if these exist, but now I don't need to bother with  
    // an isset check. 
    ?> 
    <?php 

    $aFiltered 
    array_filter($cValuescreate_function ('$a''return !empty($a);')); 
    if (empty(
    $aFiltered)) 

        print 
    '<i>No Data Available</i>'

    else 

        foreach (
    $cValues AS $name => $value
        { 
            
    printf('<a href="%s">%s</a><br />' PHP_EOLucwords($name), $value);  
        } 
    };
    ?>
    but its throwing an error: Notice: Undefined variable: manual in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\ctechinfoNEW\templates\board.tpl on line 174. But that $manual variable worked with the old code (and linked properly). Its also printing/outputting links for all three vaiables given..

    Code:
    <p align="left">
    <b>Documentation:</b><br />
    <br />
    <b>Notice</b>:  Undefined variable: manual in <b>C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\ctechinfoNEW\templates\board.tpl</b> on line <b>174</b><br />
     
    <a href="">Motherboard Manual</a><br />
    <a href=""ftp://ftp.compaq.com/pub/supportinformation/papers/335683_rev002_us.pdf"">Quick Reference Guide</a><br />
    <a href=""http://h18000.www1.hp.com/products/quickspecs/11632_na/11632_na.HTML"">Quick Specs</a><br />
     </p>
    The idea here is if there is only one piece of documentation there is only one link, if there is more then the the code produces more..

  12. #27
    Regular Coder
    Join Date
    Sep 2012
    Posts
    100
    Thanks
    5
    Thanked 3 Times in 3 Posts
    Quote Originally Posted by Fou-Lu View Post
    Yep you can do that quite easily. It requires a slightly different approach.
    PHP Code:
    <b>Found in the following systems:</b><br>
    <?php

    $modelsboth 
    'A model';

    $bValues = array(
        
    'Compaq' => &$modelscompaq,
        
    'HP' => &$modelshp,
        
    'Compaq/HP' => &$modelsboth,
    );
    // Referencing was used since I don't know if these exist, but now I don't need to bother with 
    // an isset check.
    ?>
    <?php

    $aFiltered 
    array_filter($bValuescreate_function ('$a''return !empty($a);'));
    if (empty(
    $aFiltered))
    {
        print 
    '<i>No Data Available</i>';
    }
    else
    {
        foreach (
    $aFiltered AS $name => $value)
        {
            
    printf('<b>%s: </b> - <i>%s</i><br />' PHP_EOLucwords($name), $value); 
        }
    }
    BTW, as for CSS you should look at replacing these markup tags with simple spans that have classes on them. <br /> can also be removed if you block it into a div which is a block type and will create a visually distinct linefeed. So that printf would look more like: <div><span class="strong">%s:</span>-<span class="emphasis">%s</span></div>. CSS can be applied to .strong and .emphasis to apply font weight and font style as well as any margin's required.
    Probably not the way others would have done it, but I got the colorization working..

    PHP Code:
    <b>Found in the following systems:</b><br />
    <?php

    $bValues 
    = array(
        
    'Compaq' => &$modelscompaq,
        
    'HP' => &$modelshp,
        
    'HP Compaq' => &$modelsboth,
    );
    // Referencing was used since I don't know if these exist, but now I don't need to bother with 
    // an isset check.
    ?>
    <?php

    $aFiltered 
    array_filter($bValuescreate_function ('$a''return !empty($a);'));
    if (empty(
    $aFiltered))
    {
        print 
    '<i>No Data Available</i>';
    }
    else
    {
        foreach (
    $aFiltered AS $name => $value)
        {
            if (
    $name == "Compaq") {print '<font color="red">';} elseif ($name == "HP") {print '<font color="blue">';} else {print '<font color="black">';}
            
    printf('<b>%s</b> - <i>%s</i><br />' PHP_EOLucwords($name), $value); 
            print 
    '</font>';
        }
    };
    ?>
    </p>
    Working on my test server anyways..

  13. #28
    Regular Coder
    Join Date
    Sep 2012
    Posts
    100
    Thanks
    5
    Thanked 3 Times in 3 Posts
    Well, I did get the colorization code functioning as desired.

    I have revisited the links array that I wanted to setup, and have got it partially working.

    To re-explain what I am looking to do.. Much like the "models found in" array, If the variable exists the code outputs the corresponding code..

    For instance:

    PHP Code:
    <html>
    <?php
    $manual 
    "http://domain/documentation/sonic_manual.pdf";
    $quickspecs "http://domain/documentation/sonic_qs.html";

    $bValues = array(
        
    $manual => 'Motherboard Manual',
        
    $frontpanel => 'Front Panel Diagram',
        
    $quickspecs => 'Quick Specs',
        
    $quickref => 'Quick Reference Guide',
    );
    $aFiltered array_filter($bValuescreate_function ('$a''return !empty($a);'));
    if (empty(
    $aFiltered))
    {
        print 
    '<i>No Data Available</i>';
    }
    else
    {
        foreach (
    $aFiltered AS $name => $value)
        {
            
    printf('<a href="%s">%s</a><br />' PHP_EOLucwords($name), $value); 
        }
    };
    ?>

    </html>
    Should output:

    Code:
    <a href="http://domain/documentation/sonic_manual.pdf">Motherboard Manual<br />
    <a href="http://domain/documentation/sonic_qs.html">Quick Specs<br />
    But what is acutally getting outputted:
    Code:
    <html>
    <br />
    <b>Notice</b>:  Undefined variable: frontpanel in <b>C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\ctechinfoNEW\link_test.php</b> on line <b>8</b><br />
    <br />
    <b>Notice</b>:  Undefined variable: quickref in <b>C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\ctechinfoNEW\link_test.php</b> on line <b>10</b><br />
    <a href="Http://domain/documentation/sonic_manual.pdf">Motherboard Manual</a><br />
    <a href="">Quick Reference Guide</a><br />
    <a href="Http://domain/documentation/sonic_qs.html">Quick Specs</a><br />
    
    </html>
    Where all I want ouputted is the info that exists as in the models found in array...

    i.e.

    One variable:
    Link 1

    Two variables:
    Link 1
    Link 2

    And so forth

  14. #29
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    That's correct. You'd need to either declare the variables as empty or you would need to add a @ to them when you attempt to set them.
    The problem is simply that when you are declaring the array, PHP hasn't a clue what the $frontpanel variable is since it cannot find it. Due to the way php operates, it then reverts to it being an empty string, and overwrites the empty offset twice so the last item prevails.
    You cannot actually do what you are trying to do. An associative key must exist, even if its empty, so therefore you cannot just trim it down. What you can do, is filter an array keys result and crossreference it with an array intersect. Something like this looks like it would work:
    PHP Code:
    $aFilteredKeys array_filter(array_keys($bValues));
    $aFiltered array_flip(array_intersect(array_flip($bValues), $aFilteredKeys)); 
    That sure is nasty though, you may want to write a function and either handle it manually or even do that nastyness there. Feels like there should be an easier way to do this using the built in functions, but there doesn't appear to be anything that jumps out on the api for providing a user defined function signature that includes the key and value set.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  15. Users who have thanked Fou-Lu for this post:

    Ctechinfo (01-01-2014)

  16. #30
    Regular Coder
    Join Date
    Sep 2012
    Posts
    100
    Thanks
    5
    Thanked 3 Times in 3 Posts
    Quote Originally Posted by Fou-Lu View Post
    That's correct. You'd need to either declare the variables as empty or you would need to add a @ to them when you attempt to set them.
    The problem is simply that when you are declaring the array, PHP hasn't a clue what the $frontpanel variable is since it cannot find it. Due to the way php operates, it then reverts to it being an empty string, and overwrites the empty offset twice so the last item prevails.
    You cannot actually do what you are trying to do. An associative key must exist, even if its empty, so therefore you cannot just trim it down. What you can do, is filter an array keys result and crossreference it with an array intersect. Something like this looks like it would work:
    PHP Code:
    $aFilteredKeys array_filter(array_keys($bValues));
    $aFiltered array_flip(array_intersect(array_flip($bValues), $aFilteredKeys)); 
    That sure is nasty though, you may want to write a function and either handle it manually or even do that nastyness there. Feels like there should be an easier way to do this using the built in functions, but there doesn't appear to be anything that jumps out on the api for providing a user defined function signature that includes the key and value set.
    Ok I have added the @ to the $ side of the bValues array, seems to do the trick...

    But could you please explain the "nastiness".. Is it some sort of memory hog or something? or is it simply due to the double flip?

    Thanks


 
Page 2 of 3 FirstFirst 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •