Jump to content

completeamateur

Members
  • Posts

    69
  • Joined

  • Last visited

    Never

Posts posted by completeamateur

  1. Hi guys,

     

    I want to code the breadcrumb for my website i.e.

     

    Home > Book > Chapter > Page

     

    My navigation is structured in a table aptly named 'navigation'.

     

    CREATE TABLE IF NOT EXISTS `navigation` (
      `navID` smallint(5) unsigned NOT NULL auto_increment,
      `nav` text character set utf8 NOT NULL,
      `url` text character set utf8 NOT NULL,
      `parentID` smallint(5) unsigned default NULL,
      PRIMARY KEY  (`navID`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;

     

    A contentID (linked to navID) is specified for the current page.  Will I have to 'backwards search' the navigation table for the relevant chapter/book?

     

    All suggestions welcome...

  2. Hi there,

     

    I set up Zend Framework on my local machine by including the library in the php.ini file.

     

    Unfortunately I don't have access to this file on my hosting so I've tried including the path in the bootstrapper file...

     

    http://www.villa4life.co.uk/public/

     

    Not sure what I'm doing wrong...

     

    /home/benmuncey/1Y0GS2D9/htdocs/villa4life/ = $_SERVER['DOCUMENT_ROOT']

    /home/benmuncey/1Y0GS2D9/library/ = Zend Framework Library (& include path)

     

    I'm confused ???

     

    I realise this might not be the right place to post, but I've had no responses on the other board.

  3. Hi there,

     

    I set up zend framework on my local machine by including the library in the php.ini file.

     

    Unfortunately I don't have access to this file on my hosting so I've tried including the path in the bootstrapper file...

     

    http://www.villa4life.co.uk/public/

     

    Not sure what I'm doing wrong...

     

    /home/benmuncey/1Y0GS2D9/htdocs/villa4life/ = $_SERVER['DOCUMENT_ROOT']

    /home/benmuncey/1Y0GS2D9/library/ = Zend Framework Library (& include path)

     

    I'm confused  ???

  4. I've lost all my websites... forever?

     

    I've inadvertently lost all my files (& I allowed my hosting to lapse).  Unfortunately archive.org hasn't picked up the file that I'm looking for.  Does anybody know of any other similar sites that may help me.

     

    I really am a complete amateur.

  5. Hi,

     

    I am running a loop to generate the meta tags for a page, but if the database contains no meta tags, php throws a warning...

     

    Warning: Invalid argument supplied for foreach() in /Library/WebServer/Documents/villa4life/application/layouts/layout.phtml on line 6

     

    foreach($this->metadata as $metadata)

     

    Is there anyway to prevent this? TIA

  6. Hi there,

     

    I have run through the "Getting started with zend..." tutorial which went fairly smoothly.  I'm now trying to run a simple query but Zend keeps throwing the error:

     

    Fatal error: Uncaught exception 'Zend_Db_Statement_Exception' with message 'SQLSTATE[21000]: Cardinality violation: 1241 Operand should contain 1 column(s)' in /Library/WebServer/Documents/library/Zend/Db/Statement/Pdo.php:238 Stack trace: #0 /Library/WebServer/Documents/library/Zend/Db/Statement.php(283): Zend_Db_Statement_Pdo->_execute(Array) #1 /Library/WebServer/Documents/library/Zend/Db/Adapter/Abstract.php(430): Zend_Db_Statement->execute(Array) #2 /Library/WebServer/Documents/library/Zend/Db/Adapter/Pdo/Abstract.php(220): Zend_Db_Adapter_Abstract->query(Object(Zend_Db_Table_Select), Array) #3 /Library/WebServer/Documents/library/Zend/Db/Table/Abstract.php(1189): Zend_Db_Adapter_Pdo_Abstract->query(Object(Zend_Db_Table_Select)) #4 /Library/WebServer/Documents/library/Zend/Db/Table/Abstract.php(1044): Zend_Db_Table_Abstract->_fetch(Object(Zend_Db_Table_Select)) #5 /Library/WebServer/Documents/villa4life/application/controllers/BodymoorheathController.php(10): Zend_Db_Table_Abstract->fetchAll('SELECT * FROM c...') #6 in /Library/WebServer/Documents/library/Zend/Db/Statement/Pdo.php on line 238

     

    I believe this is the problem code:

     

    $this->view->comments = $comments->fetchAll('SELECT * FROM comments ORDER BY dateTime');

     

    Any suggestions.  I'm very confused by the fundamentals of executing queries in Zend.

  7. Thanks for your input...

     

    I would probably add a way to categorize the content.

     

    The navigation will categorize the content, kind of!?

     

    Maybe have a

     

    Global_Nav table and then a Lower_Nav table. That way you can have sub-categories etc. Parent id in Lower Nav links with primary key of Global Nav.

     

    Also maybe a global table that allows you to make changes to the entire site. For example, what if the person wanted to add Kontera advertising?

     

    Using ParentID means that the navigation can contain as many tiers as necessary.  I think it is a cleaner way than having a table for each tier.  Perhaps I've misunderstood.

     

    Regarding changes to the whole site, I am working with the Zend framework which allows for common changes throughout the site..

  8. Hi guys,

     

    I have been developing with php for a number of years and have just taken the plunge and begun looking at using a framework (namely Zend).  I am keen to streamline my design/programming skills so I am following 'best practices'.

     

    As such I want to develop a core structure to my websites to produce the navigation and content dynamically.  I have come up with three tables in order to do this...

     

    NAVIGATION

    -NavID (PK)

    -Nav

    -URL

    -ParentID

     

    CONTENT

    -ContentID (PK)

    -Title

    -Content

    -NavID (FK)

     

    METADATA

    -MetaID (PK)

    -MetaTag

    -MetaData

    -ContentID (FK)

     

    I would be very interested to hear anyone's comments/suggestions on how it could be improved. Thanks in advance.

  9. Hello,

     

    I'm looking to optimise the structure of the database behind my website, www.footieclassics.com.

     

    There are 25 potential options for each shirt, e.g. an '96 England Shirt' can be purchased in a 'Medium', in 'Excellent' condition.  I am looking for a way to structure the database to avoid repeated data.

     

    Any ideas?

     

    [Products]

    |

    +--[National Teams]

    |  |

    |  +--[Argentina]

    |  +--[brazil]

    |  +--[England]

    |    |

    |    +--[96 England Shirt]

    |    +--[04 England Shirt]

    |    +--[06 England Shirt]

    |        |

    |        +--[small]

    |        +--[Medium]

    |        +--[Large]

    |        +--[X-Large]

    |        +--[XX-Large]

    |          |

    |          +--[Excellent]

    |          +--[Good]

    |          +--[Average]

    |          +--[Poor]

    |          +--[Very Poor]

    |

    +--[Premiership]

    +--[Championship]

  10. Hi there, I'm designing a website where visitors will be able to record the football games they've attended.

     

    Ideally this will be done by toggling a checkbox displayed next to each game (see http://www.awayfans.co.uk/results/index.php?confederationID=7&countryID=4&divisionID=6&clubID=93&season=2006 for an example [no code behind checkboxes]).  There may be up to 60-70 games displayed on a page.

     

    If a user has attended a game, they check the checkbox which will add an entry to a table containing the user ID and the game ID.

     

    When the checkbox is unchecked, it will remove the entry from the same table.

     

    My question is, should the table be updated when the checkbox is toggled (by submitting a unique form for each particular game using javascript) or should there be one form for all the matches with a submit button for the lot)???

     

    I hope that makes sense.  All suggestions appreciated.

  11. In a nut shell...

     

    $query = "SELECT * FROM result WHERE 
    ((YEAR(datetime) = $start AND MONTH(datetime) >= $division[start]) OR
    (YEAR(datetime) = $finish AND MONTH(datetime) < $division[start])) AND
    ((home = $clubID) OR (away = $clubID)) ORDER BY datetime";
    $result1 = mysql_query("$query");
    
    if (mysql_num_rows($result1) > 0) {
    
    $i = 1;
    while ($match = mysql_fetch_array($result1)) {
    
    	//Obtain data
    	$tstamp = strtotime($match['datetime']);
    
    	$query = "SELECT name,acc FROM competition WHERE (id = $match[competition])";
    	$result = mysql_query("$query");
    	$competition = mysql_fetch_array($result);
    
    	if ($clubID == $match['home']) { $oppositionID = $match['away']; } else { $oppositionID = $match['home']; }
    	$query = "SELECT name FROM club WHERE (id = $oppositionID)";
    	$result = mysql_query("$query");
    	$opposition = mysql_fetch_array($result);
    
    	$query = "SELECT name FROM ground WHERE (id = $match[ground])";
    	$result = mysql_query("$query");
    	$ground = mysql_fetch_array($result);
    
    	if ( $i&1 ) {
    		$oe = 'odd';
    	} else {
    		$oe = 'even';
    	}
    
    }
    }

  12. Fenway, I'm afraid you seem to talk a different language to me.  I have uploaded the 'problem' script as a text file @ http://www.awayfans.co.uk/index.txt

     

    The first problem is the query on line 261.  It functions correctly, but I think it may be possible to improve efficiency by incorporating the queries that are made on lines 285 to 296 -but I don't know how to go about optimizing it (you may remember my earlier post) -the query seems complicated enough as it is (to me), without having to join(?) it with 3 other tables.

     

    The other problem is regarding the 'record' table...

    CREATE TABLE `record` (
      `id` mediumint( unsigned NOT NULL auto_increment,
      `user` mediumint( unsigned NOT NULL,
      `result` mediumint( unsigned NOT NULL,
      PRIMARY KEY  (`id`)
    )

     

    Referring back to the file, the checkbox on line 306 should:

    • be checked if an entry exists in the table 'record' where result = $match['id'] & user = $SESSION['id']
    • add an entry to the table 'record' if checked
    • remove an entry from the table 'record' if unchecked

     

    I'm so bloody confused...  ???

     

    I don't like to beg, but please, please, please HELP!  I'll be willing to paypal $10-20 if you (or somebody) can help me out with a simple solution.

     

    Many thanks.

     

     

  13. I am designing the web site www.awayfans.co.uk to allow visitors to record the football matches they've attended.  To do this, there are 2 main tables:

     

    result (contains: id, teams, scoreline, venue, date, etc)

     

    record (contains: id, result, user)

     

    I want to allow users to record and view the matches they've attended by using checkboxes displayed next to each result.

    http://www.awayfans.co.uk/results/index.php?confederationID=7&countryID=4&divisionID=6&clubID=93&season=2006

     

    FYI, the query I currently use to select the results for a given season is...

    $query = "SELECT * FROM result WHERE 
    ((YEAR(datetime) = $start AND MONTH(datetime) >= $division[start]) OR
    (YEAR(datetime) = $finish AND MONTH(datetime) < $division[start])) AND
    ((home = $clubID) OR (away = $clubID)) ORDER BY datetime";

     

    My question is... Do I have to query the 'record' table for each result individually (to see if there is an entry where both the user and the result exist together), or can this be done with one query.

     

    Any help would be much appreciated (including help with other aspects of the site!).

     

    Many thanks,

    Ben.

     

    [EDIT: I also want users to be able to toggle the checkbox for each result to update whether they have been to each match?]

  14. I require PHP developers to help me finish a project.

     

    There are a couple of conditions:

    -You must be a U.K. based football supporter.

    -You must be willing to work for FREE (this is a non-profit venture).

     

    It is essential that you have moderate to very good php/MySQL programming skills.

     

    Still interested? Read on for detail...

     

    A few years ago I registered the domain name www.awayfans.co.uk.  The website features quite highly in google and receives a reasonable amount of traffic (despite there being diddly squat on there).

     

    A few years ago I had the idea of hosting a "football wikipedia" at the domain, but it is not until recently I have had the time to anything about it.  Eventually (!), by registering for free, visitors will be able to:

    -post/edit information on clubs and grounds.

    -enter past results (club/national teams).

    -record the matches that they have attended.

     

    The aim is to provide visitors with an interactive experience.  A registered user will be able to access information on the number of matches they've attended and view the locations of the grounds they've visited.  The website will also include a message board.

     

    I begun the project approx. 6 weeks ago and feel I've made a lot of progress.  I just need a hand to finish it off and improve it further.

     

    The progress thus far has been put up on the site... it is incomplete and riddled with errors (particularly past results, where you shouldn't enter any data).  If you have a play with the site, it will give you some idea of the intention of the project.  For those of you who are security conscious, passwords are stored using the md5 encryption algorithm, with salts.  Use the username/password: benmuncey/password to play about.

     

    If anyone is interested to know a bit more, drop me an email at (ben_muncey@hotmail.com).  If you include a telephone number, i'll give you a call.  If you are midlands based, it would be good to meet up and discuss the project over a pint or two.

    (Coventry/Birmingham/Wolverhampton)

  15. But that will lead to a LOT of repeated data?  I thought efficient database design segregated duplicate data to individual tables, the tables being linked by indexes known as 'foreign keys'?

     

    EDIT: Perhaps the "result" table could be optimised by splitting:

     

    home, away, competition, ground

     

    into:

     

    hometeamname, homeID

    awayteamname, awayID

    competition, compID

    ground, groundID

     

    ???

  16. My table definitions are:

     

    -- 
    -- Table structure for table `club`
    -- 
    
    CREATE TABLE `club` (
      `id` smallint(5) unsigned NOT NULL auto_increment,
      `name` tinytext NOT NULL,
      `ground` tinytext,
      `division` smallint(5) unsigned default NULL,
      `country` tinyint(3) unsigned NOT NULL,
      `user` mediumint( unsigned NOT NULL,
      PRIMARY KEY  (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=93 ;
    
    -- --------------------------------------------------------
    
    -- 
    -- Table structure for table `competition`
    -- 
    
    CREATE TABLE `competition` (
      `id` smallint(5) unsigned NOT NULL auto_increment,
      `name` tinytext NOT NULL,
      `acc` tinytext NOT NULL,
      `country` tinyint(3) unsigned NOT NULL,
      `type` tinyint(2) unsigned NOT NULL,
      `tier` tinytext NOT NULL,
      `start` tinyint(2) unsigned zerofill NOT NULL,
      `user` mediumint( unsigned NOT NULL,
      PRIMARY KEY  (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;
    
    -- --------------------------------------------------------
    
    -- 
    -- Table structure for table `comptype`
    -- 
    
    CREATE TABLE `comptype` (
      `id` tinyint(2) NOT NULL auto_increment,
      `name` tinytext NOT NULL,
      PRIMARY KEY  (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
    
    -- --------------------------------------------------------
    
    -- 
    -- Table structure for table `confederation`
    -- 
    
    CREATE TABLE `confederation` (
      `id` tinyint(1) unsigned NOT NULL auto_increment,
      `name` tinytext NOT NULL,
      `detail` tinytext NOT NULL,
      PRIMARY KEY  (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ;
    
    -- --------------------------------------------------------
    
    -- 
    -- Table structure for table `country`
    -- 
    
    CREATE TABLE `country` (
      `id` tinyint(3) unsigned NOT NULL auto_increment,
      `name` tinytext NOT NULL,
      `confederation` tinyint(1) unsigned NOT NULL,
      `user` mediumint( unsigned NOT NULL,
      PRIMARY KEY  (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
    
    -- --------------------------------------------------------
    
    -- 
    -- Table structure for table `ground`
    -- 
    
    CREATE TABLE `ground` (
      `id` smallint(5) unsigned NOT NULL auto_increment,
      `name` tinytext NOT NULL,
      `capacity` mediumint(6) unsigned NOT NULL,
      `address` tinytext NOT NULL,
      `postcode` tinytext NOT NULL,
      `ticketoffice` tinytext NOT NULL,
      `ticketprice` tinytext NOT NULL,
      `country` tinyint(3) unsigned NOT NULL,
      `user` mediumint( unsigned NOT NULL,
      PRIMARY KEY  (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
    
    -- --------------------------------------------------------
    
    -- 
    -- Table structure for table `log`
    -- 
    
    CREATE TABLE `log` (
      `id` mediumint( unsigned NOT NULL auto_increment,
      `user` smallint(5) unsigned NOT NULL,
      `datetime` datetime NOT NULL,
      PRIMARY KEY  (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
    
    -- --------------------------------------------------------
    
    -- 
    -- Table structure for table `record`
    -- 
    
    CREATE TABLE `record` (
      `id` smallint(5) unsigned NOT NULL auto_increment,
      `user` mediumint( unsigned NOT NULL,
      `match` mediumint( unsigned NOT NULL,
      PRIMARY KEY  (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
    
    -- --------------------------------------------------------
    
    -- 
    -- Table structure for table `result`
    -- 
    
    CREATE TABLE `result` (
      `id` mediumint( unsigned NOT NULL auto_increment,
      `home` smallint(5) unsigned NOT NULL,
      `hg` tinyint(2) NOT NULL,
      `away` smallint(5) unsigned NOT NULL,
      `ag` tinyint(2) NOT NULL,
      `competition` smallint(5) unsigned NOT NULL,
      `ground` smallint(5) unsigned NOT NULL,
      `datetime` datetime NOT NULL,
      `user` mediumint( unsigned NOT NULL,
      PRIMARY KEY  (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ;
    
    -- --------------------------------------------------------
    
    -- 
    -- Table structure for table `user`
    -- 
    
    CREATE TABLE `user` (
      `id` mediumint( unsigned NOT NULL auto_increment,
      `username` varchar(20) NOT NULL,
      `forename` varchar(20) default NULL,
      `surname` varchar(20) default NULL,
      `password` varchar(32) NOT NULL,
      `salt` varchar(3) NOT NULL,
      `email` varchar(50) NOT NULL,
      PRIMARY KEY  (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
    

  17. Roughly 60 results per season and 3 queries made per result...

     

    I'm afraid my code will probably make you cringe, I should probably get some tuition in web design.

     

    $query = "SELECT name FROM confederation WHERE (id = $confederationID) ORDER BY name";
    $result = mysql_query("$query");
    $confederation = mysql_fetch_array($result);
    
    $query = "SELECT name FROM country WHERE (id = $countryID)";
    $result = mysql_query("$query");
    $country = mysql_fetch_array($result);
    
    $query = "SELECT name,start FROM competition WHERE (id = $divisionID)";
    $result = mysql_query("$query");
    $division = mysql_fetch_array($result);
    
    $query = "SELECT name FROM club WHERE (id = $clubID)";
    $result = mysql_query("$query");
    $club = mysql_fetch_array($result);
    
    echo ("
          <div class='navigator'>
            <a href='$server_url'>Home</a> »
            Clubs (<a href='$server_url/clubs/index.php?confederationID=$confederationID'>$confederation[name]</a> »
            <a href='$server_url/clubs/index.php?confederationID=$confederationID&countryID=$countryID'>$country[name]</a> »
            <a href='$server_url/clubs/index.php?confederationID=$confederationID&countryID=$countryID&divisionID=$divisionID'>$division[name]</a>) »
            $club[name]
          </div>
          <h1>$club[name] Results</h1>
          <p>
            <span style='float:right; padding:0px 3px; text-align: center; width:40px;'>Att [<a href=''>?</a>]</span>
            <span style='float:right; padding:0px 3px; text-align: center; width:175px;'>Venue</span>
            <span style='float:right; padding:0px 3px; text-align: center; width:40px;'>Score</span>
            <span style='float:right; padding:0px 3px; text-align: center; width:175px;'>Opposition</span>
            <span style='float:right; padding:0px 3px; text-align: center; width:40px;'>Type</span>
            <span style='display: block; padding:0px 3px; text-align: center; width:60px;'>Date</span>
          </p>");
    
    $query = "SELECT * FROM result WHERE ((YEAR(datetime) = 2008 AND MONTH(datetime) < 07) OR (YEAR(datetime) = 2007 AND MONTH(datetime) > 07)) AND (home = $clubID) OR (away = $clubID) ORDER BY datetime";
    //	((home = $clubID) OR (away = $clubID))
    $result1 = mysql_query("$query");
    
    $i = 1;
    while ($match = mysql_fetch_array($result1)) {
    
    //Obtain data
    $tstamp = strtotime($match['datetime']);
    
    $query = "SELECT name,acc FROM competition WHERE (id = $match[competition])";
    $result = mysql_query("$query");
    $competition = mysql_fetch_array($result);
    
    if ($clubID == $match['home']) { $opposition = $match['away']; } else { $opposition = $match['home']; }
    $query = "SELECT name FROM club WHERE (id = $opposition)";
    $result = mysql_query("$query");
    $opposition = mysql_fetch_array($result);
    
    $query = "SELECT name FROM ground WHERE (id = $match[ground])";
    $result = mysql_query("$query");
    $ground = mysql_fetch_array($result);
    
    if ( $i&1 ) {
    	$oe = 'odd';
    } else {
    	$oe = 'even';
    }
    
    echo("
          <div class='$oe'>
            <span style='float:right; padding:0px 3px; text-align: center; width:40px;'><input type='checkbox' name='option1' value='Milk' style='margin: 2px 0px 0px 0px; padding: 0px;' /></span>
            <span style='float:right; padding:0px 3px; width:175px;'>$ground[name]</span>
            <span style='float:right; padding:0px 3px; text-align: center; width:40px;'>$match[hg]-$match[ag]</span>
            <span style='float:right; padding:0px 3px; width:175px;'>$opposition[name]</span>
            <span style='float:right; padding:0px 3px; text-align: center; width:40px;'><acronym title='$competition[name]'>$competition[acc]</acronym></span>
            <span style='display: block; padding:0px 3px; text-align: center; width:60px;'>" . date('d/m/y', $tstamp) . "</span>
          </div>
          ");
    $i++;
    }
    
    }

  18. I'm worried about the number of queries that will be used on a single page load on the site I'm designing.

     

    As an estimate there will be up to 200 per page load when displaying football results (per season).

     

    Is this ridiculous or just me thinking it's ridiculous?

     

    Regards.

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