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

Can you help please? Php file
I have to write this php file to allow users to register their nicknames on nickserv

For an I

Save User Inputs while javascript reloading!
hi..
i have written a PHP code in which i reload the page when user selects a value in dropdown..

word wrap in emails help needed
Hello, I understand how wordwrap works in php and have used it well before. However when I used wor

scandir clients directory
hi,
how can i scandir the clients directory? i need a script that when i click a button it will u

Need a fuction to count entries in a field
Hi
I need a fuction to count how many times a email address is entered in to a field.

I ma

How to disable direct access to a file
Suppose I've 2 Files. 1.php & 2.php

I don't want anybody to access 2.php directly fr

mysqli_fetch_assoc returns multiple arrays, how to return a single array
Hello, I am using mysqli_fetch_assoc which is returning multiple rows, so it looks like:

Code

single page with referrer to show correct page
I have a simple website with a couple of different pages. I would like to be able to in a div tag w

User input in to variable
Hi all,

I'm sure this is very easy but I'm having another brain freeze!

At the end of

Paypal
Hi all,

I have an advanced basic knowledge of php

I want to try something new for a s

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