Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

php variable in html code

Status
Not open for further replies.

onbeat69

Programmer
Jan 4, 2004
5
US
i accessed php variable data from mysql server, and i want to display my data in my html code as part of the general website. how do u do that?
 
Code:
print &quot;<html><body><table><tr><td>$yourevariable</td></tr></table></body></html>&quot;;
[code]

something like this
 
or
?>
<html><body><table><tr><td><? echo &quot;$yourevariable&quot;;?></td></tr></table></body></html>

 
pos2,

no,for instance, i have executed query

select qty1 from contacts;


how do i assign a php variable to the accessed data from mysql query, and display the variable in html code.

is it $qty1, how do i display in web?
 
Code:
$query=&quot;SELECT * from artisttable order by arname&quot;;
$rs=mysql_query($query,$conn);

HeadSectie(&quot;Artist list&quot;);
BovenBalk(); 
OnderBalk(); 

PRINT (&quot;<table width=100% cellspacing=1 border=0>
	<tr class=boven2>
	<td>Name</td>
	<td>Technical details</td>
	<td></td>
	<td></td>
	</tr>&quot;);

$list = mysql_num_rows($rs); 
while($i < $list)	
{
$row = mysql_fetch_array($rs); 
$arid=$row[&quot;arid&quot;];
$arname=$row[&quot;arname&quot;];
$arspecs=$row[&quot;arspecs&quot;];


if ($j==0){
	print&quot;<tr valign=top class=inspr2>&quot;; 
	$j++;
	} else	{
   	print&quot;<tr valign=top class=inspr>&quot;; 
	$j=0;
	}

   print&quot;<td>$arname<br></td>&quot;; 
   print&quot;<td>$arspecs<br></td>&quot;; 
   print&quot;<td><a href=arform.php3?id=$arid>EDIT</a><br></td>&quot;; 
   print&quot;<td><a href=aragenda.php3?id=$arid>AGENDA</a><br></td>&quot;; 
   print&quot;</tr>&quot;; 

$i++;
}

print (&quot;
</table></td></tr>
</table>
</BODY>
</HTML>&quot;);

here is an example I use to list artists from my database.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top