MikeDXUNL Posted January 27, 2008 Share Posted January 27, 2008 alright, i am fairly new to OOP... and everything is working in this class, except it doesnt do anything with the `$get_what` vars.... any help? myclass.inc.php <?php class searchDisplay { public $get_what; public $get_what3; public function displayConsole($result) { echo "<form action=\"#\" name=\"myform\" method=\"post\"> <table border=\"0\" width=\"100%\" class=\"table1\" cellspacing=\"0\" cellpadding=\"2\"> <tr> <td width=\"3%\" class=\"search_res1\" align=\"center\"><input style=\"border:inset 1px;\" name=\"allbox\" type=\"checkbox\" value=\"Check All\" onclick=\"CheckAll(document.myform);\" /></td> <td width=\"7%\" class=\"search_res1\">Picture</td> <td class=\"search_res1\">Description</td> <td class=\"field1\">Other Info</td> </tr>"; // Start Loop ~~ while ($line = mysql_fetch_array($result)) { $consoleid = $line["consoleid"]; $consolename = $line["consolename"]; if($line['predecessor'] == "") { $pre = "No Predecessor"; } else { $pre = $line['predecessor']; } $showresults++ ; echo "<tr> <td class=\"search_res\" align=\"center\"><input type=\"checkbox\" name=\"newgame[]\" value=\"".$consoleid."\" onClick=\"CheckCheckAll(document.myform);\" > <input type=\"hidden\" name=\"type_q\" value=\"consoles\" /><br /> <a href=\"#\" onClick=\"addfavcon('".$consolename."');return false;\" class=\"new\"> </td> <td class=\"search_res\" align=\"center\"><img src=\"consolepics/".$line['consoleimg']."\"> <br /><a href=\"singular.php?consoleid=".$consoleid."&type=console\">" .$consolename. "</a></td> <td class=\"search_res\" valign=\"top\">" .$line['description']. ""; if(!isset($_SESSION['username'])) { echo " "; } else { echo "<div style=\"color: #fc3f3f; font-weight: normal;\"><strong>Console in:</strong><ul>"; $get_what = mysql_query("SELECT * FROM owned_consoles WHERE userid='".$_SESSION['id']."' AND consoleid='".$consoleid."'"); if(mysql_num_rows($$get_what) > 0) { echo "<li>Owned</li>"; } $get_what3 = mysql_query("SELECT * FROM wishlist_consoles WHERE userid='".$_SESSION['id']."' AND consoleid='".$consoleid."'"); if(mysql_num_rows($get_what3) > 0) { echo "<li>Wish List</li>"; } echo "</ul></div>"; } echo "</td> <td class=\"field\" valign=\"top\">".$line['releasedate']."<br />Predecessor: ".$pre."\n <br />\n Manufacturer: ".$line['manufacturer']."</td> </tr>\n"; } echo "<tr> <td colspan=\"3\" class=\"field\">Move to: <select name=\"whereto\">"; if(!isset($_SESSION['username'])) { $dis = "disabled"; } echo " <option ".$dis.">Owned</option> <option ".$dis.">Wish List</option> </select> "; if(!isset($_SESSION['username'])) { echo " "; } else { echo "<a href=\"deletefromcoll.php\">Delete from Anthology</a>"; } echo " </td> <td class=\"field\"><input type=\"submit\" value=\"Submit\" name=\"myform\" class=\"submit_search2\" ".$dis."></td> </tr> </table> </form>"; } // end function } ?> myscript.php <?php // .. previous code above $n_search = new searchDisplay(); $n_search->displayConsole($result); // other end tags and stuff below ?> any help is appreciated! Thanks, Mike Link to comment https://forums.phpfreaks.com/topic/88061-variables-in-functions-dont-register/ Share on other sites More sharing options...
Daniel0 Posted January 27, 2008 Share Posted January 27, 2008 You need to access it like $this->get_what. A good idea would be to read the OOP chapter in the manual to get a basic understanding of OOP in PHP. Link to comment https://forums.phpfreaks.com/topic/88061-variables-in-functions-dont-register/#findComment-450566 Share on other sites More sharing options...
MikeDXUNL Posted January 27, 2008 Author Share Posted January 27, 2008 gah, I did have that, I didn't read the error right, and the syntax in the class was $this->$getwhat = blah blah blah i didnt realize i had two $ in the variable. thank you for the link though! Link to comment https://forums.phpfreaks.com/topic/88061-variables-in-functions-dont-register/#findComment-450638 Share on other sites More sharing options...
aschk Posted February 13, 2008 Share Posted February 13, 2008 That class just frightens me. Embedding $_SESSION parameters into the class, along with the html. It looks more like you're just converting functions into a class + function. You want something that separates these components. i.e. php class != html e.g. <?php class myclass { public function method1(){ return "internal variable"; } public function method2(){ return "another internal variable"; } } $test = new myclass(); ?> <html> <body> my name is {$test->method1()} </body> </html> Link to comment https://forums.phpfreaks.com/topic/88061-variables-in-functions-dont-register/#findComment-465776 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.