Jump to content

Search the Community

Showing results for tags 'parameters'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 5 results

  1. I'm experiencing something that I've no idea how to understand it. I have the following methods -> <?php public function action($action, $table, $where = [], $rule = "") { if(count($where) === 3) { $operators = array('=', '<', '>', '<=', '<='); $field = $where[0]; $operator = $where[1]; $value = $where[2]; if(in_array($operator, $operators)) { if($rule == "") { $sql = "{$action} FROM {$table} WHERE {$field} {$operator} ?"; } else { $sql = "{$action} FROM {$table} WHERE {$field} {$operator} ? {$rule}"; } if(!$this->query($sql, array($value))->error()) { return $this; } } } return false; } // public function get($table, $where = [], $column = "*", $rule = "") { // return $this->action("SELECT {$column}", $table, $where, $rule); // } public function get($table, $where = [], $rule = "") { return $this->action("SELECT *", $table, $where, $rule); } They're called like this -> <?php public function recent() { $rule = "ORDER BY RAND()"; $field = "type"; $type = "recent"; $query = $this->_db->get(self::$_table, array($field, "=", $type), $rule); print_r($query); } The code like it is here works. Where the weirdness comes in is if I use the commented out DB->get() method. When I switch it and use the get() method that is commented out in the above code I get a fatal error because it's parsing the query string as this -> The absolute only difference is adding in that $column parameter or not and when it's there this effed up query string is the result. Can one of you fine phreaks break it down for me, I've been staring at my code for an hour and can't figure it out. Thanks
  2. I'm looking for some insight on where/how to look something up. I have a Post class and it's really messy so I'm trying to clean it up. There's a method - createPost() - that takes in 8 parameters from a form, does what's needed to them to prepare them for database and creates 7 more properties, as well. For a total of 15 fields being sent to the database. I want to create a sendPost() method to handle this. In creating this method I realized that all these parameters look and feel burdensome and there's no real connection between the 2 methods other than sharing a class. I'd like to look into how to make sendPost take however many of parameters from whichever method it's called for without always having to pass the same amount. So for example if sendPost is being called with createPost than it has to handle 15 parameters, but, later, if I want to call sendPost on an editPost method, for example, it may only need to send 6 parameters back to the database meaning the other 9 would have to be redundantly passed again. I seem to recall from Python years ago there was a way to do this but I can't remember and I really don't know what to even search for to research it. Any direction or resources or advice that anyone could share would be really helpful and appreciated. Thanks
  3. Here's the basic premise of the function I am trying to create. 1. User 1 sends a trade request to User 2. 2. User 2 accepts the request. 3. It redirects both users to new page(trade.php). Below is the code where User 2 accepts the request.I am using jquery dialog box for pop windows. The current issue I am having is that "window.location." is not showing the "by=$session_requestById" variable. It appears as NULL if I var_dump on trade.php page. But it is showing the second variable correctly, which is "by=$session_requestToId". It seems like it only happens on trade.php page. Both variables show up fine on request-php.page and in heading when I var_dump. Perhaps you can tell me what's wrong with this ? window.location.href='trade?by=<?php echo $session_requestById; ?>&to=<?php echo $session_requestToId; ?>'; <script> $(function() { $( "#dialog-confirm" ).dialog({ resizable: true, autoOpen: true, modal: true, width: 600, height: 300, buttons: { "Accept Trade": function() { $( this ).dialog( "close" ); $.ajax({ type:"post", url:"request-trade?by=<?php echo $session_requestById; ?>&to=<?php echo $session_requestToId; ?>", data:"action=acceptTrade", success:function(data){ window.location.href='trade?by=<?php echo $session_requestById; ?>&to=<?php echo $session_requestToId; ?>'; } }); }, Cancel: function() { $( this ).dialog( "close" ); $.ajax({ type:"post", url:"request-trade?by=<?php echo $session_requestById; ?>&to=<?php echo $session_requestToId; ?>", data:"action=cancelTrade", success:function(data){ if(data == false) { alert('not cancelled'); } else { alert('cancelled success'); } } }); } } }); }); </script>
  4. Hi Everyone, I am using the bind_param() function and am building a function around it. I need an automated way of inserting a uncertain (unlimited) amount of parameters into this function. ie have the php code able to insert parameters into the bind_param() function on its own. So if it is given 3 parameters put them in as bind_param($param1,$param2,$param3) or if given 5 parameters bind_param($param1,$param2,$param3,$param4,$param5) I need a way of having the script insert them in for me. What I was thinking was having all of these parameters giving to a function above this as an array. I would then use a foreach loop to determine what type of value each value in this array is and create a string with the appropriate letters to have as the first parameter in the bind_param($value_types ... Then I need a way of cycling through this array and adding how ever many values it has, as individual parameters, to the bind_param() function. Thanks in advance, Timothy
  5. Hello all! I need a bit of help with my coding. I'm new to php so be nice! My goal is to fetch data from a database, display it in divs and be able to sort, filter etc. And I have succeeded to a point but have run into a few problems. First you might want to have a look at the users point of view: http://tinyurl.com/bv6fm7b And yes I am using mysql and not mysqli or pdo which I will convert to in the future, but most of the tutorials I've found use mysql so to get my head around it I am using that, I also probably have not put it all together the best way so any suggestions would be great. Ok so the main problem at the moment are my sort/filtering functions. For example if you go to my page, click 'Rock and Pop' and then sort it by 'price high to low' it will forget the 'Rock and Pop' Where clause and vice versa. Also with this problem are the other sorting options and the pagination. I'm using the GET method so I thought I'd try and enter say ?categories=rockandpop&sort=PriceHigh manually to the end of the url, but it only applied the price sorting and not the category. There is a lot of code so I wont post all of it but try to put examples of each function. Categories: if($_GET['categories'] == 'rockandpop') { $query = "SELECT * FROM searchacts WHERE category='Rock and Pop'"; } if($_GET['categories'] == 'tributebands') { $query = "SELECT * FROM searchacts WHERE category='Tribute Bands'"; } Sort By: if(isset($_GET['sort'])) { if($_GET['sort'] == 'PriceLow') { $query = "SELECT * FROM searchacts ORDER BY price ASC"; } elseif($_GET['sort'] == 'PriceHigh') { $query = "SELECT * FROM searchacts ORDER BY price DESC"; } if(isset($_GET['upto'])) { if($_GET['upto'] == 'upto100') { $query = "SELECT * FROM searchacts WHERE price <= '100'"; } elseif($_GET['upto'] == 'upto200') { $query = "SELECT * FROM searchacts WHERE price <= '200'"; } Example of one of the forms: <form action='<?php echo $_SERVER['PHP_SELF']; ?>' method='get' name='form_filter' class="sortoptions" > <select name="sort"> <option value="all">All</option> <option value="PriceLow">Price (Low to High)</option> <option value="PriceHigh">Price (High to Low)</option> </select> <br /> <input type='submit' value = 'Re-Order your results'> </form> And the data into the divs: <?php $i=0; while ($i < $num) { $image=mysql_result($result,$i,"image"); $name=mysql_result($result,$i,"name"); $category=mysql_result($result,$i,"category"); $description=mysql_result($result,$i,"description"); $stamps=mysql_result($result,$i,"stamps"); $stickmen=mysql_result($result,$i,"stickmen"); $price=mysql_result($result,$i,"price"); $view=mysql_result($result,$i,"view"); $actpagelink=mysql_result($result,$i,"actpagelink"); ?> <a href="<?php echo $actpagelink; ?>" class="searchitem"> <div class="searchimage"><img src="<?php echo $image; ?>"/></div> <div class="searchtext"> <div class="searchname"><?php echo $name; ?></div> <div class="searchcategory"><?php echo $category; ?></div> <div class="searchdescription"><?php echo $description; ?></div> </div> <div class="searchstamps"><img src="<?php echo $stamps; ?>" /></div> <div class="searchstickmen"><img src="<?php echo $stickmen; ?>" /></div> <div class="searchprice"><span class="pricefrom">from</span>£<?php echo $price; ?></div> <div class="searchview"><img src="<?php echo $view; ?>" /></div> </a> I've also attached my full code if that helps. Thanks code.txt
×
×
  • 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.