Solved

How to use data from my table in mysql

Posted on 2013-06-11
3
167 Views
Last Modified: 2013-06-11
Hi!

Have this webpage:

<?php // RAY_EE_login.php
require_once('RAY_EE_config.php');
$table1 = 'Kontroller';
// ACCESS TO THIS PAGE IS TESTED BUT NOT CONTROLLED
if ($uid = access_control(TRUE))
{

}
else
{
        header("location: login.php");
	    exit;
}

?>
<!DOCTYPE html>

<html>
<head>
<meta charset="utf-8" />
<title>Test system</title>

</head>

<body>
<link rel="stylesheet" href="default.css">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

<Form method="post" action="side3.php">
<table summary="Services, or Links box template" class="servicesT" cellspacing="1">
<tr><td colspan="2" class="servHd">Min Test</td></tr>


<tr>
	<td class="servBodL_medborder" >HERE I WANT DATA FROM MYSQL TABLE</td>
	<td class="servBodL_medborder"><input type="submit" id="GULKN" value=">"></td>
</tr>

</table>
</Form>
<br>
<table summary="Services, or Links box template" class="servicesT" cellspacing="0">
<tr><td colspan="2" class="servHd">MY OPEN</td></tr>
<tr>
	<td class="TESTE" width="92%">TEST</td>
	<td class="servBodL_medborder" width="8%"><input type="submit" id="GULKN" value=">"></td>
</tr>
</table>
<br><br>
<Form method="post" action="logut.php">
<fieldset id="actions">
	<input type="submit" id="LOGIN" value="Logg ut">
</fieldset>
</Form>

</body>
</html>

Open in new window


I need to pu this Php code in this block (code abow)
<tr>
	<td class="servBodL_medborder" >HERE I WANT DATA FROM MYSQL TABLE</td>
	<td class="servBodL_medborder"><input type="submit" id="GULKN" value=">"></td>
</tr>

Open in new window


<?php

$result3 = mysql_query("SELECT Navn FROM {$table1} WHERE Bruker_id='K007'") or die(mysql_error());
while ($row3 = mysql_fetch_array($result3)){
    $navn = $row3['Navn'];
	echo $navn;
}

?>

Open in new window


How do i do this ?
0
Comment
Question by:team2005
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 58

Accepted Solution

by:
Julian Hansen earned 500 total points
ID: 39237559
<?php

$result3 = mysql_query("SELECT Navn FROM {$table1} WHERE Bruker_id='K007'") or die(mysql_error());
while ($row3 = mysql_fetch_array($result3)){
    $navn = $row3['Navn'];
?>
<tr>
	<td class="servBodL_medborder" ><?php echo $navn; ?></td>
	<td class="servBodL_medborder"><input type="submit" id="GULKN" value=">"></td>
</tr>
<?php
}

?>

Open in new window

0
 
LVL 58

Expert Comment

by:Julian Hansen
ID: 39237567
Or
<?php

$result3 = mysql_query("SELECT Navn FROM {$table1} WHERE Bruker_id='K007'") or die(mysql_error());
while ($row3 = mysql_fetch_array($result3)) :
?>
<tr>
	<td class="servBodL_medborder" ><?php echo  $row3['Navn']; ?></td>
	<td class="servBodL_medborder"><input type="submit" id="GULKN" value=">"></td>
</tr>
<?php
endwhile;
?>

Open in new window

using while() : endwhile; is sometimes preferable to using {} when mixing code with html output as it easily enables you to see where code blocks start and end.
0
 
LVL 2

Author Closing Comment

by:team2005
ID: 39237593
Exelent :)
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
Find out what you should include to make the best professional email signature for your organization.
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question