rusdvlunread, Aug 25, 2008, 12:28:22 PM8/25/08 to NZ PHP Users Group Hi i'm having a little trouble displaying content from a database... this is the code: <?php
$query = "SELECT feedbackID, feedback, participant FROM tbl_feedback while($row = mysqli_fetch_assoc($feed->result)) Here is the class: <?php function __construct() function query($query) When I run the script i get a Warning: mysqli_fetch_assoc() expects I'm sure I just messed something up and cant see it. If anyone can Thanks. Dmitry Rubanunread, Aug 25, 2008, 12:45:11 PM8/25/08 to while($row = mysqli_fetch_assoc($feed->result)) -> while($row = $feed->result->fetch_assoc()) rusdvl: Steve Wakeunread, Aug 25, 2008, 12:45:11 PM8/25/08 to Have you
checked the return value from your call to mysqli->query() ? I'd move the actual fetch into the class so you wrap the nature of rusdvlunread, Aug 26, 2008, 5:30:55 AM8/26/08 to NZ PHP Users Group Hey, I tried it your way and came up with this error: rusdvlunread, Aug 26, 2008, 5:45:11 AM8/26/08 to NZ PHP Users Group Hey, Sorry im still learning php so im not entirely sure what you mean... <?php //make sure we’re using the right database $query = "SELECT feedbackID, feedback, participant FROM tbl_feedback"; while($row = mysql_fetch_assoc($result)) $feedback = '<p>'.$row['feedback'].'<br />'."\n"; This did display the result, but only one result... I have 13 in the anru chenunread, Aug 26, 2008, 6:17:24 AM8/26/08 to while($row = mysql_fetch_assoc($result)) //this will destroy old content inside $feedback $feedback .= '<i>'.$row['participant'].'</i></p>'."\n"; that why only one result displayed. should do like this:
regards. anru unread, Aug 26, 2008, 6:14:31 AM8/26/08 to Showing only the last row I would assume? You are re-defining $feedback $feedback = ""; That still does solve your original problem though... HTH. Nathan. rusdvlunread, Aug 26, 2008, 6:46:07 AM8/26/08 to NZ PHP Users Group Hey, yea thanks that fixed that problem... But it did not fix the problem I have when its all in a class. On Aug 26, 9:17 am, "anru chen" <> wrote: Andrew McMurtrieunread, Aug 26, 2008, 6:51:30 AM8/26/08 to Check your query in a DB gui tool or command line, I would have expected to Andrew __________ Information from ESET NOD32 Antivirus, version of virus
signature The message was checked by ESET NOD32 Antivirus. __________ Information from ESET NOD32 Antivirus, version of virus signature The message was checked by ESET NOD32 Antivirus. http://www.eset.com rusdvlunread, Aug 26, 2008, 7:11:41 AM8/26/08 to NZ PHP Users Group lol...
what a dumb mistake... oh well all part of the learning Andrew McMurtrieunread, Aug 26, 2008, 7:41:11 AM8/26/08 to Lol it was a typo wasn't it? Couldn't have been a
dumb mistake (never admit } If($this->mysqli->error) rusdvlunread, Aug 26, 2008, 8:35:02 AM8/26/08 to NZ PHP Users Group Hey admitting your mistakes is the first step to learning :D (but sure Thanks for the help and the better code... I wrote that class while |