:: Forum >>

problem displaying from mysql

hai, i'm trying to get the grid working with php/mysql, but when i select a db, table and some fields.. it wont show anything..
i double checked my sql info is right..

this is the source in html when i open basic.php

<html>
<head>
    <title>ActiveWidgets Grid :: PHP Example</title>
    <style> body, html {margin:0px; padding: 0px; overflow: hidden;font: menu;border: none;} </style>

    <!-- ActiveWidgets stylesheet and scripts -->
    <link href="../../runtime/styles/xp/grid.css" rel="stylesheet" type="text/css" ></link>
    <script src="../../runtime/lib/grid.js"></script>

    <!-- ActiveWidgets PHP functions -->
        
</head>
<body>

<script>
var _columns = [

];
var _data = [
];
try {
var = new Active.Controls.Grid;
.setRowCount();
.setColumnCount();
.setDataText(function(i, j){return _data[i][j]});
.setColumnText(function(i){return _columns[i]});
document.write();
}
catch (error){
document.write(error.description);
}
</script>

</body>
</html>


anyone knows how 2 solve this?
MichielM
Tuesday, August 2, 2005
There isn't any data in this code. It can't display what isn't there. You are making an error in your PHP code, otherwise there would be information between your "var _data = [ " and your "];".
Post the PHP code and we might be able to assist you. But from what you have posted above, the grid is working properly.
Jim Hunter
Wednesday, August 3, 2005
ok, the main problem is solved.. i dont know what it was, but i uploaded it today and it works! great stuff!
It seems to be i cant select the fields that will be added to the grid, because every field is showing up now:S. this is my script:

<html>
<head>
    <title>ActiveWidgets Grid :: PHP Example</title>
    <style> body, html {margin:0px; padding: 0px; overflow: hidden;font: menu;border: none;} </style>

    <!-- ActiveWidgets stylesheet and scripts -->
    <link href="../../runtime/styles/xp/grid.css" rel="stylesheet" type="text/css" ></link>
    <script src="../../runtime/lib/grid.js"></script>

    <!-- ActiveWidgets PHP functions -->
    <?php include("activewidgets.php") ?>
    <?php include("config.php") ?>

</head>
<body>

<?php

    // grid object name
    $name = "obj";

    // SQL query
    $query = "select * from `leden` limit 0,20";

    // database connection
    $connection = mysql_connect("$host", "$user", "$ww");
    mysql_select_db("$db");

    // query results
    $data = mysql_query($query, $connection);

    // add grid to the page
    echo activewidgets_grid($gebruikersnaam, $automerk, $type);

?>


</body>
</html>


how can i only select $gebruikersnaam, $automerk and $type?
MichielM
Thursday, August 4, 2005
you need to learn a little mysql.

Specifically in this case select * from... gives you all fields.

select a,b,c from... would give you only fields a,b and c
rick
Thursday, August 4, 2005
or he could do something like this:
$html .= " $name.setColumnValues([1,4,5,7,9,10,12]);\n";

to show only columns 1,4,5,7,9,10 & 12
Dan
Thursday, August 4, 2005
oops forgot to say wher to put:
$html .= " $name.setColumnValues([9,10,11,12]);\n";

put it in the include("activewidgets.php") file
Dan
Thursday, August 4, 2005
i have attached my coding in this. here is an error. that is array is undefined. any one can solve this pbm?



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/tr/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<style>
html {background-color:#eeeeee}
body {
background-color:#ffffcc;
font-family:Tahoma,Arial,Helvetica,sans-serif;
font-size:12px;
margin-left:15%;
margin-right:15%;
border:3px groove #006600;
padding:15px
}
h1 {
text-align:left;
font-size:1.5em;
font-weight:bold
}
</style>

<script type="text/javascript">

// global flag
var isIE = false;

// global request and XML document objects
var req;

//document.getElementById("hiddenDIV").style.visibility="visible";
//document.getElementById("hiddenDIV").innerHTML=xhr.rs(0);

function loadXMLDoc(url) {
// branch for native XMLHttpRequest object
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
req.onreadystatechange = processReqChange;
req.open("GET", url, true);
req.send(null);
// branch for IE/Windows ActiveX version
} else if (window.ActiveXObject) {
isIE = true;
req = new ActiveXObject("Microsoft.XMLHTTP");
if (req) {
req.onreadystatechange = processReqChange;
req.open("GET", url, true);
req.send();
}
}
}


