SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Member
    Join Date
    Aug 2012
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Display php tag on browser instead of php value

    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?>

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,401
    Mentioned
    147 Post(s)
    Tagged
    4 Thread(s)
    Welcome to the SP forums.

    Could you post some code please?

  3. #3
    SitePoint Member
    Join Date
    Aug 2012
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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">&nbsp;</td>
    <td width="383" class="text-black"><div align="center"></div></td>
    </tr>

    <tr>
    <td>&nbsp;</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>&nbsp;</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>

  4. #4
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,401
    Mentioned
    147 Post(s)
    Tagged
    4 Thread(s)
    Code:
    <?php=$res_query->title; ?>
    You're mixing shorthand and "full" code here. The shorthand version is
    Code:
    <?=$res_query->title; ?>
    while the full version is
    Code:
    <?php echo $res_query->title; ?>

  5. #5
    SitePoint Member
    Join Date
    Aug 2012
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ya you are right but short hand code is not working on localhost what to do.

  6. #6
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,401
    Mentioned
    147 Post(s)
    Tagged
    4 Thread(s)
    Don't use it.

  7. #7
    SitePoint Member
    Join Date
    Aug 2012
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    k sir
    thank u so much sir


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •