Jump to content

doogles

Members
  • Posts

    13
  • Joined

  • Last visited

    Never

Posts posted by doogles

  1. it seems to me you have two else clauses in a row :)

     

    else
                          {
    
    		echo'<table class="verifytb" style="width:500px"><tr class="tbhd"><td>Emperor Election</td></tr>';
    		echo'<tr><td class="admincellcen1">You can vote for a capable kingdom <b>in your empire</b> to represent as the Emperor for '.$newarray[empire].'</td></tr>';			
    		// calculate how many ppl vote for this user
    		$check_mine=mysql_query("SELECT COUNT(id) FROM users WHERE Svote= '$newarray[Knumber]'" ,$link ) or die(mysql_error());
    		$vote_for_me=mysql_fetch_array($check_mine);
    		echo'<tr><td class="admincellleft1">--<b class="highlight">'.$vote_for_me[0].'</b> Kingdoms have voted you for the Emperor.<br>';
    
    		// Display current vote for creator
    			if ($newarray['Svote']==0) echo'<span class="txtleft">-You have not vote for the Emperor yet.</span><br>';
    			else {
    

     

    I just saw your error :)

     

    if ($newarray['Svote']==0) echo'<span class="txtleft">-You have not vote for the Emperor yet.</span><br>';
    			else {

     

    hehe... You're missing the curly bracets on that if clause. And you have a typo! GASP

     

    if ($newarray['Svote']==0) {echo'<span class="txtleft">-You have not voted for the Emperor yet.</span><br>';}
    			else {

     

     

     

  2. you can't have two else clauses in a row

     

    it has to be

     

    if ($x=1) {do stuff}

    elseif ($x=2) {do something else}

    THEN

    else {do other stuff}

     

    You can have more than one elseif, though.

    If your if clauses aren't related to the same thing, just make them all if clauses

     

    if ($x=1) {do that}

    if ($y=15) {do this}

    if ($z=45) {do something else}

  3. Pretty simple question. I think this is more related to PHP than mysql so I posted it here. I just want to select values from mysql and be able to save them to my own PHP variables.

     

    The catch is that I don't know what the values will be because they are based on user input, so I can't use a WHERE clause. Any help would be great.

     

    The table's name is the only thing known about it. Also, I know there are 3 columns: 'title', 'points_earned', and 'points_possible' and that the table is not empty. All of that is verified. I just need to save the values that are in it to its respective values.

     

    Any help is appreciated.

     

    I was thinking a few if clauses would work...

    if(mysql_num_rows(mysql_query(SELECT * FROM $class)) = 1) {
    //I don't know what to do to save the values to php variables
    }
    

     

    maybe I need an auto_increment integer to work with?

     

     

     

  4. you could go into your MySQL DOS box and simply type in your password then enter the following:

     

    use [database name];

     

    then do what you wish.

     

    Or if you working with PHP, do something like:

     

    $conn=mysql_connect("localhost", "[username]", "[password]");
    mysql_select_db("[database name]", $conn);

  5. MySQL version 5.0.22

     

    I want to take a table in mysql and virtually print it in the web browser.

     

    BUT I also want to add columns that manipulate the values already in the MySQL table.

     

    The user (me) enters their desired table name to be displayed in a small form...

     

    <html><head><title>View gradelogs</title></head><body>
    <h1>View grades</h1>
    <?PHP
    $class=$_POST['class'];
    if ($class =="") {
    echo "<form method=post>
    <p>Type the name of the class you want to view:</p><input type=text name=class><input type=submit value=view></form>"; } else { 
    //This is where I want to fetch the MySQL table and display it.}

     

    If it helps, here is the table that is created and the script that inserts it (on another file and another form) :

     

    $createtable="CREATE table $class (
    title varchar (25),
    points_earned varchar (4),
    points_possible varchar (4))";
    mysql_query($createtable);
    
    if ($grade1 !=="") {$ins="insert into $class values('$grade1', '$g1e', '$g1t')"; mysql_query($ins) or die(mysql_error());
    //and etc. for $grade2....$grade3..}
    

     

    It's not really a problem. I just want to know how to do it.

     

    It'd be easy if it was just one row, but its a whole table. Also, if you could tell me how to save each value in the table to a specific variable, that'd be easier.

     

    I can make the table, its just getting the table's values from mysql into a workable variable. Thanks.

     

     

     

     

     

     

     

     

     

  6. It was hard to explain with just the title, so I figured I'll explain what I mean here:

     

    Say I have various variables with the same name and different endings, like $test1, $test2, $test3, $test4, etc...

     

    Would it be possible to create a loop that will do something to each of those variables instead of me typing it for each and every one?

     

    Something like:

     

    for($x=1; $x <=4; $x++) {echo $test$x;} so it would print each test variable, 1-4? Obviously combining the two variables is impossible. Do I need to encase the $x in something like $test".$x." ?

     

    Thanks !

     

    ;D

  7. MySQL version 5.0.22

     

    My problem is when I try to insert values based on user input into a table also based on user input.

     

    The table is created fine. I verified it. It's the values I try to put it the table that don't go.

     

    Here's the small script that adds the table:

     

    $createtable="CREATE table $class (

    title varchar (25),

    points_earned varchar (4),

    points_possible varchar (4))";

    mysql_query($createtable);

     

    Here's the script that adds the values:

     

    if ($grade1 !=="") {$ins="insert into $class values($grade1, $g1e, $g1t)"; mysql_query($ins) or die(mysql_error());}

     

    The error mysql gives depends on the user's value for $grade1. I've verified also that all the values I try to insert exsist by having the script print them to the browser. If $grade1 is 'test' then I get:

     

    "Unknown column 'test' in 'fieldlist'"

     

    Thanks!

     

     

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