gevans Posted December 6, 2008 Share Posted December 6, 2008 That will check if id is checked, and if it is only show that one title Link to comment https://forums.phpfreaks.com/topic/135797-solved-dont-display-link-if-already-clicked/page/3/#findComment-707888 Share on other sites More sharing options...
jnerotrix Posted December 6, 2008 Author Share Posted December 6, 2008 ok one last piece to edit the index.php where it displays available surveys =================================== Heres the code We need to make it so if it is in the complete_surveys then dont show that survey <td><font size="6"> Surveys Available </font></td> <td> <?php mysql_connect("localhost", "sex1800_admin", "12921993") or die(mysql_error()); //add you password mysql_select_db("sex1800_loginbux") or die(mysql_error()); $query = "SELECT * FROM survey"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo "<a href=\"survey.php?id={$row['id']}\">{$row['title']}</a><br>\n"; } ?> </td></tr> </table> Link to comment https://forums.phpfreaks.com/topic/135797-solved-dont-display-link-if-already-clicked/page/3/#findComment-707897 Share on other sites More sharing options...
gevans Posted December 6, 2008 Share Posted December 6, 2008 First of all we need to do some work on survey.php to run an sql query You need to say insert into the second table survey id and user id let me know how u get on! Link to comment https://forums.phpfreaks.com/topic/135797-solved-dont-display-link-if-already-clicked/page/3/#findComment-707905 Share on other sites More sharing options...
jnerotrix Posted December 6, 2008 Author Share Posted December 6, 2008 Heres The Code I have to Do This mysql_connect("localhost", "sex1800_admin", "12921993") or die(mysql_error()); mysql_select_db("sex1800_loginbux") or die(mysql_error()); $member = mysql_real_escape_string($_SESSION['userid']); $survey = mysql_real_escape_string($_GET['id']); mysql_query("INSERT INTO completed_surveys (member_id, survey_id) VALUES('$member', '$survey') ") or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/135797-solved-dont-display-link-if-already-clicked/page/3/#findComment-707911 Share on other sites More sharing options...
jnerotrix Posted December 6, 2008 Author Share Posted December 6, 2008 All we need to do is edit this code to only show surveys that havent been completed <td><font size="6"> Surveys Available </font></td> <td> <?php mysql_connect("localhost", "sex1800_admin", "12921993") or die(mysql_error()); //add you password mysql_select_db("sex1800_loginbux") or die(mysql_error()); $query = "SELECT * FROM survey"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo "<a href=\"survey.php?id={$row['id']}\">{$row['title']}</a><br>\n"; } ?> </td></tr> </table> Link to comment https://forums.phpfreaks.com/topic/135797-solved-dont-display-link-if-already-clicked/page/3/#findComment-707928 Share on other sites More sharing options...
premiso Posted December 6, 2008 Share Posted December 6, 2008 How do you know that a survey has not been completed? Answer that then add that identifier to the survey query in a WHERE clause and you got your answer. Link to comment https://forums.phpfreaks.com/topic/135797-solved-dont-display-link-if-already-clicked/page/3/#findComment-707931 Share on other sites More sharing options...
jnerotrix Posted December 6, 2008 Author Share Posted December 6, 2008 Thats alot of confusing stuff you just I know its completed if its in the member id and survey id is in completed_surveys table but i dont know how to make it so if its in the table to tell the survey to be hidden Link to comment https://forums.phpfreaks.com/topic/135797-solved-dont-display-link-if-already-clicked/page/3/#findComment-707934 Share on other sites More sharing options...
gevans Posted December 6, 2008 Share Posted December 6, 2008 change this; </tr> <?php mysql_connect("localhost", "sex1800_admin", "****") or die(mysql_error()); //add you password mysql_select_db("sex1800_loginbux") or die(mysql_error()); $query = "SELECT * FROM surveys"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo "<tr><td><a href="survey.php?id={$row['id']}">{$row['title']}</a></td></tr> "; } to this; </tr> <?php mysql_connect("localhost", "sex1800_admin", "****") or die(mysql_error()); //add you password mysql_select_db("sex1800_loginbux") or die(mysql_error()); $query = "SELECT * FROM surveys JOIN completed_surveys ON surveys.id!=completed_surveys.survey_id AND memberid={$_SESSION['userid']}"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo "<tr><td><a href="survey.php?id={$row['id']}">{$row['title']}</a></td></tr> "; } Link to comment https://forums.phpfreaks.com/topic/135797-solved-dont-display-link-if-already-clicked/page/3/#findComment-707935 Share on other sites More sharing options...
jnerotrix Posted December 6, 2008 Author Share Posted December 6, 2008 Now i get this Error Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home3/sex1800/public_html/epicbux/index.php on line 95 Heres lines 85 - 100 <tr> <td><font size="6"> Surveys Available </font></td> <td> <?php mysql_connect("localhost", "sex1800_admin", "12921993") or die(mysql_error()); //add you password mysql_select_db("sex1800_loginbux") or die(mysql_error()); $query = "SELECT * FROM surveys JOIN completed_surveys ON surveys.id!=completed_surveys.survey_id AND memberid={$_SESSION['userid']}"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo "<tr><td><a href="survey.php?id={$row['id']}">{$row['title']}</a></td></tr>"; } ?> </td></tr> </table> Link to comment https://forums.phpfreaks.com/topic/135797-solved-dont-display-link-if-already-clicked/page/3/#findComment-707943 Share on other sites More sharing options...
premiso Posted December 6, 2008 Share Posted December 6, 2008 echo "<tr><td><a href="survey.php?id={$row['id']}">{$row['title']}</a></td></tr>"; should be echo "<tr><td><a href=\"survey.php?id={$row['id']}\">{$row['title']}</a></td></tr>"; You have to escape " inside of ". Link to comment https://forums.phpfreaks.com/topic/135797-solved-dont-display-link-if-already-clicked/page/3/#findComment-707948 Share on other sites More sharing options...
gevans Posted December 6, 2008 Share Posted December 6, 2008 <tr> <td><font size="6"> Surveys Available </font></td> <td> <?php mysql_connect("localhost", "sex1800_admin", "****") or die(mysql_error()); //add you password mysql_select_db("sex1800_loginbux") or die(mysql_error()); $query = "SELECT * FROM surveys JOIN completed_surveys ON surveys.id!=completed_surveys.survey_id AND memberid={$_SESSION['userid']}"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo "<tr><td><a href="survey.php?id={$row['id']}">{$row['title']}</a></td></tr>"; } ?> </td></tr> </table> Link to comment https://forums.phpfreaks.com/topic/135797-solved-dont-display-link-if-already-clicked/page/3/#findComment-707949 Share on other sites More sharing options...
jnerotrix Posted December 6, 2008 Author Share Posted December 6, 2008 now it displays the page but where it should display the surveys it displays Unknown column 'df1063585e41cc161b358347877f900c' in 'on clause' Heres the code though i fixed it to match my tables <?php mysql_connect("localhost", "sex1800_admin", "12921993") or die(mysql_error()); //add you password mysql_select_db("sex1800_loginbux") or die(mysql_error()); $query = "SELECT * FROM survey JOIN completed_surveys ON survey.id!=completed_surveys.survey_id AND member_id={$_SESSION['userid']}"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo "<tr><td><a href=\"survey.php?id={$row['id']}\">{$row['title']}</a></td></tr>"; } ?> Link to comment https://forums.phpfreaks.com/topic/135797-solved-dont-display-link-if-already-clicked/page/3/#findComment-707955 Share on other sites More sharing options...
gevans Posted December 6, 2008 Share Posted December 6, 2008 did you get the same error after doing that? Link to comment https://forums.phpfreaks.com/topic/135797-solved-dont-display-link-if-already-clicked/page/3/#findComment-707958 Share on other sites More sharing options...
jnerotrix Posted December 6, 2008 Author Share Posted December 6, 2008 yea Tables: survey *id *title *adlink completed_surveys *member_id *survey_id Link to comment https://forums.phpfreaks.com/topic/135797-solved-dont-display-link-if-already-clicked/page/3/#findComment-707963 Share on other sites More sharing options...
gevans Posted December 6, 2008 Share Posted December 6, 2008 put this in for an error check; <?php mysql_connect("localhost", "sex1800_admin", "12921993") or die(mysql_error()); //add you password mysql_select_db("sex1800_loginbux") or die(mysql_error()); $query = "SELECT * FROM survey JOIN completed_surveys ON survey.id!=completed_surveys.survey_id AND member_id={$_SESSION['userid']}"; echo $query; die(); $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo "<tr><td><a href=\"survey.php?id={$row['id']}\">{$row['title']}</a></td></tr>"; } ?> Link to comment https://forums.phpfreaks.com/topic/135797-solved-dont-display-link-if-already-clicked/page/3/#findComment-707966 Share on other sites More sharing options...
jnerotrix Posted December 6, 2008 Author Share Posted December 6, 2008 it says SELECT * FROM survey JOIN completed_surveys ON survey.id!=completed_surveys.survey_id AND member_id=df1063585e41cc161b358347877f900c <-- this is the problem Link to comment https://forums.phpfreaks.com/topic/135797-solved-dont-display-link-if-already-clicked/page/3/#findComment-707973 Share on other sites More sharing options...
gevans Posted December 6, 2008 Share Posted December 6, 2008 Can you look into the completed_surveys table and see what data you currently have in there? Link to comment https://forums.phpfreaks.com/topic/135797-solved-dont-display-link-if-already-clicked/page/3/#findComment-707978 Share on other sites More sharing options...
jnerotrix Posted December 6, 2008 Author Share Posted December 6, 2008 member_id - survey_id 0 - 1 0 - 2 0 - 1 Link to comment https://forums.phpfreaks.com/topic/135797-solved-dont-display-link-if-already-clicked/page/3/#findComment-707980 Share on other sites More sharing options...
gevans Posted December 6, 2008 Share Posted December 6, 2008 ok, having a little error didn't realise that the member_id was hashed. in the table completed_surveys change member_id from INT to VARCHAR 32 Link to comment https://forums.phpfreaks.com/topic/135797-solved-dont-display-link-if-already-clicked/page/3/#findComment-707983 Share on other sites More sharing options...
jnerotrix Posted December 6, 2008 Author Share Posted December 6, 2008 what should i put for the mysql code instead of this <?php mysql_connect("localhost", "sex1800_admin", "12921993") or die(mysql_error()); //add you password mysql_select_db("sex1800_loginbux") or die(mysql_error()); $query = "SELECT * FROM survey JOIN completed_surveys ON survey.id!=completed_surveys.survey_id AND member_id={$_SESSION['userid']}"; echo $query; die(); $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo "<tr><td><a href=\"survey.php?id={$row['id']}\">{$row['title']}</a></td></tr>"; } ?> Link to comment https://forums.phpfreaks.com/topic/135797-solved-dont-display-link-if-already-clicked/page/3/#findComment-707986 Share on other sites More sharing options...
gevans Posted December 6, 2008 Share Posted December 6, 2008 ok, having a little error didn't realise that the member_id was hashed. in the table completed_surveys change member_id from INT to VARCHAR 32 did you do that?? If you did delete all the entries in the table and it should work fine Link to comment https://forums.phpfreaks.com/topic/135797-solved-dont-display-link-if-already-clicked/page/3/#findComment-707988 Share on other sites More sharing options...
jnerotrix Posted December 6, 2008 Author Share Posted December 6, 2008 yes i did and deleted all that data in it so and i open the index page and still get this SELECT * FROM survey JOIN completed_surveys ON survey.id!=completed_surveys.survey_id AND member_id=324a6953910123430fa8e36e055d3c41 Link to comment https://forums.phpfreaks.com/topic/135797-solved-dont-display-link-if-already-clicked/page/3/#findComment-707991 Share on other sites More sharing options...
gevans Posted December 6, 2008 Share Posted December 6, 2008 ok, change this <?php mysql_connect("localhost", "sex1800_admin", "12921993") or die(mysql_error()); //add you password mysql_select_db("sex1800_loginbux") or die(mysql_error()); $query = "SELECT * FROM survey JOIN completed_surveys ON survey.id!=completed_surveys.survey_id AND member_id={$_SESSION['userid']}"; echo $query; die(); $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo "<tr><td><a href=\"survey.php?id={$row['id']}\">{$row['title']}</a></td></tr>"; } ?> back to this <?php mysql_connect("localhost", "sex1800_admin", "12921993") or die(mysql_error()); //add you password mysql_select_db("sex1800_loginbux") or die(mysql_error()); $query = "SELECT * FROM survey JOIN completed_surveys ON survey.id!=completed_surveys.survey_id AND member_id={$_SESSION['userid']}"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo "<tr><td><a href=\"survey.php?id={$row['id']}\">{$row['title']}</a></td></tr>"; } ?> Link to comment https://forums.phpfreaks.com/topic/135797-solved-dont-display-link-if-already-clicked/page/3/#findComment-707995 Share on other sites More sharing options...
jnerotrix Posted December 6, 2008 Author Share Posted December 6, 2008 Now it says Unknown column '8190ef16bc01b56546027a349806ad2a' in 'on clause' Link to comment https://forums.phpfreaks.com/topic/135797-solved-dont-display-link-if-already-clicked/page/3/#findComment-707996 Share on other sites More sharing options...
gevans Posted December 6, 2008 Share Posted December 6, 2008 try this; <?php mysql_connect("localhost", "sex1800_admin", "12921993") or die(mysql_error()); //add you password mysql_select_db("sex1800_loginbux") or die(mysql_error()); $query = "SELECT * FROM survey JOIN completed_surveys ON survey.id!=completed_surveys.survey_id WHERE member_id={$_SESSION['userid']}"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo "<tr><td><a href=\"survey.php?id={$row['id']}\">{$row['title']}</a></td></tr>"; } ?> Link to comment https://forums.phpfreaks.com/topic/135797-solved-dont-display-link-if-already-clicked/page/3/#findComment-707998 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.