Printable Version of Topic

Click here to view this topic in its original format

Nexus Forums _ Nexus Atlas Official Forum _ Need A Programmer

Posted by: AllyGator Apr 29 2010, 12:04 PM

I have never claimed to be a programmer. Nexus Atlas needs one just for one short project. We've got so many multi-level caves now. I've love to have the monster information fed from the database. In the past the map pages have been typed in and that's a royal pain in the tush. Over the years, I have rebuild our old database into mySQL and redone almost all of our map pages using php with html templates so that dynamic data comes from the database. Updating only takes seconds now. Except for multi-level caves because I am NOT a programmer. I can, by trial and error sometimes get loops to work but it's really clunky.

Take this page where it loops correctly but there is no in-page link to let you go to the section you want:

http://www.nexusatlas.com/monsters/turtlecave.php

Icespadez made this page and I can't figure out why I can't adapt it to other pages like the one above:

http://www.nexusatlas.com/monsters/anchorite.php

So my biggest problem is map pages where I'd like to just have 1 field repeating for the experience OR if there is a difference in drops per level (and there sometimes is) put up an area with monster images then a brief table with experience and drops but again I can't do loops to save myself:

http://www.nexusatlas.com/50atlas/hunter.php

Can someone volunteer for this job?


Posted by: Falaris Apr 29 2010, 03:10 PM

This is not PHP. What you want to look up is a basic HTML feature called "anchors."

Notice the hyperlink. For example, the page name is "anchorite.php" but then when you mouse-over the links you get a # with some text after it depending on the link. For cave one it is "cl_1" which I'm assuming is short for cave level 1.

Basically all you do is go through the HTML and place a line of code for the anchor, with the name of the anchor in there (in the case above, the anchor name is "cl_1"). When you click the link with #cl_1 after it, it scans the page looking for where the anchor code is. Once it finds it, it scrolls the page down to that point.

So, to first make the link, you use a regular link HTML tag:

CODE
<a href="#anchorname1">LINK TEXT GOES HERE</a>


Ok, voila, the link is done. Now we set the point on the page it goes to with this:

CODE
<a name="anchorname1"></a>


Notice in the name, there is no # in front of the letters, and you still need a closing tag with the /a, but no link text should go inside since you are just using it as a marker on the page for where you want your original link to end up at. Put this piece of code wherever in the page you want to jump to.

For more reference, http://www.echoecho.com/htmllinks08.htm.


-Falaris

Posted by: AllyGator Apr 29 2010, 06:02 PM

sorry I don't want advise, I'm tired of beating my head, I want a programmer - if it were that simple, I would have done it

Posted by: Falaris Apr 29 2010, 06:58 PM

Fair enough. Maybe next time though you should ask for someone who knows how to copy and paste 1 extra line of code instead of a programmer.


-Falaris

Posted by: Dritz Apr 29 2010, 07:08 PM

I think what Ally means is they need someone good at templating which is a tad more complicated. I'd volunteer but I'm not real comfortable with SQL and PHP templates are ugly to look at (XSL all the way!)

Posted by: AllyGator Apr 29 2010, 10:01 PM

QUOTE (Falaris @ Apr 29 2010, 06:58 PM) *
Fair enough. Maybe next time though you should ask for someone who knows how to copy and paste 1 extra line of code instead of a programmer.


-Falaris


If it were SIMPLE I would have done it. Get the wax out bud. This is not a one line problem. It's not a 20 line problem. It's a conditional loop within a conditional loop within a loop. I think.

Your little example is already used in one of the examples given above. It doesn't solve the problem.

Posted by: Alston Apr 29 2010, 10:08 PM

Falaris, you do realize that the html on those pages you see are a result of PHP code working in the background on the server, right? You can't lookup the PHP source itself (trust me on this).

Posted by: Falaris Apr 29 2010, 11:04 PM

QUOTE (Alston @ Apr 29 2010, 10:08 PM) *
Falaris, you do realize that the html on those pages you see are a result of PHP code working in the background on the server, right? You can't lookup the PHP source itself (trust me on this).


