How to get output list in solidity funct i have a struct of Drug and a table named drugs of Drug i need to get a list table of drugs having same name

0 votes
I try this but it doesn't work! any suggestions please ? 
    function getdrugs(string memory _name) public view returns (Drug[] memory) {
  Drug memory D;
        for(uint i=0;i<counter;i++){
            if (keccak256(abi.encodePacked((drugs[i].name))) == keccak256(abi.encodePacked((_name)))){
            D.push(drugs[i]);
                return D;
       }}}
Sep 25, 2022 in Blockchain by IMEN

edited 3 hours ago 47 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP