Solved

How to use data from my table in mysql

Posted on 2013-06-11
3
162 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
  • 2
3 Comments
 
LVL 51

Accepted Solution

by:
Julian Hansen earned 500 total points
Comment Utility
<?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 51

Expert Comment

by:Julian Hansen
Comment Utility
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
Comment Utility
Exelent :)
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Showing your events from Google Calendar in Google Maps Why? I travel all week and I thought it would be ideal if staff in office knew where I was based on my calendar. (OK real reason: my son wanted to see where I would be working, and I thoug…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to define a gradient in CSS. Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Gradient. Define the background as "linear-gradient(to right, #ee3668, black)". Ensure you …
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now