Yes, I know how it works. She said she is using PHP within HTML templates. I was responding directly to the issue about linking to certain parts of the page. You can put those anchors in an HTML template outside of the PHP tags and have them work, and they would show up in the page source as they normally do since the template is HTML which is NOT generated at the time of the page view and is always static, unlike the stuff inside the PHP tags which generates what you will see as you open the page. What I was talking about did not have to interfere with the PHP at all anyway.

Anyway Ally, nevermind, I'm sorry I tried to help. After re-reading the initial post, it occurred to me that for some reason how the data is being called onto the page is probably much different than how I would do it and I guess I made basic assumptions that it would be done the same way I'd do it from the start, which was wrong of me. None of that really matters though seeing as you don't want advice anyway.


-Falaris

Posted by: Dritz Apr 29 2010, 11:15 PM

Not sure what you are trying to say Falaris (never used php to template before) but if you are trying to dynamically create menu options from SQL it could be tough for a newbie.

It should be fairly simple (from my rather limited perspective).

Something like this:

CODE
$array = SQLstuffpointingtosectionheadings

foreach ($array as $heading) {
echo '<a href="#'.$heading.'">'.$heading.'</a>';
}


Personally even that tiny snipit I find hard to read so someone less experienced than me might get confused with a lot of that stuff going on. Using PHP to dynamically generate a lot of html is messy and can be totally unreadable depending on who is writing it.

Posted by: Falaris Apr 30 2010, 12:05 AM

QUOTE (Dritz @ Apr 29 2010, 11:15 PM) *
Not sure what you are trying to say Falaris (never used php to template before) but if you are trying to dynamically create menu options from SQL it could be tough for a newbie.

It should be fairly simple (from my rather limited perspective).

Something like this:

CODE
$array = SQLstuffpointingtosectionheadings

foreach ($array as $heading) {
echo '<a href="#'.$heading.'">'.$heading.'</a>';
}


Personally even that tiny snipit I find hard to read so someone less experienced than me might get confused with a lot of that stuff going on. Using PHP to dynamically generate a lot of html is messy and can be totally unreadable depending on who is writing it.


What you are doing is trying to use PHP to do it, and you're right that it is confusing as it is to me too. I understand it well enough from my experience around web page design and PHP, but I probably couldn't code it nor would I, because I think the problem is that kind of code is an ultra-optimized, professional way of doing it when a simpler method is available for the non-professional PHP programmers who are just working on a fan website.

What I'm saying is that for this particular problem when it comes solely to having links at the top of the page which jump you to a lower part of the page, if the pages are HTML templates, then you should simply put the HTML code in the HTML template outside of the PHP tags rather than doing it via PHP. This shouldn't be hard as the links are at the top. So, you would just enter the HTML in my initial post into the correct spots most likely even before the PHP starts.

The argument could be made that the actual anchors themselves would interrupt the PHP if everything in the right-hand side of the page is generated via PHP with absolutely no use of basic HTML, but even then you would just break the PHP tag at the appropriate places in the HTML template. You could use PHP to do a ton of things to dynamically generate everything and make it much more streamlined than how I am suggesting to code it which is more of only calling for the PHP to input the data I need at specific points and using HTML for the rest, but again we aren't programming Microsoft.com here. Clearly, this is where my lack of PHP ability is showing through as I would opt to not do it that way, but I still think a less confusing approach even at the cost of .0000001ms load time of the page is worth it for a project like this.

The simplest way I can put it is that I would simply make a PHP page, again in an HTML template, that is simply a template of how each "cave level" section looks on those pages. In the HTML table, insert the PHP code in the right places calling for specific information from the MySQL entries with the name of the monster, picture, experience, drops, etc., based on the cave name and level you are calling. From there, any monsters in the database that fall under that entry could have it's data filled in for each monster that is in the database, generated dynamically as you call the page. Of course, the PHP generates the information based on the variable of what cave level and monster you want to call in the first place, which is easy enough if you just name your pages appropriately (if the cave name is "Turtle Cave," then make the page turtlecave.php and each SQL entry's cave name should likewise be 'turtlecave' of course).

