gergy008 Posted November 30, 2009 Share Posted November 30, 2009 [ Please read on, I tried to make this as less confusing as possible, Just post if you know what I mean ] Ok. I have a series of badges on my website, But the table I am using only has room for 4 badges before it has to break lines. Problem is, Breaking the lines... I don't know how to make it calculate how many badges are on... For example, I have, Say a newcomers badge, Then an admin, Then a Moderator, Then a rich badge. I want it to break lines there and then, Ready for the next badge; the contributer badge. But the badges can come in any combination, The admin badge might not be there, So I don't want it to break lines but stay on the same line. Get the drift? If you need more explaination just ask, It's a little complicated. Link to comment https://forums.phpfreaks.com/topic/183486-need-help-devising-a-way-to-do-this-what-sounds-a-simple-idea/ Share on other sites More sharing options...
mrMarcus Posted November 30, 2009 Share Posted November 30, 2009 i don't know that the concept is complicated so much as how you explain it is complicated. ultimately, you want to know how many badges are being displayed on the page before they are displayed on the page? so you can adjust the table accordingly or something? show you code that pulls the info from the db and displays it. Link to comment https://forums.phpfreaks.com/topic/183486-need-help-devising-a-way-to-do-this-what-sounds-a-simple-idea/#findComment-968541 Share on other sites More sharing options...
gergy008 Posted November 30, 2009 Author Share Posted November 30, 2009 I thought of a way, This is it... $count=1; $badges=""; function addto($string){ if($count==4){ $count=1; $badges.="<br>".$string; } else { $count++; $badges.=$string; } } $sql1="SELECT new FROM medals WHERE login='".$_SESSION['login']."'"; $results1 = mysql_query($sql1, $link); $arr1 = mysql_fetch_row($results1); $resultss1 = $arr1[0]; if ($resultss1==1){ addto("<img src=\"images/Medals/Graduate.png\" width=\"150\" height=\"150\" alt=\"Graduate - Became a member of Gergy.info!\">"); } $sql2="SELECT admin FROM medals WHERE login='".$_SESSION['login']."'"; $results2 = mysql_query($sql2, $link); $arr2 = mysql_fetch_row($results2); $resultss2 = $arr2[0]; if ($resultss2==1){ addto('<a href="javascript:popUp(\'ADMIN/index.php\')"><img src="images/Medals/Admin.png" width="150" height="150" alt="Admin - A very special member of Gergy.info! This person modifys the websites content and makes sure everything is up to scratch! This person should be treated with respect, Otherwise you may find yourself facing the ban hammer!!!"></a>'); } $sql3="SELECT banned, cash FROM users WHERE login='".$_SESSION['login']."'"; $results3 = mysql_query($sql3, $link); $arr3 = mysql_fetch_row($results3); $resultss3 = $arr3[0]; if ($resultss3==1){ addto('<img src="images/Medals/banned.png" width="150" height="150" alt="Tut tut tut... Nawteh Nawteh! Person banned by admin.">'); } $sql4="SELECT contrib FROM users WHERE login='".$_SESSION['login']."'"; $results4 = mysql_query($sql4, $link); $arr4 = mysql_fetch_row($results4); $resultss4 = $arr4[0]; if ($resultss4==1){ addto('<img src="images/Medals/Contribute.png" width="150" height="150" alt="Zomg, This person Contributed to the site! Applaud!">'); } $sql5="SELECT games FROM gaming WHERE login='".$_SESSION['login']."'"; $results5 = mysql_query($sql5, $link); $arr5 = mysql_fetch_row($results5); $resultss5 = $arr5[0]; if ($resultss5>0){ addto("<img src=\"images/Medals/Buisness.png\" width=\"150\" height=\"150\" alt=\"Buisness man - Bought very first game\">"); } $sql6="SELECT `games`, `themes` FROM `gaming`, `themes` WHERE `gaming`.`login`='".$_SESSION['login']."' AND `themes`.`login`='".$_SESSION['login']."'"; $results6 = mysql_query($sql6, $link) or die(mysql_error()); $arr6 = mysql_fetch_row($results6); if ($arr6[0]>=13 && $arr6[1]>=7 && $arr3[1]>0){ addto("<img src=\"images/Medals/Spare.png\" width=\"150\" height=\"150\" alt=\"Bowler - Wow, Has everything with cash to spare?\">"); } $sql7="SELECT onlooker FROM medals WHERE login='".$_SESSION['login']."'"; $results7 = mysql_query($sql7, $link); $arr7 = mysql_fetch_row($results7); $resultss7 = $arr7[0]; if ($resultss7>0){ addto("<img src=\"images/Medals/Angel.png\" width=\"150\" height=\"150\" alt=\"Onlooker - Reported 3 [ Swearword ] devils with actions dealt... [ Swearword ]...\">"); } echo($badges); All that gives me is: Notice: Undefined variable: count in /home/gergy/public_html/members.php on line 207 Notice: Undefined variable: count in /home/gergy/public_html/members.php on line 211 Notice: Undefined variable: badges in /home/gergy/public_html/members.php on line 212 The starting line is 204 Ugh I have to go now, Post anything and I will read it tomorrow, Thanks!! Link to comment https://forums.phpfreaks.com/topic/183486-need-help-devising-a-way-to-do-this-what-sounds-a-simple-idea/#findComment-968555 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.