| | |
Help! echo herf variable, automatically link to the corresponding pages
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Oct 2009
Posts: 25
Reputation:
Solved Threads: 0
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:
Error:
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:
PHP Syntax (Toggle Plain Text)
<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:
PHP Syntax (Toggle Plain Text)
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
•
•
Join Date: Oct 2009
Posts: 25
Reputation:
Solved Threads: 0
0
#2 Oct 27th, 2009
i know it's the problem of .
But i can't solve it.
Welcome for any suggestions!!! Thanks.
PHP Syntax (Toggle Plain Text)
echo "<td><a href=\"$row[\"sujet\"].php\" alt='autosujet.php'>DETAIL</a></td>";
But i can't solve it.
Welcome for any suggestions!!! Thanks.
•
•
Join Date: Oct 2009
Posts: 25
Reputation:
Solved Threads: 0
0
#3 Oct 27th, 2009
i have changed the code to:
Now it works like i can link it to variable $row['sujet']. But i want to link it to $row['sujet'].php.
Anyone has an idea???? Thanks in advance.
PHP Syntax (Toggle Plain Text)
echo "<td><a href=\"".$row['sujet']."\" alt='autosujet.php'>DETAIL</a></td>";
Now it works like i can link it to variable $row['sujet']. But i want to link it to $row['sujet'].php.
Anyone has an idea???? Thanks in advance.
•
•
Join Date: Oct 2009
Posts: 15
Reputation:
Solved Threads: 3
0
#4 Oct 27th, 2009
•
•
•
•
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:
PHP Syntax (Toggle Plain Text)
<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:
PHP Syntax (Toggle Plain Text)
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
PHP Syntax (Toggle Plain Text)
<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>'; } ?>
•
•
Join Date: Oct 2009
Posts: 15
Reputation:
Solved Threads: 3
0
#5 Oct 27th, 2009
Hi Use This
PHP Syntax (Toggle Plain Text)
<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>'; } ?>
•
•
Join Date: Oct 2009
Posts: 25
Reputation:
Solved Threads: 0
0
#6 Oct 27th, 2009
•
•
•
•
Hi Use This
PHP Syntax (Toggle Plain Text)
<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>'; } ?>
I changed my code based on yours. Just delete a " and it works now.
PHP Syntax (Toggle Plain Text)
echo '<td><a href="'.$row['sujet'].'.php" alt="autosujet.php">DETAIL</a></td>';
Thanks a lot for the help, friend!
•
•
Join Date: Oct 2009
Posts: 25
Reputation:
Solved Threads: 0
0
#9 Oct 27th, 2009
Sorry, i forgot to describe my need with details.
I want to display a form in $row['sujet'].php.
First, I use a mysql query "select * from table besoin where sujet=$row['sujet']"; 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 $['sujet'].php.
Thanks for your suggestions.
I want to display a form in $row['sujet'].php.
First, I use a mysql query "select * from table besoin where sujet=$row['sujet']"; 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 $['sujet'].php.
Thanks for your suggestions.
![]() |
Similar Threads
- Row variable to live link (PHP)
- Automated quality link exchange (Relevant Link Exchanges)
- PHP add automatically / to a $_GET variable (PHP)
- make a link from an array variable (PHP)
- link exchange script (Existing Scripts)
- Linking to other pages (PHP)
- IE6 refuses to link to pages (Windows NT / 2000 / XP)
- Link Swapper (Search Engine Optimization)
Other Threads in the PHP Forum
- Previous Thread: session message printing problem
- Next Thread: oci_execute() invalid character ORA-00911
| Thread Tools | Search this Thread |






