Jump to content

MoFish

Members
  • Posts

    227
  • Joined

  • Last visited

Posts posted by MoFish

  1.     public function get_all_league()
        {
            $db = new sql();
            $sql = "SELECT * FROM $this->tablename";
            $returned = $db->query($sql);
            $data = $returned->$db->fetch_array();
            $section_object = new section_object();
        
            if(!empty($data)){
                while($k = $db->fetch_array($db))
                {
                    $total[] = $k;
                }
            }
            return $total;
        }
    

    Updated code. No Joy

  2.     function query($sql_query)
        {
            
            $this->sql_query=$sql_query;
            $this->sql_result=mysql_query($this->sql_query);
            $this->error=mysql_error();
            if (!$this->sql_result)
            {
                echo "<b>" . $sql_query . "</b><br><br>";
                $this->error=mysql_error();
                echo $this->error;
            }
            echo mysql_error();
        }
    

    is my query function objnoob

  3. Hi,

     

    I updated the code as suggested - but it now returns no values.

     

    Can you clarify if i got this correct?

     

    Should the fetch_array still be in the while loop as I had previously?

        public function get_all_league()
        {
            $db = new sql();
            $sql = "SELECT * FROM $this->tablename";
            $db->query($sql);
            $data = $db->mysql_num_rows();
            $section_object = new section_object();
        
            if(!empty($data)){
                while($k = $db->fetch_array($db))
                {
                    $total[] = $k;
                }
            }
            return $total;
        }
    
  4. What are you expecting? 

     

    What foreach?

     

    Appologies,

     

    It is a while statement:

    while($k = $db->fetch_array($db))
    

    There are three entries in the database and it is only returning two in the print_r statement.

     

    Do I need to maybe add the values of $data into the total[] array I am returning somehow?

     

    Thanks

     

    MoFish

  5. Hi,

     

    I have a foreach running on the results for SQL query, but only get two results appearing.

     

    I am expecting three to be displayed.

     

    Can anyone see any major problem with this?

        public function get_all_league()
        {
            $db = new sql();
            $sql = "SELECT * FROM $this->tablename";
            $db->query($sql);
            $data = $db->fetch_array();
            $section_object = new section_object();
        
            if(!empty($data)){
                while($k = $db->fetch_array($db))
                {
                    $total[] = $k;
                }
            }
            return $total;
        }
    

    Thanks,

     

    MoFish

  6. Hi,

     

    I have a button which does 3 processes behind the scenes such as database imports and file extracts.

     

    I'm trying to write out a % status to indicate which part of the process is running. I have created an update_progress() function which passes in the percentage complete, but find that I only ever see 100% complete once the full script has run.

    if(isset($_POST['btnOneClick'])){
    		
       echo update_progress(0);
       mysql_dump($sql_url);
       echo update_progress(30);
       move_file_local($zip_url);
       echo update_progress(50);
       extract_zip();
       echo update_progress(100);    
    	
    }
    

    In my update_progress function I have tried using flush() which I thought would have returned it to the screen instantly but have had no success. I also read that setting ini_set('output_buffering', 0); may have worked - but that also doesnt seem to work :(

    function update_progress($percent) {
       $bar = "<div class='progress-bar'  role='progressbar' aria-valuenow='$percent' aria-valuemin='0' aria-valuemax='100' style='width: $percent%'>
          <span class='sr-only'>$percent% Complete</span>
       </div>";
       return $bar;
       flush();
    }
    

    Could anyone point me in the right direction?

     

    Cheers,

     

    MoFish

  7. Hi Thanks for your help.

     

    I finally got rid of that 'Parent Directory'. It is now writing out the following:

    <a href="design1/"> design1/</a>
    

    Ideally i would like it to only return "design1" without the anchors or trailing forward slash.

     

    Could anyone help?

     

    My code is:

    // declare the folder
    $html = file_get_contents("http://www.mywebsite.com/folderlist/");
    preg_match_all('|<li>(.*)</li>|U', $html, $uu);
    $files = $uu[1];
    print_r($files[1]);
    

    Thanks

  8. Hi All,

     

    I'm trying to create a dropdown which will write out the directory structure names of another one of my servers (Remote URL)

     

    I have a script working (ish) however it keeps writing out "Parent Directory" as an option in my dropdown list.

     

    Could someone advise me on how to remove this? I've been looking into it for a while now. The structure of the HTML is.

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
    <html>
     <head>
      <title>Index of /myurl.com</title>
     </head>
     <body>
    <h1>Index of /myurl.com</h1>
    <ul><li><a href="/"> Parent Directory</a></li>
    <li><a href="design1/"> design1/</a></li>
    </ul>
    </body></html>
    

    Ok - so first i set the URL and attempt strip out the ULs and the LI including "Parent Directory" - This doesnt seem to work :)

    <?php
    $url = file_get_contents("http://www.myurlwhichhasdirectorylisting.co.uk");
    
    // do some line removing
    $newlines = array("\t","\n","\r","\x20\x20","\0","\x0B");
    $content = str_replace($newlines, "", html_entity_decode($url));
    
    // attempt to remove the ul and li (doesnt work)
    
    $start = strpos($content,"<ul><li><a href='/'>Parent Directory</a></li>");
    $end = strpos($content,"</ul>",$start) + 8;
    $table = substr($content,$start,$end-$start);
    preg_match_all("|<li(.*)</li>|U",$table,$rows);
    ?>
    

    Then i attempt to loop around the dropdown

                    	<?php 
    	                	foreach ($rows[0] as $row){
    	                		preg_match_all("|<li(.*)</li>|U",$row,$cells);
    	                		$var = strip_tags($cells[0][0]);
    	                		echo "{$var}\n";
    	                ?>
    	                	<option value="<?=$var;?>"><?=$var;?></option>
    	                <?php } ?>
    

    I'm probably doing this a very long winded way :)

     

    Thanks!

  9. Hey everyone.

     

    Can someone point me in the right direction as to how I can access my get_all() function through the news_areas()

     

    The following code works to access get_all() through the __construct

     

    <?php 
    $nm = new newsManager();
    $news = $nm->get_all();
    ?>
    

     

    but when i try something like the following; it doesnt seem to work.

     

    <?php 
    $nm = new newsManager();
    $news = $nm->news_areas->get_all();
    ?>
    

     

    More than likely a syntax problem with the above line; as im not sure thats the correct way to do it

     

    <?php
    class newsManager extends masterManager  {
        
        private $tablename;
        
        public function __construct()
        {
        	$this->tablename = "_news";
        	parent::__construct($this->tablename);
        }
    
    public function news_areas()
    {
        	$this->tablename = "_news_areas";
        	parent::__construct($this->tablename);
    }
        
    }
    ?>
    

     

    Thanks for your time.

     

  10. Hello Everyone!

     

    I've recent been using Zigmoyd [http://zigmoyd.net] for my web development, but have a small query regarding the include files and paths.

     

    when i include the following, it works fine, even although the zend folder is back one directory in my folder.

     

    include_once('zigmoyd/config.php');
    include_once('template/template.php');
    include_once('db/sql.php');
    include_once('ums/customize.php');
    include_once('done.php');
    

     

    i then try'd the following to go back one directory using ./ and it still worked?

     

    include_once('./zigmoyd/config.php');
    include_once('./template/template.php');
    include_once('./db/sql.php');
    include_once('./ums/customize.php');
    include_once('./done.php');
    

     

    i then try'd to go back using ../ and a load of error appeared complaining at the files location.

     

    include_once('../zigmoyd/config.php');
    include_once('../template/template.php');
    include_once('../db/sql.php');
    include_once('../ums/customize.php');
    include_once('../done.php');
    

     

    which one is correct, and why does both normall dir and ./dir work?

     

    i'm rather confused. also does anyone know if you can use PHP code in-with the template class?

     

    any help would be much appreciated.

     

    Mo

  11. Hello.

     

    Im trying to find the highest value of a value in my database called LeagueWoodenSpoon.

     

    On the highest value, i want to set $image="spoon.gif"

     

    i tryed the following code, but it adds a spoon.gif to everything over 0 and not only the highest value

     

    can anyone point me in the right direction?

     

    the following code is inwith a loop which goes through every value in my database.

     

    $SpoonFlag = 0;
    
    if($row_SelectAllLeague['LeagueWoodenSpoon'] > $SpoonFlag){
      $SpoonFlag = $row_SelectAllLeague['LeagueWoodenSpoon'];
      $image='spoon.gif';
    }
    

  12. the top three are suppost to be gold.gif silver.gif and bronze.gif, the rest are suppost to be none.gif.

     

    source from page = "  <td align="center"><img src='images/'></td> " - nothing :(

     

    oh, so if the first element is removed from the array... how does the gold icon still appear?

     

    confusing

  13. Hello. I'm currently making a league and wanted icons beside the top three positions in the league table: gold, silver and bronze.

     

    The code im using appears to be working to some extent, but .. the 4th row is blank all the time.

     

    If i add a 4th value to the array, it simply shifts to the 5th row being blank.

     

    I cant figure out whats going on here at all.

     

    can anyone see the problem? i've been trying to find it out for days now.

     

    leagueimagewr9.jpg

     

    <?php
    error_reporting(E_ALL);
    $colors=array('#DAEBFF', '#DAEBFF', '#DAEBFF');
    $images=array('gold1.gif', 'silver1.gif', 'bronze1.gif');
    do{
    if(isset($colors)){
      $color=array_shift($colors);
      if(is_null($color)){
       unset($colors);
      }
    }else{
      $color='#C4DFFF';
    }
    if(isset($images)){
      $image=array_shift($images);
      if(is_null($image)){
       unset($images);
      }
    }else{
      $image='none.gif';
    }
    
    //all my display table is here
    //echo "<img src='images/" . $image ."'>"; etc
    
    }while($row_SelectAllLeague=mysql_fetch_assoc($SelectAllLeague));
    ?>
    

×
×
  • 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.