Problems with adding a link to one position in a 'foreach' loop, please help


Posted on 16th Feb 2014 07:03 pm by admin

Hello!

Iam pretty new to programming and I wanna create a table with users from an array. It works just fine but in one table row I wanna add a link to it so I can click on the username to edit it later. This is my code right now:

Code: $keys = mysql_query("SELECT * FROM users", $connection);
confirm_query($keys);
$result = mysql_query("SELECT * FROM users", $connection);
if (!$result)
confirm_query($keys);

echo "<table id="usertable">";
echo "<tr id="usertablemain">";
$a = array_keys(mysql_fetch_assoc($keys));
foreach($a as $b) { echo "<td>" . $b . "</td>";}
echo "</tr>";
while ($rows = mysql_fetch_assoc($result))
{
echo "<tr>";
foreach ($rows as $row)
{

echo "<td>".$row."</a>"."</td>";
}
echo "</tr>";
}
echo "</tr>";
echo "</table>";

I tried to nest a IF statement but it always give in some way true and all positions in the table get a <a href> tag. The array contains a position called 'username' which is in the second row. Please help me out

No comments posted yet

Your Answer:

Login to answer
222 Like 35 Dislike
Previous forums Next forums
Other forums

mySQL and PHP search
Hello,
I am trying to code a project and ran into a brick wall with one of my pages. I am pretty

PHP code for a proxy
I was wondering which function I could use to create an online proxy tool. I was thinking cURL would

Include a php
Hello,

I'm trying to include a function that shows the recent searches.
Example I have <

cURL proxy
Okay here is the thing... i know how to add proxys

Code: curl_setopt($ch, CURLOPT_PROXYTYPE,

Unexpected T_Variable ?
Hi all,
I dont really know what I am doing!! I know I'm doing something wrong, and I know its on

Syntax Help
Code:


im having trouble with that code snipped
Parse error: syntax error, unexpec

TemplatePower & AJAX
Hi all,



I'm currently implementing some AJAX features in my PHP-framework (which is b

PHP, Arrays & A Lot Of Confusion
I've been doing basic PHP work on sites for a few years now, but I've never been tempted to learn ho

Image resize
Hi again fellers

I managed to sort out the issues with the folder,

Final hurdle is th

Inserting multiple records from single form
I've found a number of threads that deal with this issue, but I'm new to php and coding language so

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash