Jump to content

digitalgod

Members
  • Posts

    374
  • Joined

  • Last visited

    Never

Everything posted by digitalgod

  1. got another question, would there be any way to change the code so that instead of having to click on Page 2, Page 3 etc they're all displayed at the same time and there's just a page break between them?
  2. hey guys, I'm trying to limit the number of checkboxes a user can check. Need the limit to be dynamic but for testing purposes I'm trying to do it with a fixed number. the checkboxes look like this <input type="checkbox" name="winner[]" value="'.$row['username'].'"> is there any way of doing that if the name of the checkbox is an array? It really needs to be like that.
  3. I found my error... it was the single quotes around v.answer. Thanks for your help [code] a.id = 'v.answer'[/code]
  4. the part I gave you is the whole script for my poll results, session_start() had already been declared. I already echoed out the $ans_result query and everything seems to be in order... I get no errors but for some reason the while statement isn't fired up.... I'll give it a shot in phpmyadmin and post back
  5. hey guys, for some reason my poll results always show up as 0 no matter what... I'm not sure where the problem is... so this is what I have [code] <?php $result = mysql_query("SELECT answer FROM mtlguest_pollanswers WHERE question = '".$_SESSION['pnum']."'");         while ($row = mysql_fetch_assoc($result)) {         $allanswers[] = $row['answer'];     }             $ans_result = mysql_query("SELECT v.answer, COUNT(v.id) AS numVotes, a.answer FROM pollvotes v, pollanswers a WHERE v.question = '".$_SESSION['pnum']."' AND a.id = 'v.answer' GROUP BY v.answer ORDER BY NumVotes DESC");     echo "<UL>";         $votedvotes = array();     while ($row2 = mysql_fetch_assoc($ans_result)) {         extract($row2, EXTR_PREFIX_ALL, 'poll');         $votedvotes[] = $poll_answer;         echo "<LI>".$poll_answer.": ".$poll_numVotes."</LI>";     }         $notvotedanswers = array_diff($allanswers, $votedvotes);     foreach($notvotedanswers as $answer) {         echo "<LI>".$answer.": 0</LI>";     }         echo "</UL>"; ?> [/code] here are my tables polls (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, question VARCHAR(250)) pollanswers (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, question INT, answer VARCHAR(250)) pollvotes (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, question INT, answer INT, ip VARCHAR(20)) for some reason it never displays anything in there [code=php:0] while ($row2 = mysql_fetch_assoc($ans_result)) {         extract($row2, EXTR_PREFIX_ALL, 'poll');         $votedvotes[] = $poll_answer;         echo "<LI>".$poll_answer.": ".$poll_numVotes."</LI>";     } [/code] any reasons why?
  6. hey guys, I already know how to make a print button that prints the page your on but to make things faster for people I'd like to add a print button next to another link so that it prints the content of another page. Would that be possible?
  7. hey guys, trying to display a date but for some reason it's giving me the wrong year... here's what I got [code=php:0] $y = 2006; $m = 08; $d = 24; echo date('l, F jS, Y, mktime(0,0,0,$m,$d,$y)); //outputs Thursday, August 24th, 2000 [/code] why does it keep giving me 2000 as the year??
  8. gives me the same result as what I did before... unless I'm doing something wrong [code=php:0] $num_rows = min($max_num_rows,mysql_num_rows($list_result)); echo "<table class='guestlist'>\n"; for ($i = 0 ; $i < $max_num_columns; $i++) echo "<tr><td width=197><div align='center'><strong>name/nom + #</strong></div></td><td height=17 width=21><img width=17 height=17 src='images/boy.jpg'></td><td height=17 width=21><img width=15 height=17 src='images/girl.jpg'></td></tr>\n"; echo "</tr>\n"; for ($r = 0; $r < $max_num_rows; $r++){ echo "<tr>\n"; for ($c = 0; $c < $max_num_columns; $c++){ $x = $c * $num_rows + $r; if ($x < $num_records) { $y = mysql_result($list_result, $x, 'name'); $z= "+" . mysql_result($list_result, $x, 'number'); /*$promo =  mysql_result($list_result, $x, 'promo_code'); if ($promo != "") { $promo = "(".$promo.")"; }*/ } else { $y = '&nbsp;'; $z = '&nbsp;'; //$promo = '&nbsp;'; } echo "<td>$y $z </td>"; echo "<td>&nbsp;</td>"; echo "<td>&nbsp;</td>"; } echo "</tr>\n"; } echo "</table>\n"; for ($i=1;$i <= $total_pages;$i++) { if ($i == $page) echo "Page $i "; else echo " <a href=\"?page=$i\">$i</a> "; } [/code]
  9. thanks but that's not what I meant. I need the top part of the tables to display what each column is so I have ------------------------------------------------------------------- | name/nom + #    |  Guy  |  Girl  | name/nom + #    |  Guy  |  Girl  | -------------------------------------------------------------------- | INFO 1              |  &nbsp;|&nbsp;|    INFO 49          |&nbsp;| &nbsp;| ---------------------------------------------------------------------- etc sorry for the way the table looks lol, but I hope you understand what I mean. I really appreciate your help
  10. ok here's what I got so far [code=php:0] $total_result = mysql_query("SELECT COUNT(*) FROM listarchive WHERE date = '".$_GET['date']."' AND club = '".$_GET['club']."' "); $num_records = mysql_result($total_result,0,0); $max_num_rows = 48; $max_num_columns = 2; $per_page = $max_num_columns * $max_num_rows; $total_pages = ceil($num_records / $per_page); if (isset($_GET['page'])) $page = $_GET['page']; else $page = 1; $start = ($page - 1) * $per_page; $list_result = mysql_query("SELECT * FROM listarchive WHERE date = '".$_GET['date']."' AND club = '".$_GET['club']."' ORDER BY name LIMIT $start, $per_page"); $num_columns = ceil(mysql_num_rows($list_result)/$max_num_rows); $num_rows = min($max_num_rows,mysql_num_rows($list_result)); echo "<table border=\"1\">\n"; echo "<tr><td width=197><div align='center'><strong>name/nom + #</strong></div></td><td height=17 width=21><strong>Girl</strong></td><td height=17 width=21><strong>Guy</strong></td></tr>\n"; for ($r = 0; $r < $max_num_rows; $r++){ echo "<tr>\n"; for ($c = 0; $c < $max_num_columns; $c++){ $x = $c * $num_rows + $r; if ($x < $num_records) { $y = mysql_result($list_result, $x, 'name'); $z= "+" . mysql_result($list_result, $x, 'number'); } else { $y = '&nbsp;'; $z = '&nbsp;'; } echo "<td>$y $z</td>"; echo "<td>&nbsp;</td>"; echo "<td>&nbsp;</td>"; } echo "</tr>\n"; } echo "</table>\n"; for ($i=1;$i <= $total_pages;$i++) { if ($i == $page) echo "Page $i "; else echo " <a href=\"?page=$i\">$i</a> "; } [/code] so that fills up everything that doesn't have info with empty spaces but I just need it to do name/nom + #  | Girl  | Guy| again when it starts the second column... any ideas no how to do that?
  11. or use javascript [code] <INPUT type="button" value="Click here to go back" onClick="history.back()"> [/code]
  12. yeah I did do that before and it worked well after that. I have another problem now, I need it to create empty cells if there isn't enough info. So if there's only 15 names it will still create 96 cells but only 15 of them will have info.. is that doable?
  13. Hey guys, I was wondering if it would be possible to redirect someone to another server by using php but masking the domain name at the same time. So for instance someone goes to whatever.whatever.com it takes you to mysite.mysite.com but would still display whatever.whatever.com . I'd like to do this without using the domain mask function with registars..
  14. that's really not what I'm looking for, I know how to do pagination, what I don't know how to do is display information like I stated in my original post [quote author=digitalgod link=topic=105519.msg421543#msg421543 date=1156446671] hey guys, I was wondering if it's possible to print info in an html table and if there are more than 48 cells it starts a new column? something like this ------------------------------------- |                  | |   INFO 1      |    INFO 49 |                  | ------------------------------------- |                  | |   INFO 2      |   etc |                  | ------------------------------------- |                  | |up to info 48 | |                  | ------------------------------------- and if there's more than 96 it will create a new page. Any ideas how to do that? [/quote]
  15. hmm that's what I thought but I was sure there was a better way of doing this.. so something like this I guess? [code] <?php $result = mysql_query("SELECT DISTINCT date, club FROM listarchive ORDER BY date ASC, date ASC") or die(mysql_error()); $prevDate = ""; while ($row = mysql_fetch_array($result)) { $currDate = $row['date']; echo '<div style="margin-left:8px; margin-top:10px; margin-right:8px; height:1px; clear:both; background-image:url(images/dot.jpg) "><img src="images/spacer.gif"></div>'; if ($currDate != $prevDate) { echo '<div style="margin-top:8px; margin-bottom:5px "><strong>'.date("D jS M y", mktime(0,0,0,$m,$d,$y)).' </strong></div>'; } echo '<div style="margin-left:10px; margin-top:10px; clear:both "><img src="images/square1.jpg" align="absmiddle" style="margin-right:5px "><strong class="light_gray"><a href="admin.php?a=guestlist&action=archive&club='.$row['club'].'&date='.$row['date'].'">'.$row['club'].'</strong></a></div>'; echo '<div style="margin-left:10px; margin-top:10px; clear:both ">People on the list: ' . $friends_count.'</div>'; $prevDate = $row['date']; } ?> [/code]
  16. ok almost there, this displays everything almost perfectly, only problem is that it always displays the date on top of each club even if it's the same date/ [code] <?php $result = mysql_query("SELECT DISTINCT date, club FROM listarchive ORDER BY date ASC, date ASC") or die(mysql_error()); while ($row = mysql_fetch_array($result)) { echo '<div style="margin-left:8px; margin-top:10px; margin-right:8px; height:1px; clear:both; background-image:url(images/dot.jpg) "><img src="images/spacer.gif"></div> <div style="margin-top:8px; margin-bottom:5px "><strong>'.date("D jS M y", mktime(0,0,0,$m,$d,$y)).' </strong></div> <div style="margin-left:10px; margin-top:10px; clear:both "><img src="images/square1.jpg" align="absmiddle" style="margin-right:5px "><strong class="light_gray"><a href="admin.php?a=guestlist&action=archive&club='.$row['club'].'&date='.$row['date'].'">'.$row['club'].'</strong></a></div>'; echo '<div style="margin-left:10px; margin-top:10px; clear:both ">People on the list: ' . $friends_count.'</div>'; } ?> [/code] and it displays 2006-08-28 --------------------- Club 1   |  Number of people : -------------------------- 2006-08-28 --------------------- Club 5   |  Number of people : -------------------------- 2006-08-27 --------------------- Club 2   |  Number of people : -------------------------- 2006-08-27 --------------------- Club 5   |  Number of people : --------------------------
  17. ok right now this is way beyond me!!... can you please explain your code... I replaced the queries with my own and it's not working... all I get is a blank page and I really don't even know where to start... the queries need to be dynamic so I'm using $_GET and this is what I have with your code [code=php:0] if (isset($_GET['club']) && isset($_GET['date'])) { $result = mysql_query("SELECT COUNT(*) FROM listarchive WHERE date = ".$_GET['date']." AND club = ".$_GET['club']." "); $num_records = mysql_result($result,0,0); $max_num_rows = 48; $max_num_columns = 2; $per_page = $max_num_columns * $max_num_rows; $total_pages = ceil($num_records / $per_page); if (isset($_GET['page'])) $page = $_GET['page']; else $page = 1; $start = ($page - 1) * $per_page; $result = mysql_query("SELECT * FROM listarchive LIMIT $start, $per_page WHERE date = ".$_GET['date']." AND club = ".$_GET['club'].""); $num_columns = ceil(mysql_num_rows($result)/$max_num_rows); $num_rows = min($max_num_rows,mysql_num_rows($result)); echo "<table border=\"2\">\n"; for ($r = 0; $r < $num_rows; $r++){ echo "<tr>\n"; for ($c = 0; $c < $num_columns; $c++){ $x = $c * $num_rows + $r; if ($x < $num_records) $y = mysql_result($result, $x, 'info'); else $y = '&nbsp;'; echo "<td>$y</td>"; } echo "</tr>\n"; } echo "</table>\n"; for ($i=1;$i <= $total_pages;$i++) { if ($i == $page) echo " $i "; else echo " <a href=\"?page=$i\">$i</a> "; } [/code] date looks like 0000-00-00 *edit* found out why it wasn't displaying anything... Now I get an error saying Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource for lines 279 and 280 which are: [code] <?php $num_columns = ceil(mysql_num_rows($result)/$max_num_rows); $num_rows = min($max_num_rows,mysql_num_rows($result)); ?> [/code]
  18. back again, I have another question that first query was to see lists that have been added "today", now I want to be able to see the archive. I want to select everything from listarchive and group everything by date, ordered from today to the very first entry, and in each day it will show all the clubs (ordered alphabeticaly) that had a list... dunno if I'm clear so here's an example I want to be able to see something like this 2006-08-28 --------------------- Club 1  |  Number of people : Club 5  |  Number of people : -------------------------- 2006-08-27 --------------------- Club 2  |  Number of people : Club 5  |  Number of people : -------------------------- etc I'm really having a hard time figuring how to create a query that will select and group everything like that. Can someone give me a push in the right direction?
  19. I need to get the sum of 2 query results but it won't let me add them up. Here's what I have [code] <?php $query = mysql_query("SELECT name FROM list WHERE club = '".$row['club']."' AND date = '".$row['date']."'") or die(mysql_error()); $count_result = mysql_num_rows($query); $friends_query = mysql_query("SELECT SUM(number) FROM list WHERE club = '".$row['club']."' AND date = '".$row['date']."'") or die(mysql_error()); $friends_count = mysql_fetch_array($friends_query); $friends_count = $friends_count + $count_result; ?> [/code] and I get this error Fatal error: Unsupported operand types.
  20. yeah I already had the second part figured out and as for the first part I did this and it works perfectly for now (gotta test it some more with more entries) [code] <?php $today = date("Y-m-d"); $query = mysql_query("SELECT DISTINCT club, date FROM list WHERE date = '". $today . "' GROUP BY club ORDER BY club ASC, date ASC") or die(mysql_error()); while ($row = mysql_fetch_array($_SESSION['guestlist_result'])) {         $count= mysql_query("SELECT name FROM list WHERE club = '".$row['club']."' AND date = '".$row['date']."'") or die(mysql_error());         $count_result = mysql_num_rows($count);         echo $row['club'] . ' #: ' . $count_result; } ?> [/code] thanks for your help!
×
×
  • 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.