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

WELCOME SCREEN
first of all let me tell you what does my script do,

it´s a very simple query to show a e

DataTable Help Required
Hi all I am creating an app that utilises and MS Access back end and queries it quite a bit at vario

login from external site
Hi my new experience begins, Now what i am trying to do is i make three pages, login.php logout.php

Beginners syntax and loop questions - help please!
Hi everyone,

I have some problems with php code. I'm currently in the middle of learning php,

Strange HTML Tag?
I recently noticed some odd HTML appear in some of the websites I host. Not all of them are run on a

Update not working ... please help
Hi,

I am trying to update a row using an edit form by passing id of the row .. but it is not

Generate multilayered array from string.
ok so i have a string that looks like this:
Code: blog:edit_all,delete_all|users:edit_all,delete_

Different payment methods with different cross company requirements in F110
We are implementing SAP in a company in the shipping industry. They have the following requirement:<

OOP help
okay so i have a class im making it has everything setup i just need to randomize the 2 variables an

BB_Code error
I'm having a problem with a custom built function and keep getting this error:


Warning: M

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