Forums

Give help. Get help.

  • # October 21, 2012 at 2:05 am

    Oh yay for being able to make a super mini database system from scratch.

    Here’s the lowdown: You are able to submit scripts(like play scripts) through a form to a MySQL database. After being approved by an administrator, they show up in a table on the viewing page, and you can click on the script you wish to read in a viewscript.php?id=32 form.

    It is modeled after [my friend’s website](http://www.everythingdojo.com/themedb.php “Theme DB”), specifically the . This is a site in which he stores CSS codes for blogs [here](http://www.artofproblemsolving.com/Forum/apsjour.php “AoPS Blogs”). (Uh yeah you have probably figured out by now that I’m in middle school i.e. not an adult like yall but I love PHP :D)

    Anyway you cannot see the approving thing (not being a registered user and not being an styles moderator) and you don’t need to understand the purpose of the sites but if you can look around the first site linked to, specifically the View section, so you get a feel for where I’m stuck at.

    Now for my problem: If you can see how the links in the view mode have a get variable attached to it something like “page.php?id=12”.
    So I have a table holding the scripts with columns id, title, author, script, approved.

    < ?php
    $tablesql = “SELECT title, author FROM accscriptdb WHERE approved=0”;
    $result1 = mysql_query($tablesql);
    $idsql = “SELECT id FROM accscriptdb WHERE approved=0”;
    $result2 = mysql_query($idsql);
    if (!$result1 || !$result2) {
    exit(“QUERY ERROR: ” . mysql_error());
    } else {
    $tableData = ”;
    while($row = mysql_fetch_assoc($result1)) {
    $currRow = ”;
    foreach($row as $key => $value) {
    $currRow .= “

    $value

    “;
    }
    $tableData .= “

    $currRow

    n”;
    }
    echo(“

    //oh gosh it’s filtering out the HTML, it’s just a valid table, this is not the problem

    $tableData

    Script Name Author

    “);
    } ?>

    Right now, my second query is not being used, but I am spitting out a table with the title and author now. That works fine…now I am trying to add a link (the get variable kind) to each one in the foreach loop. I am thinking of using an array but I am not very good at fetching selected data in the sql table and using it effectively. I’m quite fuzzy on how I might do this, help?

    Thanks for reading [my quite lengthy] question,
    Red

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

icon-anchoricon-closeicon-emailicon-linkicon-logo-staricon-menuicon-nav-guideicon-searchicon-staricon-tag