Lambneck Posted April 10, 2008 Share Posted April 10, 2008 Hello, I have here, echoed as a link, the subject of my submitted forms. What I am trying to do is make it so each individual subject from a form submission becomes a link to a page displaying the rest of its form entry (ie. name, email, message). I figure to do this i would have to call on the Submission ID numbers. however, I have no clue as to how to go about doing so. ??? any suggestions? $result = mysql_query("SELECT col_4 FROM {$table}"); if (!$result) { die("Query to show fields from table failed:".mysql_error()); } while($row = mysql_fetch_array($result)) { echo "<a href=\"Display.php\">$row[col_4]</a>"; echo "<br />"; } mysql_free_result($result); ?> Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted April 10, 2008 Share Posted April 10, 2008 Indeed. You need to be passing something that will identify the row of the database uniquely in the URL. Hopefully this will be in the form of an ID number. You'd then do something like: $result = mysql_query("SELECT col_4 FROM {$table}"); if (!$result) { die("Query to show fields from table failed:".mysql_error()); } while($row = mysql_fetch_array($result)) { echo '<a href="Display.php?id='.$row['id'].'">'.$row['col_4'].'</a>'; echo "<br />"; } mysql_free_result($result); ?> You'd then have Display.php set up something like: <?php $id = (int) $_GET['id']; $sql = "SELECT * FROM tbl WHERE id=$id"; $result = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($result) == 1){ $row = mysql_fetch_assoc($sql); //print out information }else{ echo 'That record ID does not exist!'; } ?> Quote Link to comment Share on other sites More sharing options...
Lambneck Posted April 11, 2008 Author Share Posted April 11, 2008 im getting the following message: Unknown column 'id' in 'where clause' :'( how/where do i identify the submission id? Quote Link to comment Share on other sites More sharing options...
digitalgod Posted April 11, 2008 Share Posted April 11, 2008 just replace $sql = "SELECT * FROM tbl WHERE id=$id"; with whatever column you're using for id in your db, as well as the table name Quote Link to comment Share on other sites More sharing options...
Lambneck Posted April 11, 2008 Author Share Posted April 11, 2008 sorry, i just started learning php, could you show me an example of what u mean? the column is "Submission ID" the table is "Resumes" appreciate it. Quote Link to comment Share on other sites More sharing options...
Lambneck Posted April 12, 2008 Author Share Posted April 12, 2008 Where to specify the column name (submission id)? <?php $id = (int) $_GET['id']; $sql = "SELECT * FROM tbl WHERE id=$id"; $result = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($result) == 1){ $row = mysql_fetch_assoc($sql); //print out information }else{ echo 'That record ID does not exist!'; } ?> i tried the following with no luck... $submission id= (int) $_GET['id']; $sql = "SELECT * FROM tbl WHERE submission id=$ submission id"; Quote Link to comment Share on other sites More sharing options...
mrdamien Posted April 13, 2008 Share Posted April 13, 2008 i tried the following with no luck... $submission id= (int) $_GET['id']; $sql = "SELECT * FROM tbl WHERE submission id=$ submission id"; You shouldn't use spaces in your field names. And you can't use spaces in variable names. To fix that, use $submission_id= (int) $_GET['id']; $sql = "SELECT * FROM tbl WHERE `submission id` = $submission_id"; Quote Link to comment Share on other sites More sharing options...
Lambneck Posted April 13, 2008 Author Share Posted April 13, 2008 Thank you! 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.