I mean, truthfully, I can't even understand why having different drops or experience per cave level is an issue here. For each monster entry in the table, there should be multiple fields created for each monster, including one for cave name and level, along with monster name, experience, drops, etc.

I guess to put what I'm saying in code (not real code, just trying to get the message across without actually designing the page) what I would do based on the Anchorite page:

CODE
<HTML>
<head>
//All the stuff that goes in the head tags which doesn't matter goes here.
</head>

<body>
<table>
<tr><td>
//All the menu code goes here
</td>

<td>
Anchorite<br><br>

<a href="#anchor1">Link to First Anchor on the Page</a> - <a href="#anchor2">Link To The Second Anchor on the Page</a>
<hr>
//All the links for the other caves go here, can do this a few different ways.

<img src="whatever the name of the image that goes across splitting up the top navigation and bottom content sections is.jpg">

<a name="anchor1"></a>
<?php include("monstertablecave1.php"); ?>
//Not getting into the code for variables and getting the correct data, just showing the template and how I would do this
<br>

<a name="anchor2"></a>
<?php include("monstertablecave2.php"); ?>

</td></tr></table>
</body>
</HTML>


Like I said, it is uglier and less streamlined, but more appropriate I think to keep the majority of this as HTML and call the PHP only when you need it to display values from the database. The better you know PHP, the more you can do to not repeat yourself in code or you could even design each "monstertablecave.php" file to have all the anchors and cave levels all in one rather than calling multiple templates, or you could just use the cave level variables to use the same template since all the information for each monster is strictly dependent on the cave and level. I just did it in the most basic way that involved the least bit of PHP that I could. I think it is certainly less confusing for people who don't know PHP, but I might be wrong.


-Falaris

Posted by: AllyGator Apr 30 2010, 09:37 AM

It's not a discussion guys, it's a job offer. FYI - I may not be a programmer but I was a unix sys admin for 26 years. So far everything you have said, I have tried plus many, many, many more. My husband is a programmer and used to work for IBM research so he's no slouch and he isn't able to get it working. But he isn't a web programmer and doesn't know PHP. So like I said...

I need someone who knows mySQL and PHP!!!


If you do want to discuss it, I can get Rachel to set up a private forum for us.

Posted by: LEET May 1 2010, 10:48 AM

Paging Dereksmart

Posted by: Alston May 1 2010, 05:18 PM

I'd help, Ally, but my PHP's so rusty I'd get luckier programming C tongue.gif

I do know php.net has the entire manual up there, and I used to reference it a lot.

Posted by: Rachel May 1 2010, 06:58 PM

Just for the record, a lot of us don't know what we're doing and just figure it out as we go. Willingness to work is often more important than your ability to do so at whatever level you consider to be satsifactory (As long as you can figure enough out to get the job done). Over time, we learn things and fix our earliest mistakes. smile.gif

Posted by: DEREKSMART May 3 2010, 03:21 AM

ok i'll help you out, here i set up a simple db and a test page, based off of the last example you gave (I assume that's how you want it to look?)

http://www.activateskynet.com/images/natest.php

All the relevant data is pulled from the db, which i'm guessing in your example you wrote by hand instead.

Here is the code, it looks ugly because i copy+paste your site's html out to mimic the look

CODE
<?php
$username = "user";
$password = "pass";
$db = "db";

$query = "SELECT * FROM hunter";
?>

