Jump to content

why wont this work


d22552000

Recommended Posts

       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 

Link to comment
https://forums.phpfreaks.com/topic/67784-why-wont-this-work/
Share on other sites

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?
Link to comment
https://forums.phpfreaks.com/topic/67784-why-wont-this-work/#findComment-340557
Share on other sites

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 -_-.

Link to comment
https://forums.phpfreaks.com/topic/67784-why-wont-this-work/#findComment-340562
Share on other sites

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 :P

Link to comment
https://forums.phpfreaks.com/topic/67784-why-wont-this-work/#findComment-340563
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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