Now i extract data from mysql database, and echo them in a table.

In the last column of each row, i made a link. It link to the corresponding page according to the value of first column in the row.

Now i can't get the solution and have some errors.

Here is my code:

<table id="t" border="1">
		<tr>
			<th>SUJET</th>
			<th>DATE</th>
			<th>NATURE</th>
			<th>ACTION</th>
			<th>NON DE DECIDEUR</th>
			<th>DETAIL</th>
		</tr>
	<?php
		$conn = mysql_connect("localhost","root","") or die("Sorry, can't connect: ".mysql_error());
		mysql_select_db($db);
		$query = "SELECT sujet, bdate, nature, adetail, decideur FROM besoin";
		$result = mysql_query($query, $conn) or die("Sorry, don't get result for error: ".mysql_error());
		while($row = mysql_fetch_assoc($result)){
			echo "<tr><td>".$row["sujet"]."</td>";
			echo "<td>".$row["bdate"]."</td>";
			echo "<td>".$row["nature"]."</td>";
			echo "<td>".$row["adetail"]."</td>";
			echo "<td>".$row["decideur"]."</td>";
			echo "<td><a href=\"$row[\"sujet\"].php\" alt='autosujet.php'>DETAIL</a></td>";
			echo "</tr><br>";
		}
	?>

Error:

Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in C:\wamp\www\CRM1.11\pages\pperso\bes\list.php on line 38

i know it's the problem of

echo "<td><a href=\"$row[\"sujet\"].php\" alt='autosujet.php'>DETAIL</a></td>";

.

But i can't solve it.

Welcome for any suggestions!!! Thanks.

i have changed the code to:

echo "<td><a href=\"".$row['sujet']."\" alt='autosujet.php'>DETAIL</a></td>";

Now it works like i can link it to variable $row. But i want to link it to $row.php.

Anyone has an idea???? Thanks in advance.

Now i extract data from mysql database, and echo them in a table.

In the last column of each row, i made a link. It link to the corresponding page according to the value of first column in the row.

Now i can't get the solution and have some errors.

Here is my code:

<table id="t" border="1">
		<tr>
			<th>SUJET</th>
			<th>DATE</th>
			<th>NATURE</th>
			<th>ACTION</th>
			<th>NON DE DECIDEUR</th>
			<th>DETAIL</th>
		</tr>
	<?php
		$conn = mysql_connect("localhost","root","") or die("Sorry, can't connect: ".mysql_error());
		mysql_select_db($db);
		$query = "SELECT sujet, bdate, nature, adetail, decideur FROM besoin";
		$result = mysql_query($query, $conn) or die("Sorry, don't get result for error: ".mysql_error());
		while($row = mysql_fetch_assoc($result)){
			echo "<tr><td>".$row["sujet"]."</td>";
			echo "<td>".$row["bdate"]."</td>";
			echo "<td>".$row["nature"]."</td>";
			echo "<td>".$row["adetail"]."</td>";
			echo "<td>".$row["decideur"]."</td>";
			echo "<td><a href=\"$row[\"sujet\"].php\" alt='autosujet.php'>DETAIL</a></td>";
			echo "</tr><br>";
		}
	?>

Error:

Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in C:\wamp\www\CRM1.11\pages\pperso\bes\list.php on line 38
<table id="t" border="1">
		<tr>
			<th>SUJET</th>
			<th>DATE</th>
			<th>NATURE</th>
			<th>ACTION</th>
			<th>NON DE DECIDEUR</th>
			<th>DETAIL</th>
		</tr>
	<?php
		$conn = mysql_connect("localhost","root","") or die("Sorry, can't connect: ".mysql_error());
		mysql_select_db($db);
		$query = "SELECT sujet, bdate, nature, adetail, decideur FROM besoin";
		$result = mysql_query($query, $conn) or die("Sorry, don't get result for error: ".mysql_error());
		while($row = mysql_fetch_assoc($result)){
			echo '<tr><td>'.$row["sujet"].'</td>';
			echo '<td>'.$row["bdate"].'</td>';
			echo '<td>'.$row["nature"].'</td>';
			echo '<td>'.$row["adetail"].'</td>';
			echo '<td>'.$row["decideur"].'</td>';
			echo '<td><a href="'.$row['sujet'].'".php" alt="autosujet.php">DETAIL</a></td>';
			echo '</tr><br>';
		}
	?>

Hi Use This

<table id="t" border="1">
		<tr>
			<th>SUJET</th>
			<th>DATE</th>
			<th>NATURE</th>
			<th>ACTION</th>
			<th>NON DE DECIDEUR</th>
			<th>DETAIL</th>
		</tr>
	<?php
		$conn = mysql_connect("localhost","root","") or die("Sorry, can't connect: ".mysql_error());
		mysql_select_db($db);
		$query = "SELECT sujet, bdate, nature, adetail, decideur FROM besoin";
		$result = mysql_query($query, $conn) or die("Sorry, don't get result for error: ".mysql_error());
		while($row = mysql_fetch_assoc($result)){
			echo '<tr><td>'.$row["sujet"].'</td>';
			echo '<td>'.$row["bdate"].'</td>';
			echo '<td>'.$row["nature"].'</td>';
			echo '<td>'.$row["adetail"].'</td>';
			echo '<td>'.$row["decideur"].'</td>';
			echo '<td><a href="'.$row['sujet'].'".php" alt="autosujet.php">DETAIL</a></td>';
			echo '</tr><br>';
		}
	?>

Hi Use This

<table id="t" border="1">
		<tr>
			<th>SUJET</th>
			<th>DATE</th>
			<th>NATURE</th>
			<th>ACTION</th>
			<th>NON DE DECIDEUR</th>
			<th>DETAIL</th>
		</tr>
	<?php
		$conn = mysql_connect("localhost","root","") or die("Sorry, can't connect: ".mysql_error());
		mysql_select_db($db);
		$query = "SELECT sujet, bdate, nature, adetail, decideur FROM besoin";
		$result = mysql_query($query, $conn) or die("Sorry, don't get result for error: ".mysql_error());
		while($row = mysql_fetch_assoc($result)){
			echo '<tr><td>'.$row["sujet"].'</td>';
			echo '<td>'.$row["bdate"].'</td>';
			echo '<td>'.$row["nature"].'</td>';
			echo '<td>'.$row["adetail"].'</td>';
			echo '<td>'.$row["decideur"].'</td>';
			echo '<td><a href="'.$row['sujet'].'".php" alt="autosujet.php">DETAIL</a></td>';
			echo '</tr><br>';
		}
	?>

Thanks a lot for your posting. You are almost there.

I changed my code based on yours. Just delete a " and it works now.

echo '<td><a href="'.$row['sujet'].'.php" alt="autosujet.php">DETAIL</a></td>';

Thanks a lot for the help, friend!

I have one another question about passing variables between pages.

If i want to use $row in the page $row.php, how can i manage to do that?

Hope for advice.

Please Explain your Need

Sorry, i forgot to describe my need with details.

I want to display a form in $row.php.

First, I use a mysql query "select * from table besoin where sujet=$row"; to get the values.

And then, i want to populate them in a form.

I can populate it in a form, but i don't know how to pass the variable to the page $.php.

Thanks for your suggestions.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.