hi i am new to php
i have used drop down and bind the data from database
in dropdown value display the php tag on browser
eg
title?>
desc?>
hi i am new to php
i have used drop down and bind the data from database
in dropdown value display the php tag on browser
eg
title?>
desc?>
Welcome to the SP forums.
Could you post some code please?
below code for connectivity
it works fine in server but in localhost
<?php
//$dbservertype=‘mysql’;
$servername=‘localhost’;
$dbusername=“root”;
$dbpassword=“root”;
$dbname=“tesjoomlaautogua”;
connecttodb($servername,$dbname,$dbusername,$dbpassword);
function connecttodb($servername,$dbname,$dbuser,$dbpassword)
{
global $link;
$link=mysql_connect (“$servername”,“$dbuser”,“$dbpassword”);
if(!$link){die(“Could not connect to MySQL”);}
mysql_select_db(“$dbname”,$link) or die (“could not open db”.mysql_error());
}
session_start();
?>
below code is binding data in database
distributor.php
<?php
include(‘admin/includes/db.php’);
?>
<style>
.styled-select {
width: 220px;
overflow: hidden;
background: #ddd;
}
</style>
<link rel=“stylesheet” href=“dropdown.css” type=“text/css” />
<style media=“all” type=“text/css”>@import “menu_style.css”;</style>
<link href=“css/netcom.css” rel=“stylesheet” type=“text/css”>
<script type=“text/javascript”>
// <![CDATA[
function showDiv(obj){
if(document.getElementById){
divs=document.getElementById(“cont”).getElementsByTagName(“DIV”);
num=obj.options[obj.selectedIndex].value - 1;
for(i=0;i<divs.length;i++){
if (divs[i].className==“txt”){
if(i==num){
divs[i].style.display = “block”;
}else{
divs[i].style.display = “none”;
}
}
}
}
}
// ]]>
</script>
<table width=“391” border=“0” align=“center” cellpadding=“0” cellspacing=“0”>
<tr>
<td width=“7”> </td>
<td width=“383” class=“text-black”><div align=“center”></div></td>
</tr>
<tr>
<td> </td>
<td align="left"><table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="186" ><form action="" id="form1">
<div style="text-align: center;" >
<select id="select1" onchange="showDiv(this.form.select1)" class="styled-select" >
<?php $sel_admin_user=“select * from news1 order by id ASC”;
$query_exe=mysql_query($sel_admin_user);
$loop=1;
while($res_query=mysql_fetch_object($query_exe))
{
?>
<option value="<?php=$loop; ?>"><?php=$res_query->title; ?></option>
<?php $loop++; }
?>
</select> <br>
</div>
</form></td>
</tr>
</table>
<script type=“text/javascript”>
var thetext1=new Array()
thetext1[0]=“”
thetext1[1]=“”
thetext1[2]=“”
thetext1[3]=“news1.com- The #1 technology news1 site.”
thetext1[4]=“Web Coding and development forums”
var thetext2=new Array()
thetext2[0]=“CNN- US and World news1.”
thetext2[1]=“MSNBC- NBC news1 online.”
thetext2[2]=“BBC news1- Updated every minute of every day.”
thetext2[3]=“TheRegister- Daily IT news1.”
// Now, see 2) below for final customization step
function displaydesc(which, descriptionarray, container){
if (document.getElementById)
document.getElementById(container).innerHTML=descriptionarray[which.selectedIndex]
}
function jumptolink(what){
var selectedopt=what.options[what.selectedIndex]
if (document.getElementById && selectedopt.getAttribute(“target”)==“newwin”)
window.open(selectedopt.value)
else
window.location=selectedopt.value
}
displaydesc(document.form1.select1, thetext1, ‘textcontainer1’)
displaydesc(document.form2.select2, thetext2, ‘textcontainer2’)
</script></td>
</tr>
<tr>
<td> </td>
<td align=“left”>
<div id="cont">
<div class="txt" style="display: block;">
<?php
$sel_admin_user="select * from news1 order by id ASC limit 0,1";
$query_exe=mysql_query($sel_admin_user);
$loop=1;
while($res_query=mysql_fetch_object($query_exe))
{
?>
<span class="text-black">
<?php=$res_query->desc; ?>
</span>
<?php } ?>
</div>
<?php
$sel_admin_user="select * from news1 order by id ASC limit 1,100";
$query_exe=mysql_query($sel_admin_user);
$loop=1;
while($res_query=mysql_fetch_object($query_exe))
{
?>
<div class="txt" style="display: none;">
<span class="text-black">
<span class="text-black">
<?php=$res_query->desc;?>
</span>
</span>
</div>
<?php } ?>
</div>
</td>
</tr>
</table>
<?php=$res_query->title; ?>
You’re mixing shorthand and “full” code here. The shorthand version is
<?=$res_query->title; ?>
while the full version is
<?php echo $res_query->title; ?>
ya you are right but short hand code is not working on localhost what to do.
Don’t use it.
k sir
thank u so much sir