Tag Archives: oop

Loop an array of array

Questions: in PHP, how can i loop an array of array without know if is or not an array? Better with an example: Array ( [0] => Array ( [0] => big [1] => small ) [1] => Array ( [0] => big [1] => tiny ) [2] => Array ( [0] => a [1]… Read More »

How to insert multiple radio button values with PHP OOP

Questions: I’m working on a CMS with PHP OOP. In this project, there is a feature for users to add new Telegram Channel. For this feature, I added this form which also contains the action codes: <?php if(isset($_POST[‘submit’])){ $token = $_POST[‘token’]; $cat = $_POST[‘cat’]; $ads = $_POST[‘ads’]; $key = $_POST[‘keyboard’]; $tel = new Telegram(); $notice… Read More »

PHP If / Else statement not working in While loop

Questions: I’ve been working on this bit of code for about an hour and can’t seem to figure out why it’s not working. Does PHP allow If/Else statements within While loops? I’ve tried adding different echos to both If/Else statements and the latter (Else) will not show. Is this because I’m trying to use the… Read More »

PHP While loop displaying only last row

Questions: I’m using TCPDF library to generate PDF of a table . Table has few number of rows say 10 Among that two rows has same invoice number “78650” Now i am selecting by invoice number and as desired it should generate PDF with two rows. But instead it is only fetching the second row… Read More »

Can the for loop be eliminated from this piece of PHP code?

Questions: I have a range of whole numbers that might or might not have some numbers missing. Is it possible to find the smallest missing number without using a loop structure? If there are no missing numbers, the function should return the maximum value of the range plus one. This is how I solved it… Read More »

php while loop variable for every third div

Questions: Is their a way in a while loop to assign a variable to a class in a div, for every third item in a while loop. I am using the blueprint structure and the third div is at the end and i need to attacht a “last” class name to every third div so… Read More »

Jquery Loop not working correctly?

Questions: I am trying to create a loop to create many functions so that when a user clicks the thumb up button it runs the correct .php document. It works great when I remove the loop and just give var i a specific number but as soon as i try to make it into a… Read More »

How to loop through this json decoded data in PHP?

Questions: I’ve have this list of products in JSON that needs to be decoded: “[{“productId”:”epIJp9″,”name”:”Product A”,”amount”:”5″,”identifier”:”242″},{“productId”:”a93fHL”,”name”:”Product B”,”amount”:”2″,”identifier”:”985″}]” After I decode it in PHP with json_decode(), I have no idea what kind of structure the output is. I assumed that it would be an array, but after I ask for count() it says its “0”. How… Read More »

How to build multi oop functions in PHP5

Questions: I have a question about OOP in PHP5. I have seen more and more code written like this: $object->function()->first(array(‘str’,’str’,’str’))->second(array(1,2,3,4,5)); But I don’t know how to create this method. I hope somebody can help me here, :0) thanks a lot. Answers:

Assigning xml generated by a while loop to a variable

Questions: I am creating XML using a while loop, but now I need to prepend and append the generated XML with the XML header info and wrapper tag, but I am struggling to get it to work, here is my code, $result = mysql_query(“SELECT * FROM users”) or die(mysql_error()); $row = mysql_fetch_array($result); while ($row =… Read More »