3
Contributors
9
Replies
10
Views
9 Years
Discussion Span
Last Post by somedude3488
0

use this:

$sql = "SELECT * FROM `contacts` WHERE `first1 = '" . $_POST['name'] . "' AND `mobile` = '" . $_POST['mobile'] . "'";
$query = mysql_query($sql);
while ($row = mysql_fetch_assoc($query)) {
  echo '<a href="' . $_SERVER['PHP_SELF'] . '?id=' . $row['id'] . '">' . $row['first'] . ' ' . $row['last'] . '</a>';
}

then use $_GET to 'get' the id from the url and select the info from the database related to that id

0

I will explain you the logic what has to be done with an example and you can implement that in your script.

$results = mysql_query("SELECT * FROM f_category ORDER BY c_order DESC", $connection);
    $numrows = @mysql_num_rows($results);
    $x = 0;
    while ($x < $numrows) {
        $cid = stripslashes(mysql_result($results, $x, "c_id"));
        $cname = stripslashes(mysql_result($results, $x, "c_name"));
        echo "Property Name = <a href=deails.php?cid=$cid>$cname</a>";
        $x++;
        }

Now what this will do is print a list of property names and with their cid's as the hyperlink.
and you can use GET method in details.php to retrieve cid and print the results :)

0

it comes up with this error

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/proper/public_html/welcome.php on line 19

0

it comes up with line 19 error
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/proper/public_html/welcome.php on line 19

0

did you connect to the database first?

i did connect but it didnt work

i tried this code and it worked. Do u know how i could add image and hyperlink the image aswell

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?
$username="proper_asik112";
$password="ashik112";
$database="proper_contacts";

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$result = mysql_query('SELECT * FROM contacts
WHERE first=\''. $_POST.'\' And mobile=\''. $_POST.'\'');;


while($row=mysql_fetch_array($result))
{
echo '<a href="' . $_SERVER . '?id=' . $row . '">' . $row . ' ' . $row . '</a>';
}

?>
</body>
</html>

0

i am typing up some code for you now, ill post asap.

thanks

0

use all of this code, not pieces of it, or you will get errors.

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php

$host = 'localhost';
$user = 'proper_asik112';
$pass = 'ashik112';
$db   = 'proper_contacts';

$con = mysql_connect($host,$user,$pass) or die('Error: Could not connect');
mysql_select_db($db) or die('Error: Could not select database');

$sql   = "SELECT * FROM `contacts` WHERE `first` = '" . mysql_real_escape_string($_POST['name']) . "' AND `mobile` = '" . mysql_real_escape_string($_POST['mobile']) . "'";
$query = mysql_query($sql, $con);
while ($row = mysql_fetch_assoc($query)) {
	echo '<a href="pagename.php?id=' . $row['id'] . '">' . $row['first'] . ' ' . $row['last'] . '</a><br />';
}

?>
</body>
</table>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.