Beginning PHPBeginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Beginning PHP section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
Hello again all and thanks for taking the time to read this!
My problem is as follows:
I have a search form which pulls data according to country, state and industry and displays the result with the company name as a link to its profile(member_profile.php). The name of the company shows up and the link works but the member_profile details I cant seem to pull across from the link clicked. (make sense at all?)
The code that shows the list of companies is like this:
Code:
<?php
session_start();
include 'dbc.php';
//select which database you want to edit
mysql_select_db("users");
$search=$_POST["search"];
//get the mysql and store them in $result
//change whatevertable to the mysql table you're using
//change whatevercolumn to the column in the table you want to search
$result = mysql_query("SELECT * FROM users WHERE country LIKE '%$country%' AND state LIKE '%$state%' AND industry LIKE '%$industry%' ORDER BY full_name DESC");
//grab all the content
while($r=mysql_fetch_array($result))
{
//the format is $variable = $r["nameofmysqlcolumn"];
//modify these to match your mysql table columns
$full_name=$r["full_name"];
$id=$r["id"];
echo '<a href="member_profile.php" target="_blank" id=' . $r['id'] . '">'.$r['full_name'].'</a><br />';
}
?>
As you can see it shows retrieves the id and full name and displays the full name as the link to member_profile.php.
The member profile page has the following code:
Code:
<?php
session_start();
require 'dbc.php';
{
$id = $_GET['id'];
$user = mysql_query("SELECT * FROM user WHERE id = '$id'");
$user=mysql_fetch_assoc($user);
}
echo "<h1>User Info</h1>";
echo "<b>Username:".$user['full_name']."<br>";
echo "<br>";
echo '<form name="backlistfrm" method="post" action="members.php">';
echo '<input type="submit" value="Back to The List">';
echo '</form>';
echo "<br>";
?>