Jump to content

variables in functions dont register..?


MikeDXUNL

Recommended Posts

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
Share on other sites

  • 3 weeks later...

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.