<font face="Verdana, Arial, Helvetica, sans-serif" color="#993300" size="1">
   <b>Monsters in Area :</b></font> <br>

        <table width="98%" border="1" cellspacing="0" cellpadding="0" bordercolor="#B1300D">
          <tr>
            <td align=middle bgcolor=#B1300D height=20 width="44%">
              <div align="center">

              <font color="#FEE956" face="Verdana" size="2"><strong>Creature</strong></font></div>
            </td>
            <td align=middle bgcolor=#B1300D height=20 width="27%">
              <div align="center"><font color="#FEE956" face="Verdana" size="2">
              <strong>Experience</strong></font></div>
            </td>
            <td align=middle bgcolor=#B1300D height=20 width="29%">
              <div align="center"><font color="#FEE956" face="Verdana" size="2">
              <strong>Item Drop</strong></font></div>

            </td>
          </tr>
        </table>

        <table width="98%" border="1" cellspacing="0" cellpadding="0"
           bordercolor="#B1300D">


<?php

mysql_connect("localhost", $username, $password) or
    die("Could not connect: " . mysql_error());
mysql_select_db($db);

$result = mysql_query($query);


while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
    
    echo '<tr><td width="24%">
              <div align="center">
  <font face="Verdana, Arial, Helvetica, sans-serif" size="-2" color="#330000">';
    
    $temp = $row["name"];
    echo '<b>'.$temp.'</b></font></div></td><td width="10%">
              <div align="center">';
    $temp = $row["pic1"];
    echo '<img src="'.$temp.'">';
    echo '<font face="Verdana, Arial, Helvetica, sans-serif" size="-2" color="#330000">
</font></div>
            </td>
            <td width="10%">
              <div align="center">';
              
    $temp = $row["pic2"];
    echo '<img src="'.$temp.'">';
    echo '<font face="Verdana, Arial, Helvetica, sans-serif" size="-2" color="#330000">
</font></div>
            </td>
            <td width="27%">
              <div align="center">
  <font face="Verdana, Arial, Helvetica, sans-serif" size="-2" color="#330000">';
  
    
    $i = 1;
    echo '<b>';
    while($exp = $row["exp".$i])
    {
        if(!$exp)
            break;
        if($i != 1)
            echo '<br>';
        echo "Level $i - $exp";
        $i++;
    }
    
    echo '</b></font></div>
            </td>

            <td width="29%">
              <div align="center">
  <font face="Verdana, Arial, Helvetica, sans-serif" size="-2" color="#330000">
              <b>';
    
    $temp = $row["drops"];
    echo "$temp";
    echo '</b></font></div>
            </td>
          </tr>';
}

mysql_free_result($result);
?>

</table>


I made my db very simple for this, especially the item drops field is just a text entry as you can see, i assume yours links to an item table.

If you want me to implement this myself, reply or PM and toss me source and I'll do it according to your db's layout.

Posted by: AllyGator May 3 2010, 04:56 PM

Dereksmart, check your forum mail.

Posted by: AllyGator May 5 2010, 08:24 PM

I copied most of the files in question to Dereksmart but before he had a chance to look at them I was talking to LordAchoo. The thing with LordAchoo is that he's a really good programmer and that's it's nearly impossible to get him to focus on anything except.....well if you know him you know. Anyway the last time he slowed down enough to work on something for NA was a year ago, then a month ago, AkiKan got him to program the carnage schedule that is now on the front page. I thought we'd have another year before we could bug him again. :heh:

Anyway after I whined enough he solved the problem in an hour.

Compare http://www.nexusatlas.com/60atlas/anchorite.php to http://www.nexusatlas.com/50atlas/magus.php and http://www.nexusatlas.com/50atlas/horse-test.php to http://www.nexusatlas.com/50atlas/horse.php. In addition to the breaks between cave levels being clearer, the data is coming directly from the databases now making updates much, much faster.

I've updated the Gogoon Island pages and I'll get to the other leveled caves pretty soon. Hopefully I can get people to give me experience from all cave levels but I doubt that ever happens. Thanks Derek!

Posted by: Interstate May 6 2010, 04:02 PM

lol.... just, lol.

Poor allygator. Way to hold the nexus together girl.



Posted by: stabme Jun 4 2010, 08:21 PM

dude, wth falaris what are you talking about. not a single person in this thread knows wth they're talking about re: html, php, templating, mysql, loops, tyvm.

