Page 1 of 1
Fatal error: Cannot redeclare function
Posted: Sun Jan 18, 2009 1:00 pm
by bla5e
Code: Select all
while($row = mysql_fetch_array($result)) {
echo ("<form action=\"makeMoney.php?id=edit\" method=\"post\">");
function getRest() {
echo ("<th width=\"156\" scope=\"col\">" . $row['fullname'] . "</th>");
echo ("<th width=\"367\" scope=\"col\">" . $row['name'] . "</th>");
echo ("<th width=\"121\" scope=\"col\">" . $row['status'] . "</th>");
echo ("<th scope=\"col\" align=\"left\">");
echo ("<select name=\"edit\" id=\"jumpMenu\">");
echo ("<option>Not Started</option><option>Downloaded</option><option>Burned</option><option>Sold</option>");
echo ("<input type=hidden name=forWho value=".$row['id'].">");
echo ("<input type=\"submit\" value=\"Submit\">");
echo ("</form>");
echo ("</th></tr>");
}
if ("" . $row['status'] . "" == "Not Started") { echo ("<tr bgcolor=\"Red\">"); getRest(); }
elseif ("" . $row['status'] . "" == "Downloaded") { echo ("<tr bgcolor=\"Orange\">"); getRest(); }
elseif ("" . $row['status'] . "" == "Burned") { echo ("<tr bgcolor=\"Yellow\">"); getRest(); }
elseif ("" . $row['status'] . "" == "Sold") { }
}
Im trying to get it so it doesnt display items listed as sold.
Re: Fatal error: Cannot redeclare function
Posted: Sun Jan 18, 2009 1:14 pm
by Burrito
you're recreating the function with every iteration of your while loop...can't do that.
Re: Fatal error: Cannot redeclare function
Posted: Sun Jan 18, 2009 1:17 pm
by bla5e
yeah i also tried to remove it from the loop, then it wouldnt display any data because the loop consists of my mysql fetch
Re: Fatal error: Cannot redeclare function
Posted: Sun Jan 18, 2009 1:29 pm
by Burrito
put your function declaration outside of your loop and call your function within your loop and pass in the arguments you need it to process.
Re: Fatal error: Cannot redeclare function
Posted: Fri Jan 23, 2009 8:50 pm
by bla5e
Here is my current code I am using, but its sill not working.
I am getting no errors, but its not displaying any data from the function.
Code: Select all
case 'current':
$con = mysql_connect("xx ", "xx ", "xx ") or die(mysql_error());
mysql_select_db("xx", $con);
$result = mysql_query("SELECT * FROM makeMoney");
function getRest($data) {
echo ("<th width=\"156\" scope=\"col\">" . $data['fullname'] . "</th>");
echo ("<th width=\"367\" scope=\"col\">" . $data['name'] . "</th>");
echo ("<th width=\"121\" scope=\"col\">" . $data['status'] . "</th>");
echo ("<th scope=\"col\" align=\"left\">");
echo ("<select name=\"edit\" id=\"jumpMenu\">");
echo ("<option>Not Started</option><option>Downloaded</option><option>Burned</option><option>Sold</option>");
echo ("<input type=hidden name=forWho value=".$data['id'].">");
echo ("<input type=\"submit\" value=\"Submit\">");
echo ("</form>");
echo ("</th></tr>");
}
echo ("<center><h3> Currenty Requested</h3>");
echo ("<table width=893 border=1 cellspacing=0 cellpadding=0 bordercolor=\"#000000\">");
echo ("<tr>");
echo ("<th width=\"156\" scope=\"col\">Client</th>");
echo ("<th width=\"367\" scope=\"col\">Item Requested</th>");
echo ("<th width=\"121\" scope=\"col\">Status</th>");
echo ("<th width=\"121\" scope=\"col\"></th>");
echo ("</tr>");
while($row = mysql_fetch_array($result)) {
echo ("<form action=\"makeMoney.php?id=edit\" method=\"post\">");
if ("" . $row['status'] . "" == "Not Started") { echo ("<tr bgcolor=\"Red\">"); getRest($data); }
if ("" . $row['status'] . "" == "Downloaded") { echo ("<tr bgcolor=\"Orange\">"); getRest($data); }
if ("" . $row['status'] . "" == "Burned") { echo ("<tr bgcolor=\"Yellow\">"); getRest($data); }
if ("" . $row['status'] . "" == "Sold") { echo ("<tr bgcolor=\"Green\">"); }
}
echo ("</table></form></center>");
break;
any ideas? Thanks in advance
Re: Fatal error: Cannot redeclare function
Posted: Fri Jan 23, 2009 9:03 pm
by bla5e
nevermind it was because the rows were mislabeled in my database