Jump to content

mendoz

Members
  • Posts

    118
  • Joined

  • Last visited

    Never

Everything posted by mendoz

  1. Hy phpfreaks. Well, some time ago something like 20 friends started a beting league. There were four rounds. Each round had 15 games. We had a forum, in which everyone posted their score. You got 4 points if you got the same score and 2 points if you got the team who won. Someone manually checked each score. My english is bad here so an example: Match one was Liverpool-Chelsea, 3-2. I posted that Liverpool would win 2-0, so I got two points for that. I want to create a league, in which up to X can registar. Then they can post their predictions for the round. Then their score would be calculated and added to their total score. And a rankings table. I checked the football fantasy legaue scripts and couldn't find anyone I liked. Help would be appriciated, Dror Wolmer
  2. mendoz

    Solved

    Well, most of the code seems to work right The only thing missing is that the first img is 5.jpg and not 1.jpg http://10bayad.com/test.php?cat=star [code] <?php mysql_connect( "XX", "XX", "XX" ); // Use correct stuff there mysql_select_db( "10bayad" ); // Use Database Name $cat=$_GET['cat']; // Select total results for pagination $result = mysql_query("SELECT count(id) FROM $cat"); $num_records = mysql_result($result,0,0); // Set maximum number of rows and columns $max_num_rows = 2; $max_num_columns = 3; $per_page = $max_num_columns * $max_num_rows; // Work out how many pages there are $total_pages = ceil($num_records / $per_page); // Get the current page number if (isset($_GET['page'])) $page = $_GET['page']; else $page = 1; // Work out the limit offset $start = ($page - 1) * $per_page; // Select the results we want including limit and offset $result = mysql_query("SELECT id FROM $cat ORDER BY id LIMIT $start, $per_page"); $num_columns = ceil(mysql_num_rows($result)/$max_num_rows); $num_rows = ceil(mysql_num_rows($result)/$num_columns); // Echo the results echo "<table bgcolor=\"#D5D5D5\" border=\"2\">\n"; for ($r = 0; $r < $max_num_rows; $r++){ echo "<tr>\n"; for ($c = 0; $c < $max_num_columns; $c++){ // 1 $x = $r * $max_num_columns + $c; if ($x < mysql_num_rows($result)){ //                  $y = mysql_result($result, $x, 0); // Commented out so I could show your example                     $num = mysql_result($result, $x, 0);                   $y = <<<HTML <table align="center" border="0" cellpadding="0" cellspacing="0" width="145">   <tr>     <td width="16"><img src="about_files/top_lef.gif" alt="a" width="16" height="16">     </td>     <td background="about_files/top_mid.gif" height="16">       <img src="about_files/top_mid.gif" alt="a">     </td>     <td width="16">       <img src="about_files/top_rig.gif" alt="a" width="16" height="16">     </td>   </tr>   <tr>     <td background="about_files/cen_lef.gif" width="16">       <img src="about_files/cen_lef.gif" alt="a">     </td>     <td align="left" bgcolor="#ffffff" valign="middle">       <div align="center">         <img src="{$cat}/thumb/{$num}.jpg" width="114" height="86" border="1">       </div>     </td>     <td background="about_files/cen_rig.gif" width="16">       <img src="about_files/cen_rig.gif" alt="a">     </td>   </tr>   <tr>     <td height="16" width="16">       <img src="about_files/bot_lef.gif" alt="a" width="16" height="16">     </td>     <td background="about_files/bot_mid.gif" height="16">       <img src="about_files/bot_mid.gif" alt="a">     </td>     <td height="16" width="16">       <img src="about_files/bot_rig.gif" alt="a" width="16" height="16">     </td>   </tr> </table> HTML;                 }                 else {                   $y = '<table align="center" border="0" cellpadding="0" cellspacing="0" width="145">       <tr>         <td width="16"><img src="about_files/top_lef.gif" alt="a" width="16" height="16"></td>         <td background="about_files/top_mid.gif" height="16"><img src="about_files/top_mid.gif" alt="a"></td>         <td width="16"><img src="about_files/top_rig.gif" alt="a" width="16" height="16"></td>       </tr>       <tr>         <td background="about_files/cen_lef.gif" width="16"><img src="about_files/cen_lef.gif" alt="a"></td>         <td align="left" bgcolor="#ffffff" valign="middle"><div align="center"> <img src="html/images/bekarov.jpg" width="114" height="86" border="1"></font></div></td>         <td background="about_files/cen_rig.gif" width="16"><img src="about_files/cen_rig.gif" alt="a"></td>       </tr>       <tr>         <td height="16" width="16"><img src="about_files/bot_lef.gif" alt="a" width="16" height="16"></td>         <td background="about_files/bot_mid.gif" height="16"><img src="about_files/bot_mid.gif" alt="a"></td>         <td height="16" width="16"><img src="about_files/bot_rig.gif" alt="a" width="16" height="16"></td>       </tr>     </table>';                 } echo "<td>";                 echo "$y";                 echo "</td>"; } echo "</tr>\n"; } // Echo page numbers echo "</table>\n"; for ($i=1;$i <= $total_pages;$i++) { if ($i == $page) echo " $i "; else echo " <a href=\"?cat=$cat&page=$i\">$i</a> "; } ?> [/code]
  3. mendoz

    Solved

    Seems to work good. Is there a var in your script whose value is the row number? I tought it was $i but it wasn't. <img src="{$cat}/thumbs/{$i}.jpg" width="114" height="86" border="1"> Then I tried using $r but it just gave 0 and 1, i know why. Maybe I need to add a while function?
  4. mendoz

    Solved

    Wow, it works! Now, the last thing I need is to get the <image src=> right [code] <?php //the piece of the code which isn't working       $y = ' <table align="center" border="0" cellpadding="0" cellspacing="0" width="145">         <tr>               <td width="16"><img src="about_files/top_lef.gif" alt="a" width="16" height="16"></td>               <td background="about_files/top_mid.gif" height="16">                     <img src="about_files/top_mid.gif" alt="a"></td>               <td width="16">                     <img src="about_files/top_rig.gif" alt="a" width="16" height="16"></td>         </tr>         <tr>               <td background="about_files/cen_lef.gif" width="16">                     <img src="about_files/cen_lef.gif" alt="a"></td>               <td align="left" bgcolor="#ffffff" valign="middle">                     <div align="center">     <img src="$cat/$i.jpg" width="114" height="86" border="1"></div></td> //problem               <td background="about_files/cen_rig.gif" width="16">                     <img src="about_files/cen_rig.gif" alt="a"></td>         </tr>         <tr>               <td height="16" width="16">                     <img src="about_files/bot_lef.gif" alt="a" width="16" height="16"></td>               <td background="about_files/bot_mid.gif" height="16">                   <img src="about_files/bot_mid.gif" alt="a"></td>               <td height="16" width="16">                   <img src="about_files/bot_rig.gif" alt="a" width="16" height="16"></td>         </tr> </table> ';                 echo "$y"; ?> [/code]
  5. mendoz

    Solved

    There are two problems: 1. trouble with the <image src=> 2. pagination doesn't work Here is an example. http://10bayad.com/test.php?cat=star Here is the modified code: [code] <?php mysql_connect( "localhost", "user", "pass" ); // Use correct stuff there mysql_select_db( "database" ); // Use Database Name $cat=$_GET['cat']; // Select total results for pagination $result = mysql_query("SELECT count(id) FROM $cat"); $num_records = mysql_result($result,0,0); // Set maximum number of rows and columns $max_num_rows = 2; $max_num_columns = 3; $per_page = $max_num_columns * $max_num_rows; // Work out how many pages there are $total_pages = ceil($num_records / $per_page); // Get the current page number if (isset($_GET['page'])) $page = $_GET['page']; else $page = 1; // Work out the limit offset $start = ($page - 1) * $per_page; // Select the results we want including limit and offset $result = mysql_query("SELECT id FROM $cat ORDER BY id LIMIT $start, $per_page"); $num_columns = ceil(mysql_num_rows($result)/$max_num_rows); $num_rows = ceil(mysql_num_rows($result)/$num_columns); // Echo the results echo "<table bgcolor=\"#D5D5D5\" border=\"2\">\n"; for ($r = 0; $r < $max_num_rows; $r++){ echo "<tr>\n"; for ($c = 0; $c < $max_num_columns; $c++){ // 1 $x = $r * $max_num_columns + $c; if ($x < mysql_num_rows($result)){ //                  $y = mysql_result($result, $x, 0); // Commented out so I could show your example                   $y = '<table align="center" border="0" cellpadding="0" cellspacing="0" width="145">       <tr>         <td width="16"><img src="about_files/top_lef.gif" alt="a" width="16" height="16"></td>         <td background="about_files/top_mid.gif" height="16"><img src="about_files/top_mid.gif" alt="a"></td>         <td width="16"><img src="about_files/top_rig.gif" alt="a" width="16" height="16"></td>       </tr>       <tr>         <td background="about_files/cen_lef.gif" width="16"><img src="about_files/cen_lef.gif" alt="a"></td>         <td align="left" bgcolor="#ffffff" valign="middle"><div align="center"> <img src="$cat/$i.jpg" width="114" height="86" border="1"></font></div></td>         <td background="about_files/cen_rig.gif" width="16"><img src="about_files/cen_rig.gif" alt="a"></td>       </tr>       <tr>         <td height="16" width="16"><img src="about_files/bot_lef.gif" alt="a" width="16" height="16"></td>         <td background="about_files/bot_mid.gif" height="16"><img src="about_files/bot_mid.gif" alt="a"></td>         <td height="16" width="16"><img src="about_files/bot_rig.gif" alt="a" width="16" height="16"></td>       </tr>     </table>';                 }                 else {                   $y = "table-no.php";                 } echo "<td>";                 echo "$y";                 echo "</td>"; } echo "</tr>\n"; } // Echo page numbers echo "</table>\n"; for ($i=1;$i <= $total_pages;$i++) { if ($i == $page) echo " $i "; else echo " <a href=\"?cat=$cat?page=$i\">$i</a> "; } ?>[/code]
  6. Yeah, because the output is for example: for the page index.php?page=home the output will be <title>home</title>
  7. I think you need to use html code. put this inside your php script echo "<img src="X">;
  8. mendoz

    Solved

    Yes huggie, it works. I'll try not using includes and construct the tables there. http://10bayad.com/test.php
  9. mendoz

    Solved

    Yeah, you were right. I posted the same problem on another forum and got this: [quote] To give you a literal answer, you need fixed number of iterations and change inclusion file after you ouput the number of rows in the table that fit your category. For example: [/quote] [code] // SELECT COUNT(*) FROM tablename WHERE cat='$category' // get result into $numrows define ('MAX_ROWS', 6); define ('COLUMNS', 3); $j=0; echo "<table><tr>\n"; for ($i=0; $i<MAX_ROWS; $i++) {   if ($i>($numrows-1)) {     echo '<td>'; include 'table-no.php'; echo '</td>';   } else {     echo '<td>'; include 'table.php'; echo '</td>';   }   $j++;   if (($j==COLUMNS) && ($i!=(MAX_ROWS-1))) {     echo "</tr><tr>\n";     $j=0;   } } echo '</tr></table>'; [/code] Then I posted the code you gave me and got this reply. [quote] The code you have listed will not work because it echoes the include command into HTML where it has no meaning outside PHP. And by the way, do not include, but rather use different functions. As for your desired implementation of the code itself, you want to present a table of images (or something), six per page in 3x2 layout, correct? Then you can use the code that I gave you above, except you have to construct proper SQL query which tracks which page it presents and how many rows are per page (6). Tracking pages is simple, through &page=num (or whatever you want to call it) in the URL. You get the desired page number from $_GET['page'], don't forget to cast it into int, and construct the LIMIT clause: [/quote] [code] //$num_rows contains the total number of rows in the table $page= (isset($_GET['page'])) ? (int) $_GET['page'] : 1; if ($page>floor($num_rows/6)) $page= floor($num_rows / 6); if ($page<1) $page=1; $start= ($page-1) * 6; $query= "SELECT data FROM table WHERE cat='$cat' LIMIT $start, 6"; // perform query and display results [/code]
  10. mendoz

    Solved

    Huggie, I can't thank you enough. If you ever need something graphics/web desgin related email me at dror.wolmer@gmail.com I'll test this ASAP thanks
  11. mendoz

    Solved

    No rush man. I started working on those tables since I acidently destroyed my database.  :P
  12. mendoz

    Solved

    bump, Please tell me if this is against the rules
  13. [quote author=jmilane link=topic=109415.msg440932#msg440932 date=1159194181] [quote author=thorpe link=topic=109415.msg440924#msg440924 date=1159193906] A simple example. [code=php:0] <?php   if (isset($_GET['id'])) {     echo "You clicked foo";   } else {     echo "<a href='?id=foo'>foo</a>";   } ?> [/code] This is all within one page but should give you the idea. [/quote] So the $_GET var would be passed just in the url... like www.mysite.com/search?id=foo But then the file itself would simply be named www.mysite.com/search.php? And then the $_GET var would be whatever immediately follows the ? (in this case 'id'?) Thanks! Even if I am wrong... [/quote] It will be named www.mysite.com/search.php,
  14. mendoz

    Solved

    [pre]Horizontal: 1  2  3 4  5  6 [/pre] Something like this. I'll owe you big time if you can pull this one!
  15. mendoz

    Solved

    I think I'll make a page called 'tables.php' with a table in it with two rows and three columns, inside every cell I'll put an <? include ([color=blue]'table.php[/color]'); ?>. 'tables.php' will connect to a specific database via a var ('tables.php?cat=[color=red]cat1[/color]'). Then I want it to check how many rows are in that database. I want up to 6 <? include ('[color=blue]table.php[/color]'); ?>. in a page. So, if for example I have 10 rows in database '[color=green]cat1[/color]', I'll have a page with 6 <? include ('[color=blue]table.php[/color]'); ?>, and a second page with 4 <? include ('[color=blue]table.php[/color]'); ?>, And two <? include ('[color=brown]table-no.php[/color]'); ?>, 'tables.php?cat=cat1?id=0': [table][tr][td]<? include ('[color=blue]table.php[/color]'); ?>,[/td][td]<? include ('[color=blue]table.php[/color]'); ?>,[/td][td]<? include ('[color=blue]table.php[/color]'); ?>,[/td][/tr] [tr][td]<? include ('[color=blue]table.php[/color]'); ?>,[/td][td]<? include ('[color=blue]table.php[/color]'); ?>,[/td][td]<? include ('[color=blue]table.php[/color]'); ?>,[/td][/tr][/table] next 'tables.php?cat=cat1?id=1': [table] [tr] [td]<? include ('[color=blue]table.php[/color]'); ?>,[/td] [td]<? include ('[color=blue]table.php[/color]'); ?>,[/td] [td]<? include ('[color=blue]table.php[/color]'); ?>,[/td] [/tr] [tr] [td]<? include ('[color=blue]table.php[/color]'); ?>,[/td] [td]<? include ('[color=brown]table-no.php[/color]'); ?>,[/td] [td]<? include ('[color=brown]table-no.php[/color]'); ?>,[/td] [/tr] [/table] previous
  16. mendoz

    Solved

    [code] <?php mysql_connect( "localhost", "username", "password" ); // Use correct stuff there mysql_select_db( "databse" ); // Use Database Name $cat=$_GET['cat']; // Select total results for pagination $result = mysql_query("SELECT count(id) FROM $cat"); $num_records = mysql_result($result,0,0); // Set maximum number of rows and columns $max_num_rows = 2; $max_num_columns = 3; $per_page = $max_num_columns * $max_num_rows; // Work out how many pages there are $total_pages = ceil($num_records / $per_page); // Get the current page number if (isset($_GET['page'])) $page = $_GET['page']; else $page = 1; // Work out the limit offset $start = ($page - 1) * $per_page; // Select the results we want including limit and offset $result = mysql_query("SELECT id FROM $cat ORDER BY id LIMIT $start, $per_page"); $num_columns = ceil(mysql_num_rows($result)/$max_num_rows); $num_rows = ceil(mysql_num_rows($result)/$num_columns); // Echo the results echo "<center><table bgcolor=\"#D5D5D5\" border=\"0\">\n"; for ($r = 0; $r < $max_num_rows; $r++){ echo "<tr>\n"; for ($c = 0; $c < $max_num_columns; $c++){ // 1 $x = $r * $max_num_columns + $c; if ($x < mysql_num_rows($result)){ //                  $y = mysql_result($result, $x, 0); // Commented out so I could show your example                     $num = mysql_result($result, $x, 0);                     $id=$x+$start;                   $y = <<<HTML <table align="center" border="0" cellpadding="0" cellspacing="0" width="145">   <tr>     <td width="16"><img src="about_files/top_lef.gif" alt="a" width="16" height="16">     </td>     <td background="about_files/top_mid.gif" height="16">       <img src="about_files/top_mid.gif" alt="a">     </td>     <td width="16">       <img src="about_files/top_rig.gif" alt="a" width="16" height="16">     </td>   </tr>   <tr>     <td background="about_files/cen_lef.gif" width="16">       <img src="about_files/cen_lef.gif" alt="a">     </td>     <td align="left" bgcolor="#ffffff" valign="middle">       <div align="center">         <a href="movie.php?cat={$cat}&id={$id}">         <img src="movies_img/{$cat}/thumb/{$num}.jpg" width="114" height="86" border="1"></a>       </div>     </td>     <td background="about_files/cen_rig.gif" width="16">       <img src="about_files/cen_rig.gif" alt="a">     </td>   </tr>   <tr>     <td height="16" width="16">       <img src="about_files/bot_lef.gif" alt="a" width="16" height="16">     </td>     <td background="about_files/bot_mid.gif" height="16">       <img src="about_files/bot_mid.gif" alt="a">     </td>     <td height="16" width="16">       <img src="about_files/bot_rig.gif" alt="a" width="16" height="16">     </td>   </tr> </table> HTML;                 }                 else {                   $y = '<table align="center" border="0" cellpadding="0" cellspacing="0" width="145">       <tr>         <td width="16"><img src="about_files/top_lef.gif" alt="a" width="16" height="16"></td>         <td background="about_files/top_mid.gif" height="16"><img src="about_files/top_mid.gif" alt="a"></td>         <td width="16"><img src="about_files/top_rig.gif" alt="a" width="16" height="16"></td>       </tr>       <tr>         <td background="about_files/cen_lef.gif" width="16"><img src="about_files/cen_lef.gif" alt="a"></td>         <td align="left" bgcolor="#ffffff" valign="middle"><div align="center"> <img src="html/images/bekarov.jpg" width="114" height="86" border="1"></font></div></td>         <td background="about_files/cen_rig.gif" width="16"><img src="about_files/cen_rig.gif" alt="a"></td>       </tr>       <tr>         <td height="16" width="16"><img src="about_files/bot_lef.gif" alt="a" width="16" height="16"></td>         <td background="about_files/bot_mid.gif" height="16"><img src="about_files/bot_mid.gif" alt="a"></td>         <td height="16" width="16"><img src="about_files/bot_rig.gif" alt="a" width="16" height="16"></td>       </tr>     </table>';                 } echo "<td>";                 echo "$y";                 echo "</td>"; } echo "</tr>\n"; } // Echo page numbers echo "</table>\n"; for ($i=1;$i <= $total_pages;$i++) { if ($i == $page) echo " $i "; else echo " <a href=\"?cat=$cat&page=$i\">$i</a> "; } ?> [/code]
×
×
  • 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.