Mod-Jay Posted August 30, 2011 Share Posted August 30, 2011 The following code is supposed to submit everything in the database on a table, Currently its doing the first row in the database. Not sure whats wrong.. function getNews(){ $query = $this->con->query("SELECT * FROM `". $this->prefix ."news`"); while ($result = $query->fetch_assoc()) { if($result['serveradded'] == 1){ $queryy = $this->con->query("SELECT * FROM `". $this->prefix ."news` WHERE serveradded=1"); while ($resultt = $queryy->fetch_assoc()) { return "<tr><td>The Advertisement ". ucfirst($resultt['name']) ." was created</td><td>". $resultt['date'] ."</td></tr>"; } } elseif($result['servupdate'] == 1){ $queryyy = $this->con->query("SELECT * FROM `". $this->prefix ."news` WHERE servupdate=1"); while ($resulttt = $queryyy->fetch_assoc()) { return "<tr><td>". $result['type'] ." ". ucfirst($resulttt['name']) ." was Updated by ". ucfirst($resulttt['updatedby']) ." </td><td>". $resulttt['date'] ." </td></tr>"; } } elseif($result['newuser'] == 1){ $queryyyy = $this->con->query("SELECT * FROM `". $this->prefix ."news` WHERE newuser=1"); while ($resultttt = $queryyyy->fetch_assoc()) { return "<tr><td>Account Created: ". ucfirst($resultttt['name']) ." was created</td><td>". $resultttt['date'] ."</td></tr>"; } } } } Quote Link to comment https://forums.phpfreaks.com/topic/245999-mysqli-and-oop-php-problems/ Share on other sites More sharing options...
jcbones Posted August 30, 2011 Share Posted August 30, 2011 Your problem explained better than I could!!! Quote Link to comment https://forums.phpfreaks.com/topic/245999-mysqli-and-oop-php-problems/#findComment-1263368 Share on other sites More sharing options...
Mod-Jay Posted August 30, 2011 Author Share Posted August 30, 2011 I echo it out. on Main page. Quote Link to comment https://forums.phpfreaks.com/topic/245999-mysqli-and-oop-php-problems/#findComment-1263369 Share on other sites More sharing options...
jcbones Posted August 30, 2011 Share Posted August 30, 2011 You "return" it in the while loops! Quote Link to comment https://forums.phpfreaks.com/topic/245999-mysqli-and-oop-php-problems/#findComment-1263370 Share on other sites More sharing options...
Mod-Jay Posted August 30, 2011 Author Share Posted August 30, 2011 It is being returned? Explain? Quote Link to comment https://forums.phpfreaks.com/topic/245999-mysqli-and-oop-php-problems/#findComment-1263371 Share on other sites More sharing options...
trq Posted August 30, 2011 Share Posted August 30, 2011 return exits a function and returns it's argument. Quote Link to comment https://forums.phpfreaks.com/topic/245999-mysqli-and-oop-php-problems/#findComment-1263379 Share on other sites More sharing options...
Mod-Jay Posted August 30, 2011 Author Share Posted August 30, 2011 Could you edit the code to a way i could use it? Quote Link to comment https://forums.phpfreaks.com/topic/245999-mysqli-and-oop-php-problems/#findComment-1263385 Share on other sites More sharing options...
PFMaBiSmAd Posted August 30, 2011 Share Posted August 30, 2011 Perhaps if you post an example of the data you have and the result you want, someone could help. In looking at that code, I doubt anyone here can tell what it is you are trying to accomplish. You would never select all your data, then as you loop through each row, reselect some of the same data again. If the three columns - serveradded, servupdate, and newuser are actually types/categories, why don't you have one column named `type` or `category` that holds either 'serveradded', 'servupdate', or 'newuser' directly as strings or as values/enums to indicate the type for that row? Quote Link to comment https://forums.phpfreaks.com/topic/245999-mysqli-and-oop-php-problems/#findComment-1263388 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.