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

parse error
Parse error: syntax error, unexpected '[', expecting ')' in /Users/admin/Sites/phptest/array.php on

making web pages for accounts
Hello, I would like to make pages for accounts on my website im making (its not a real website..im j

PHP MySQL and DATE
Hi everyone

I have a databse and in one of the columns I have date values such as 2009-March-

Redirect not working after making a POST/GET
Hi Everyone,

I am a novice in PHP. Here I have 2 pages, one page with a textbox and button an

form variables from database help.
Hi all,

I would like to have a form that gives you options based on the results of an mysql q

[newb] Image hosting help.
Hey there, I'm new to php, I know some basics and i can code PWN, I'm only 14 but I'm interested in

sql problems
I am having a small problem with my sql statement. it is inserting into 4 of the fields.

fie

Developing Ajax-enabled ASP.Net applications for the iPhone
I would like to develop Ajax web applications using Visual Studio that are optimized for the iPhone.

Taylor Series Function
So I am working a a project for my intro C++ class, and I am having some trouble with a function for

Array question
Does anyone know how to create a program that takes the $ amount for 8 different departments and gi

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