pls, ffs, give me your code/project and i'll whip it to you in a much more optimized, faster, and easier way to you by this weekend. this is ridic.

how many mysql tables in nexus atlas, or rather the hunting, maps and experience tables? what do you say if i say i can auto generate all your content for you without having to make a new php page again.

Posted by: AllyGator Jun 4 2010, 10:01 PM

QUOTE (stabme @ Jun 4 2010, 08:21 PM) *
dude, wth falaris what are you talking about. not a single person in this thread knows wth they're talking about re: html, php, templating, mysql, loops, tyvm.

pls, ffs, give me your code/project and i'll whip it to you in a much more optimized, faster, and easier way to you by this weekend. this is ridic.

how many mysql tables in nexus atlas, or rather the hunting, maps and experience tables? what do you say if i say i can auto generate all your content for you without having to make a new php page again.


There are several databases but only 2 that count. One for Nexus Forums and one for everything else. The rest are test stuff. No tables for maps are in use although I've set up stuff for NPCs, rooms, areas, locations, etc. I just never found a real reason to use them. I cross reference locations to areas for the cave requirement chart and minor quest chart but that's about it. If the a map's monster graphic background is darker grey then the data is from the database - otherwise not. For example - Mythic maps don't use the database...yet. I'll get to it one day.

Posted by: Falaris Jun 5 2010, 09:52 AM

QUOTE (stabme @ Jun 4 2010, 08:21 PM) *
dude, wth falaris what are you talking about. not a single person in this thread knows wth they're talking about re: html, php, templating, mysql, loops, tyvm.

pls, ffs, give me your code/project and i'll whip it to you in a much more optimized, faster, and easier way to you by this weekend. this is ridic.

how many mysql tables in nexus atlas, or rather the hunting, maps and experience tables? what do you say if i say i can auto generate all your content for you without having to make a new php page again.


Everyone else is doing things like a programmer would, having PHP generate everything, trying to optimize the code (because this site is clearly bringing down 500k visitors monthly and has to be optimized, right???) or doing things that are obviously beyond AllyGator's level. Moreover, if anything goes wrong in the future, she wouldn't know how to fix it, so then she'll be right back to this same situation.

I was trying to show how to keep it simple, eliminate the need for loops completely, and use html templates with PHP includes instead of generating everything via PHP. It is a bit more work, it is a "dumbed down" way of doing it, but everything is very obvious and the PHP is kept to a minimum. This way, anyone who knows basic HTML can probably fix the page.

I'm not saying your way or all the other programmers' ways are wrong, in fact from a programmer's and programming perspective they are the "correct" way to do things. That way just doesn't make much sense to do when you are then giving it to the operator of the site to use when they have no idea what you are doing.

For calling basic information from a database to fill in the page on a fansite, there is absolutely no good reason to make this complicated, even for the sake of optimization.

Posted by: stabme Jun 5 2010, 11:40 AM

i write only oop php, with abstracted classes inheriting smarty and db classes for my model and view components; and i have a simple long-ass-fu switch-case acting as my controller. the html is completely abstracted and separated from the php, as are the sql queries. if anything ever needs to be changed, fix the model function. or change a simple html line in the templates. blamo

Posted by: stabme Jun 6 2010, 02:36 PM

Ally I am still open to doing this. Send me a PM

Posted by: SilentS Jun 6 2010, 04:30 PM

I think you already scared her away tongue.gif

Posted by: stabme Jun 6 2010, 05:29 PM

You might be right. But I want to do it anyway

Posted by: Interstate Jun 7 2010, 04:06 PM

This all started when a certain someone had a peek at a script I wrote years ago. You're welcome lol <3 =)


Posted by: stabme Jun 7 2010, 09:29 PM

QUOTE (Interstate @ Jun 7 2010, 05:06 PM) *
This all started when a certain someone had a peek at a script I wrote years ago. You're welcome lol <3 =)

eh? a script for what

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)