using editor in conjunction with userID tied to sessions

using editor in conjunction with userID tied to sessions

kinghenry7kinghenry7 Posts: 6Questions: 0Answers: 0
edited April 2014 in Editor
http://pytools.webfactional.com/capstoneTemp/

here is where I am running the demo. I got the dataTable to load successfully on the main page. But i am having issues because the query output from mySQL is associated with the userID based on the type of user that logs in. here is a code sample:

[code]
// find all entries for user
$query=mysqli_query($sql, "SELECT *
FROM PROPERTY WHERE LUSERID='$_SESSION[USERID]'
ORDER BY `STREET` ASC
");
$rowtot = 0;
while($row=mysqli_fetch_assoc($query)){
$result[]=$row;
$rowtot++;
}

if ( $rowtot > 0)
{
?>
//DATATABLE TABLE HERE

<?php
echo '';
foreach($result as $key=>$value){
if($_SESSION['USERID'] = $value["LUSERID"]){
$property_id = $value["PROPID"];
print(" ");

echo '';
print("Edit ");
print (" Delete");
echo '',$value["BLOCK"],' ', $value["LOT"],'',$value["WARD"],' ', $value["ADDRNUM"],' ',$value["STREET"],' ',$value["ZIP"],' ';
if ( $value["BOARDED"] == 1)
{
echo 'Y';
}
else
{
echo 'N';
}
if ( $value["SPOST"] == 1)
{
echo 'Y';
}
else
{
echo 'N';
}
echo '', $value["PDESC"],' ', $value["LCOMMENT"],'';
//-***********image processing includes modal***************************
if(!empty($value["PHOTOLOC"]) ){
$string =array();
$filePath=$value["PHOTOLOC"];
$dir = opendir($filePath);
while ($file = readdir($dir)) {
if (preg_match("/.png/",$file) || preg_match("/.jpg/",$file) || preg_match("/.gif/",$file) || preg_match("/.bmp/",$file) || preg_match("/.jpeg/",$file)) {
$string[] = $file;
}
}
while (sizeof($string) != 0){
$img = array_pop($string);

?>
[/code]

I am sorry I know it is a lot of code. I have not written it, so I just included as much as i thought would be neccesary to undersatnd whats happening. the absic format is that the last column is a photo of the property that is listed in the row, if it has one. also the entries that show in the table are only the ones that the user entered in to the DB themselves. my issues are 1) for some reason this doesn't work well with datatables. an example is viewable if you type in user: "harirao3" and passsword: "testingPrease"

with any login, the datatable doesn't render. I'm not sure why. I know also i should be using the editor as I did pay for it but I have no idea how to use it on a dynamic generation from a mysql query tied to session information as opposed to a static 'select * from table' type sql statement. also i ahve no idea how to actually put the editor into anything besides the sample page that the generator spits out when it does it, but thats probably due to my own incompetence. I don't believe i found any documentation on how to implement the editor into a page outside that sample one the generator makes.

i don't really expect much in terms of a solution here. kinda just throwing up a hail mary.

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Hi,

    When logged in, the table doesn't render due to a Javascript error from DataTables. That in turn is caused by the fact that there is no photo column cells when logged in. The number of cells in the table _must_ equally `rows * columns` . So because this equation isn't true, its a problem for DataTables!

    What I would suggest you do there is modify your PHP a little so that if there is no photo (which I presume is the case here) it just outputs an empty cell, rather than no cell at all.

    Ideally, yes, I would suggest you do use the Editor PHP libraries, assuming you are using them for the editing aspect? What did you try using?

    > I don't believe i found any documentation on how to implement the editor into a page outside that sample one the generator makes.

    Better documentation is coming! Ping me a mail at `allan@` this domain.net and I can e-mail over the new "Getting started" doc if you like - or hang on a few days and I'll be publishing it live :-)

    Allan
  • kinghenry7kinghenry7 Posts: 6Questions: 0Answers: 0
    thanks allan that will probably help the info about the empty cell vs a nonexistant cell... i am going to test this now.
  • kinghenry7kinghenry7 Posts: 6Questions: 0Answers: 0
    that did help... main issue now is how to deal with multiple photos that are to appear in one row. i might throw in the flag on this and say unable to accomplish by the deadline
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Can you not just loop over the array and output the required HTML? You could do that in the mRender function if needed.

    Allan
This discussion has been closed.