Lambneck Posted April 15, 2008 Share Posted April 15, 2008 I have a link echoed in the code below that i'm trying to get to open a page displaying several columns from a mysql database table. anyone know an easy way to do this? I tried the following with no luck: $result = mysql_query("SELECT col_4 FROM {$table} ORDER BY submission_date DESC"); if (!$result) { die("Query to show fields from table failed:".mysql_error()); } while($row = mysql_fetch_array($result)) { echo '<a href="ResumeDisplay.php?id='.$row['col_2, col_3, col_5].'">'.$row['col_4'].'</a>'; echo "<br />"; } mysql_free_result($result); im not sure if this syntax is correct but i what im trying to do is display the data in col_2, col_3, col_5 when the link is clicked on. Link to comment https://forums.phpfreaks.com/topic/101152-solved-get-column/ Share on other sites More sharing options...
Northern Flame Posted April 15, 2008 Share Posted April 15, 2008 try $result = mysql_query("SELECT col_4 FROM {$table} ORDER BY submission_date DESC"); if (!$result) { die("Query to show fields from table failed:".mysql_error()); } while($row = mysql_fetch_array($result)) { echo '<a href="ResumeDisplay.php?id='.$row['col_2'] . $row['col_3'] . $row['col_5'].'">'.$row['col_4'].'</a>'; echo "<br />"; } mysql_free_result($result); Link to comment https://forums.phpfreaks.com/topic/101152-solved-get-column/#findComment-517364 Share on other sites More sharing options...
Lambneck Posted April 15, 2008 Author Share Posted April 15, 2008 thanks NF. I forgot to post my display.php page code: $id = (int) $_GET['col_2, col_3, col_5']; $sql = "SELECT * FROM {$table}; $result = mysql_query($sql) or die("Error ". mysql_error(). " with query ". $sql); //print out information }else{ echo 'That record ID does not exist!'; } ?> I'm getting record ID does not exist, but it does so something must be missing from my query... do i have to specify WHERE to select from? how do i get the display.php to recognize the action of the first pages code? ??? Link to comment https://forums.phpfreaks.com/topic/101152-solved-get-column/#findComment-517394 Share on other sites More sharing options...
Northern Flame Posted April 15, 2008 Share Posted April 15, 2008 for the sql, try: $two = mysql_real_escape_string($_GET['col_2']); $three = mysql_real_escape_string($_GET['col_3']); $five = mysql_real_escape_string($_GET['col_5']); $sql = "SELECT * FROM $table WHERE col_2 = '$two' && col_3 = '$three' && col_5 = '$five'"; // make sure column names are correct! then just put that into $result.... Link to comment https://forums.phpfreaks.com/topic/101152-solved-get-column/#findComment-517398 Share on other sites More sharing options...
Lambneck Posted April 15, 2008 Author Share Posted April 15, 2008 thanks again NF! Link to comment https://forums.phpfreaks.com/topic/101152-solved-get-column/#findComment-517619 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.