Jump to content

[SOLVED] get column


Lambneck

Recommended Posts

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

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

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

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

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.