function loadDoc(evt) {
// equalize W3C/IE event models to get event object
evt = (evt) ? evt : ((window.event) ? window.event : null);
if (evt) {
// equalize W3C/IE models to get event target reference
var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
if (elem) {
try {
if (elem.selectedIndex > 0) {
loadXMLDoc(elem.options[elem.selectedIndex].value);
}
}
catch(e) {
var msg = (typeof e == "string") ? e : ((e.message) ? e.message : "Unknown Error");
alert("Unable to get XML data:\n" + msg);
return;
}
}
}
}



// retrieve text of an XML document element, including
// elements using namespaces
function getElementTextNS(prefix, local, parentElem, index) {
var result = "";
if (prefix && isIE) {
// IE/Windows way of handling namespaces
result = parentElem.getElementsByTagName(prefix + ":" + local)[index];
} else {
// the namespace versions of this method
// (getElementsByTagNameNS()) operate
// differently in Safari and Mozilla, but both
// return value with just local name, provided
// there aren't conflicts with non-namespace element
// names
result = parentElem.getElementsByTagName(local)[index];
}
if (result) {
// get text, accounting for possible
// whitespace (carriage return) text nodes
if (result.childNodes.length > 1) {
return result.childNodes[1].nodeValue;
} else {
return result.firstChild.nodeValue;
}
} else {
return "n/a";
}
}



// display details retrieved from XML document
function showDetail(evt) {
evt = (evt) ? evt : ((window.event) ? window.event : null);
var item, content, div;
if (evt) {
var select = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
if (select && select.options.length > 1) {
// copy <content:encoded> element text for
// the selected item
item = req.responseXML.getElementsByTagName("item")[select.value];
content = getElementTextNS("content", "encoded", item, 0);
div = document.getElementById("details");
div.innerHTML = "";
// blast new HTML content into "details" <div>
div.innerHTML = content;
}
}
}


//for retrieving data
function ConDB()
{

var s1 = document.fm.t1.value;
var nm = s1.substring(0,2);

var n1 = null;
if (nm.length >= 2)
{
var conn = new ActiveXObject("ADODB.Connection") ;
var connectionstring="Provider=SQLOLEDB;Password=sa;User ID=sa;Initial Catalog=TEST;Data Source=192.168.1.83;"
conn.Open(connectionstring);
var rs = new ActiveXObject("ADODB.Recordset");
var recordarray=new array();
var i=0;
rs.Open("SELECT * FROM STUD WHERE NAME LIKE '%" + nm + "%'", conn);

if (!rs.eof && !rs.bof)
{
rs.moveFirst

while(!rs.eof)
{
// var oOption = document.createElement("OPTION");
// oSelect.options.add(oOption);
// oOption.innerText = rs(0);
recordarray[i]=rs(0);
i+=1;
rs.moveNext


}

}
else
{
document.write('No matches found!');

}
rs.close;
conn.close;
}
else
{
document.write(" plz enter more than one char");

}
}
</script>
</head>



<body>
<h1><b><center>Search Engine</center></b></h1>
<hr />

<form name="fm">
<p><center>Enter the string to search</center><br />
<center><input type="text" name="t1" value="" onkeyup="ConDB();"></center>
</p>
<p>Items:<br />
<select size="10" id="topics" onchange="showDetail(event)">
<option value="">output of search details</option>
</select>
</p>
</form>
<div size="10" id="details"><span></span></div>
</body>
</html>




senthil
Wednesday, November 23, 2005

This topic is archived.


Back to support forum

Forum search