Teefa Posted October 24, 2013 Share Posted October 24, 2013 hi all , i want to ask a silly question , im not an experienced web developer this is my code <?php include "/connect_to_db.php"; $options=""; $options2=""; $options3=""; $options4=""; $dt=array(); global $date; global $hour; $sql=mysql_query("select Date from Student_Name order by Date "); //where Hour=$hour and Date='$date' while($rows=mysql_fetch_array($sql)): $date1=$rows['Date']; $options.="<OPTION VALUE=\"$date1\">".$date1.'</option>'; endwhile; ?> <form method="post"> Date <SELECT name="date1"> <? if($_POST['date1']) { $date=$_POST["date1"]; } else { $date='Date';} ?> <OPTION VALUE=<?=$date?>><?echo $date ;?> <?=$options?> <? $date=$_POST["date1"]; ?> </SELECT> <? $sql=mysql_query("select Hour from Student_Names order by Hour"); while($rows=mysql_fetch_array($sql)): $hour1=$rows['Hour']; $options2.="<OPTION VALUE=\"$hour1\">".$hour1.'</option>'; endwhile; ?> Hour <SELECT name="hour1"> <? if($_POST['hour1']) { $hour=$_POST["hour1"]; } else { $hour='Hour';} ?> <OPTION VALUE=<?=$hour?>><? echo $hour ;?> <?=$options2?> <? $hour=$_POST["hour1"]; ?> </SELECT> Quote Link to comment Share on other sites More sharing options...
requinix Posted October 24, 2013 Share Posted October 24, 2013 And the question is...? Quote Link to comment Share on other sites More sharing options...
Teefa Posted October 24, 2013 Author Share Posted October 24, 2013 there is no data displayed for the variable date one , it was working on the last version but now nothing appear in the drop menu ( empty drop menu) at the top when we echo date one it got an array but nothing in drop menu please help Quote Link to comment Share on other sites More sharing options...
Barand Posted October 24, 2013 Share Posted October 24, 2013 What version of PHP are you using? Do you have "short tags" enabled? Quote Link to comment Share on other sites More sharing options...
Teefa Posted October 24, 2013 Author Share Posted October 24, 2013 the Short table is disabled and php 5.3.8 but the first one was 5.4.8 , kindly advice ?? Quote Link to comment Share on other sites More sharing options...
Barand Posted October 24, 2013 Share Posted October 24, 2013 If short tags are disabled then <? must be <?php <?= must be <?php echo (<?= is allowed in 5.4 even with short tags disabled) Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted October 24, 2013 Share Posted October 24, 2013 if just one of your queries is not working, it's because you are using two different table names. one is Student_Name, the other is Student_Names. you need to ALWAYS test if a query worked or failed before you try to use the data that query was expected to return. if your code had some error checking logic in it, you would have already known that the table name in one of the queries is (probably) not correct. your code is all over the place with things that, in the context of the posted code, don't work or are not needed. you have variables defined, but not used; variables used but not defined; global statements that don't do anything unless inside of a function and even there they should not be used; your table name, which ever one is correct, should hold student name information. why do you have date and hour fields in that table? Quote Link to comment Share on other sites More sharing options...
Teefa Posted October 25, 2013 Author Share Posted October 25, 2013 thanks alot , Multi thanks Barand Quote Link to comment Share on other sites More sharing options...
Teefa Posted October 25, 2013 Author Share Posted October 25, 2013 if just one of your queries is not working, it's because you are using two different table names. one is Student_Name, the other is Student_Names. you need to ALWAYS test if a query worked or failed before you try to use the data that query was expected to return. if your code had some error checking logic in it, you would have already known that the table name in one of the queries is (probably) not correct. your code is all over the place with things that, in the context of the posted code, don't work or are not needed. you have variables defined, but not used; variables used but not defined; global statements that don't do anything unless inside of a function and even there they should not be used; your table name, which ever one is correct, should hold student name information. why do you have date and hour fields in that table? thnx alot , but ive changed my original table names writing this post , but sure ive checked it in my original script Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted October 25, 2013 Share Posted October 25, 2013 So this is solved now? or you still have a problem? 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.