Search the Community
Showing results for tags 'procedural'.
-
I have the following general mySQL query: $query = sprintf( "SELECT a.A, a.B, ..., a.C, FROM a WHERE a.A = %s ORDER by a.A;", implode(" OR a.A = ", $_SESSION['values'])); for some records, B has a value, and for others, B is NULL. That is what I want. I extract the query with the following PHP: for ($i = 0; $i < $nrows; $i++){ $row = mysqli_fetch_assoc($result);//fetches data stored within each row extract($row); echo "<tr>"; foreach($row as $column => $field){ if($field == $...){ ... } elseif($field == $C){ echo"<td> <input type='text' name='C+[]' value='$C'> </td>"; } echo "</tr>" } In the resulting html table, records containing not null B fields are presented accurately, while records with null B fields incur a duplication of field C. This offset occurs at the beginning of the record, pushing the final field in the record outside the table boundaries. I think I've narrowed down the problem to the extract() function, as r_print readouts of every other variable in the script returns the accurate field names and values. But, running print_r on $row after extract() provides an identical printout to other variables in the script. What are some possible ways I can stop the duplication of field C from occurring? Happy to provide more information upon request.
-
Hi. I'm not exactly new to PHP but I am brand new to this community. I have been PHP aware for about 5 years but in all that time the amount of coding I have actually done has been rather pathetic. I work for a company that is quite... insular, and secluded (their choice, not mine) from the wider developer community. As a result I only discovered PHP Frameworks about a year ago and feel quite behind the times. I am used to writing procedural PHP and not much else. I am here to hopefully broaden my horizons and get a better understanding of Frameworks, OOP, SQLi or PDO or database "unspecific" applications. When I first discovered PHP Frameworks about a year ago, my friend suggested I get started using CodeIgniter (that seems to be a lot of newbies' first choice!). I loved it, but after reading various rantings and ravings on the internet I decided that I should probably move on to something more "professional". That's when I came up against SF2 and almost cried myself to sleep every night. It made no sense to me. It still makes no sense to me. I gave up. After that I tried Laravel but couldn't even get going thanks to something called "Composer" which I still don't understand. I thought to myself, "I don't want to learn about dependencies at this stage, I just want to code". I gave up. Then another friend suggested I use PHP Slim. Another Framework. I tried to work with it but it seemed heavily dependant on knowing OOP, and I didn't have the first clue what I was doing. I gave up (are you sensing a pattern here?) So after that, I decided to try and learn the basics of OOP and how/why it was better than procedural and I have to say - I don't think it is. And I kind of hate it. I find it really confusing and not one person I have asked is able to tell me why OOP is better than procedural. They say "it just is". Sigh.... Then I decided to join PHP Freaks so I could vent my frustrations!
- 3 replies
-
- oop
- frameworks
-
(and 2 more)
Tagged with:
-
Well, I am not a programmer. I have a diploma in IT but not in computer science field. I am more like a designer but I know some server side stuffs like MySQL and PHP (Procedural). I am making a website where people will share texts. There will be registration and login, then the user account where the user can edit his/her account settings and delete his/her text uploaded if he/she wants. There will be a form to post the texts. There will be a pagination. Of course, all will be in database and with security. I know many will say OO is better etc...bla bla bla. But the website I will make is not huge or complex like Facebook, Amazon or even other bulky websites. So, I can go with Procedural? By the way, Procedural is not dead, in fact it is still used more on medium-sized application. It is not a matter I do not want to learn OO, but, the website I am doing is not huge at all! Some functions that's all, and I dont have an issue to update the codes. In fact, it will not be updated too much. Your opinion?
-
Hello. Are there any GOOD tutorials about MYSQLI Object orientated coding, and procedural. IE - ONE PAGE that has procedural instructions and DOESNT EVEN BREATHE a sign of object-orientated, and the swapped version. I prefer Procedural. I've found tutorials that have both codes in one page - very confusing.. You use 1 line of procedural, and another line of object orientated & of course its causes errors. I want seperate pages/information. I've been coding for years and now want a new thing added to my site. So I COPY the exact WORKING code i have on a separate script to this new script, and now that same code doesn't work. my current code is here:- $link = mysqli_connect('SITE.com', 'blah', 'Blahpasswrd', 'moreblah'); if ($link->connect_errno) { $GLOBALS["jobs"].="Failed to connect to MySQL: " . $link=>connect_error; save_logs("XXXXXXXXXV06_JOBSCHECK",$GLOBALS["jobs"]); exit(); } $sql = "SELECT * FROM `jobs` WHERE `ID` LIKE '$job%';"; $GLOBALS["jobs"].="\n$sql\n\n";$result = $link->query($sql); $result = $link->query($sql); while($row = mysqli_fetch_assoc($result)) { $text.=print_r($row,true)."\n"; } the error message im getting is:- [10-Jun-2023 23:30:43 Pacific/Auckland] PHP Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, bool given in PATH.php on line 72 [10-Jun-2023 23:35:03 Pacific/Auckland] PHP Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, bool given in PATH.php on line 72 all i want is a list of each line/row of the database that matches.