d22552000 Posted September 3, 2007 Share Posted September 3, 2007 echo ' <html> <head> <title>LOGGED IN - Student Tabulation - Login ID '.rand().'</title> </head> <body><p> <font color="red" face="trebuchet ms" size="8"><strong>Warning</strong>: Advanced Logging Enabled</font> <br /></p><p> '; mysql_connect('localhost','root','') or die(mysql_error()); mysql_select_db("Rolla High School") or die(mysql_error()); $sql = "SELECT * FROM `teaid` WHERE `TEAID` = '".$id."'"; $res = mysql_query($sql) or die(mysql_error()); while($row = mysql_fetch_array($res, MYSQL_ASSOC)) { echo ' <form action="index.php" method="GET"> <input type="hidden" name="id" value="'.$id.'"> <input type="hidden" name="pw" value="'.$pw.'"> <input type="hidden" name="s" value="3"> <select name="clsid"> <option value="'.$row[`clsid1`].'">'.$row[`clsid1`].'</option> <option value="'.$row[`clsid2`].'">'.$row[`clsid2`].'</option> <option value="'.$row[`clsid3`].'">'.$row[`clsid3`].'</option> <option value="'.$row[`clsid4`].'">'.$row[`clsid4`].'</option> <option value="'.$row[`clsid5`].'">'.$row[`clsid5`].'</option> <option value="'.$row[`clsid6`].'">'.$row[`clsid6`].'</option> <option value="'.$row[`clsid7`].'">'.$row[`clsid7`].'</option> <option value="'.$row[`clsid8`].'">'.$row[`clsid8`].'</option> </select><input type="submit" value="submit"> </form> '; } echo ' </p> </body> </html> '; and I cant figure out why it doenst work. It should make a dropdown box for EACH list of classi's for the login ID. It outputs a dropdown box that has no values in it. I run: SELECT * FROM `teaid` WHERE `TEAID` = 'v1' in phpmyadmin and it gives me the entire row. (v1 is just a test teaid) Table (teaid) TEAID TEAPW SEMID CLSID1 CLSID2 CLSID3 CLSID4 CLSID5 CLSID6 CLSID7 CLSID8 v1 v1 1 101 102 103 104 105 106 107 108 Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted September 3, 2007 Share Posted September 3, 2007 Replace the `s with 's. (not in the query but e.g. $row[`clsid2`] should be $row['clsid2']) Quote Link to comment Share on other sites More sharing options...
trq Posted September 3, 2007 Share Posted September 3, 2007 Firstly, your creating the entire form within your loop. This is probably not what you want. Secondly, you appear to be using `backticks` around your array keys. ie; $row[`clsid1`] should be... $row['clsid1'] Quote Link to comment Share on other sites More sharing options...
d22552000 Posted September 3, 2007 Author Share Posted September 3, 2007 but then it screws my echo -,-. oh how I wish backticks were the same as quotes like in mysql. Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted September 3, 2007 Share Posted September 3, 2007 Use heredoc and put the variables in curly brackets then. Quote Link to comment Share on other sites More sharing options...
d22552000 Posted September 3, 2007 Author Share Posted September 3, 2007 when using heredoc does it sitll isten to variables... Im not sure about that. Ill try { lol nver kenw they were quotes. Quote Link to comment Share on other sites More sharing options...
trq Posted September 3, 2007 Share Posted September 3, 2007 oh how I wish backticks were the same as quotes like in mysql. They serve a very different purpose in MySql as well. backticks are for escaping reserved words, quotes are for creating string values. Quote Link to comment Share on other sites More sharing options...
d22552000 Posted September 3, 2007 Author Share Posted September 3, 2007 uh so... where do I put the {}? on the [{}] or {$row} ??? please can someone do it, I think im gonna screw it up . Quote Link to comment Share on other sites More sharing options...
Azu Posted September 3, 2007 Share Posted September 3, 2007 oh how I wish backticks were the same as quotes like in mysql. They serve a very different purpose in MySql as well. backticks are for escaping reserved words, quotes are for creating string values. In MySQL I surround all my database/table/row names with backticks.. is this bad practice? Quote Link to comment Share on other sites More sharing options...
d22552000 Posted September 3, 2007 Author Share Posted September 3, 2007 lol so do I , in fact I dont think I use a normal quote EVER in my mysql -,-! <form action="index.php" method="GET"> <input type="hidden" name="id" value="'.$id.'"> <input type="hidden" name="pw" value="'.$pw.'"> <input type="hidden" name="s" value="3"> <select name="clsid"> <option value="'.$row{CLSID1}.'">'.$row{CLSID1}.'</option> <option value="'.$row{CLSID2}.'">'.$row{CLSID2}.'</option> <option value="'.$row{CLSID3}.'">'.$row{CLSID3}.'</option> <option value="'.$row{CLSID4}.'">'.$row{CLSID4}.'</option> <option value="'.$row{CLSID5}.'">'.$row{CLSID5}.'</option> <option value="'.$row{CLSID6}.'">'.$row{CLSID6}.'</option> <option value="'.$row{CLSID7}.'">'.$row{CLSID7}.'</option> <option value="'.$row{CLSID8}.'">'.$row{CLSID8}.'</option> </select><input type="submit" value="submit"> </form> Seems to wkr now, thank you and yes, I do want ti to be one form per row, cause each teacher per district per callid per... ugh. its easier just to say it was there on purpose. I am writing a whole districts absense tracking program . Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted September 3, 2007 Share Posted September 3, 2007 uh so... where do I put the {}? on the [{}] or {$row} ??? please can someone do it, I think im gonna screw it up . Around the entire variable. <?php $rand = rand(); echo <<<EOF <html> <head> <title>LOGGED IN - Student Tabulation - Login ID {$rand}</title> </head> <body><p> <font color="red" face="trebuchet ms" size="8"><strong>Warning</strong>: Advanced Logging Enabled</font> <br /></p><p> EOF; mysql_connect('localhost','root','') or die(mysql_error()); mysql_select_db("Rolla High School") or die(mysql_error()); $sql = "SELECT * FROM 'teaid' WHERE `TEAID` = '{$id}'"; $res = mysql_query($sql) or die(mysql_error()); while($row = mysql_fetch_array($res, MYSQL_ASSOC)) { echo <<<EOF <form action="index.php" method="GET"> <input type="hidden" name="id" value="{$id}"> <input type="hidden" name="pw" value="{$pw}"> <input type="hidden" name="s" value="3"> <select name="clsid"> <option value="{$row['clsid1']}">{$row['clsid1']}</option> <option value="{$row['clsid2']}">{$row['clsid2']}</option> <option value="{$row['clsid3']}">{$row['clsid3']}</option> <option value="{$row['clsid4']}">{$row['clsid4']}</option> <option value="{$row['clsid5']}">{$row['clsid5']}</option> <option value="{$row['clsid6']}">{$row['clsid6']}</option> <option value="{$row['clsid7']}">{$row['clsid7']}</option> <option value="{$row['clsid8']}">{$row['clsid8']}</option> </select><input type="submit" value="submit"> </form> EOF; } echo <<<EOF </p> </body> </html> EOF; ?> lol so do I , in fact I dont think I use a normal quote EVER in my mysql -,-! You did in the code you posted Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.