Jump to content

me1000

Members
  • Posts

    183
  • Joined

  • Last visited

    Never

Posts posted by me1000

  1. I feel like an idiot for asking this, but I need some help...

     

    I have a simple 2D array,

     

    $oObj->specailPageList = array(
    'login' => 'login.php'
    );

     

    Now I want to get the value of row... (in this case I want "login.php") to be returned...

    I just cant turn anything up!

     

       echo $oObj->specailPageList["login"];
    

     

     

    Thanks,

     

     

  2. So this will only work if I use PHP generated dates?

     

    this could be a problem, because the date will be stored in the database, and pulled out when it needs to be calculated.

     

     

     

    EDIT: im just going to mark this topic as solved, because for the moment I can just do the math on the dates before they get stored in the DB...

     

  3. ok,

    So when I attempt to work with this, im not having a lot of luck

    echo date("2008-05-26", strtotime('+1 year'));
    

     

    from what I understand this should return

    "2009-05-26" right?

     

    Im getting the exact same date as I entered into it...

    "2008-05-26"

     

    im not sure what the problem is here though...

  4. ok, so basically im out of luck making it any easier on me.

    At first it doesnt seem that hard, however the more I think about it, what if in those 7 days the month changes? I have to write that into my code. Now what happens if the year also changes within that 7 days too?

     

    is there no easy(er) way to manage this?

  5. Hello,

     

    The user will have the ability to determine the expiration period of an entry. (1 week, 2 weeks, 1 month, 2 months, 3 months, 6 months)

     

    The problem is I am unsure of how to filter the results to only show the entries that are not past the expiration.

     

    Is there an easy SQL or PHP command to convert dates to make them much easier to work with?

     

    Thanks,

     

     

  6. ok, So The user will be able to remove an entry from the database, however once they do it needs to update the rest of the entries...

     

    for example, there is an 'ORDER' column in the DB

    if there are 3 entries in the DB the order column would be filled out like so,

    '1,2'3' respectivly.

     

    however If I wanted to remove the row WHERE ORDER=1 the database will have the values to '2,3' instead it needs to update all the values that are greater than 1 and subtract 1 from them, so after you delete the row the db would be updated so that it said '1,2' again.

     

     

    Here is the PART script I have written so far..

    $inPageID       = (is_numeric($_REQUEST['id'])) ? $_REQUEST['id'] : die('invalid id');
    	$query = "SELECT * FROM nav WHERE ASSO=$inPageID";
    
    	$result = mysql_query($query);
    	$blah = mysql_fetch_array($result);
    	$newnum = $blah['ORDER'];
    
    
    	$query = "SELECT * FROM nav WHERE `ORDER` > $newnum";
    		$count = mysql_num_rows(mysql_query($query));
    		//echo $count;
    		//echo $query;
    		//die;
    	if ($count > 0) {	
    		$result = mysql_query($query);
    		while ($blah123 = mysql_fetch_array($result)){
    			$newnum2 = $blah123['ORDER'] - 1;
    			$query = "UPDATE nav SET `ORDER`='$newnum2' WHERE `ID`='".$blah123['ID']."'";
    			$result = mysql_query($query);
    			$message = ($result) ? "" : 'FAIL!';
    			echo $message;
    			//echo $query;
    
    		}
    	}
    

     

    The error im getting is...

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in [path...] on line 69

     

    line 69 is

    while ($blah123 = mysql_fetch_array($result)){

     

     

    I believe it updates the first row after that, but then it fails when it tries to loop again.

     

    Can anyone help me?

     

     

    Thanks,

     

     

     

  7. So basically my while loops will never stop...

    on top of that it looks like my query (only when ran from the browser via this script) will only return one entry.

     

    here is the loop

    $query="SELECT * FROM nav ORDER BY 'ORDER' ASC";
     //echo $query;
    while ($row = mysql_fetch_array(mysql_query($query))) {
    
    	echo '<div class="navBullet"><a href="http://google.com">'.$row['ASSO'].'</a></div>';
    }	

     

    im sure it is just something stupid that im doing, but I cant seem to find it.

    I know the query is good, because I have ran it through my sql manager, and it returned the correct entries.

  8. nope it doesnt, it is basically what I already posted; I just forgot to add the last ) at the end when i removed a good portion of the array.

     

     

    EDIT: nevermind, I think the problem was that the table wasnt long enough.

    so the library I am using to create the pdf just hides it.

  9. array_push($arrayAlpha,array('Name'=>$Row['name']." ".$Row['name']);

     

    That isnt all the code but it is what is causing the problem,

     

    any time I add a 2nd $Row variable it causing nothing to display. As long as there is only one (regardless of which one it is, for example it could be $Row['id'] or $Row['content'] ) it displays fine, the code I posted above is calling the same variable $Row['name'] however it doesnt display, but if I used

     

    array_push($arrayAlpha,array('Name'=>$Row['name']." ");

     

    it would work, even with the space after it.

     

     

    Any ideas how to fix this?

     

     

     

  10. 
    array('CourseName'=>'','number'=>'','Complete'=>'','expired'=>"",'inProgress'=>"") // make the first row blank, 
    
    foreach ($arrCourses as $strKey => $strRow) {
    
    
    // Total Enrolled
    $strQuery = "";
    $intEnrolled = $Database->db->MyQuery($strQuery);
    $counter['1'] = $counter['1'] + $intEnrolled;
    
    
    // Completed
    $strQuery = "";
    $intCompleted = $Database->db->MyQuery($strQuery);
    $counter['2'] = $counter['2'] + $intCompleted;
    
    // Expired without Completing
    $strQuery = "";
    $intExpired = $Database->db->MyQuery($strQuery);
    $counter['3'] = $counter['3'] + $intExpired;
    
    // In Progress
    $strQuery = "";
    $intProgress = $Database->db->MyQuery($strQuery);
    $counter['4'] = $counter['4'] + $intProgress;
    
    ,array('CourseName'=>$strRow['series'] ." ". $strRow['number'] ." (". $strRow['odid'].")",'number'=>$intEnrolled,'Complete'=>$intCompleted,'expired'=>$intExpired,'inProgress'=>$intProgress)
    
    }
    
    ,array('CourseName'=>"TOTAL",'number'=>$counter['1'],'Complete'=>$counter['2'],'expired'=>$counter['3'],'inProgress'=>$counter['4'])
    
    
    );

     

    So basically I need the foreach loop to fill out the array, but from the php error im getting back Im going to guess that PHP doesnt let you do that.

     

    So is there a way I can?

     

    Thanks,

     

     

    EDIT: By the way, I removed most of the queries prior to post because it is pointless to post them,

    but there error im getting is

     

    unexpected T_FOREACH, expecting ')'

    so I know the problem is the loop!

  11. ok, the code works now, I just coped the whole charts.php page into the page that was including it which brings me to my next question.

     

    Can you not send arrays through a function? for example if my array were,

     

    $data['1]=123;

    $data['2]=456;

    $data['3]=789;

     

    and I send $data through the function

     

    functionName($data);

     

    EDIT: nevermind, because I am still sending the array data through the function!

    I really have no idea what was going on...

     

    does that not work?

  12. I believe it is $Graph->add() which sends the headers, Ill check tomorrow for sure, but Im about 95% sure graph.php is just a bunch of classes in which you must call in order for anything to execute.

     

    however the header must be sent sometime to create the PNG... right?

     

  13. Hi,

     

    (all of this is using the PEAR library image_graph http://pear.php.net/package/Image_Graph )

     

    I have a file where I need to create several different graphs all the same kind with limited redundancy. So I have created a function where I pass an array of data through it to create the graph.

     

    this is what I have that generates the file,

     

    function makePieChart($data){
    
    
    require_once 'Image/Graph.php'; 
    
    
    // create the graph 
    $Graph =& Image_Graph::factory('graph', array(400, 300)); 
    
    // create the plotarea 
    $Graph->add( 
    Image_Graph::vertical( 
    Image_Graph::factory('title', array('OnDemand Overall Status', 12)), 
    Image_Graph::horizontal( 
    $Plotarea = Image_Graph::factory('plotarea'), 
    $Legend = Image_Graph::factory('legend'), 
    70 
    ), 
    5 
    ) 
    ); 
    
    $Legend->setPlotarea($Plotarea); 
    
    // create the 1st dataset 
    
    $Dataset1 =& Image_Graph::factory('dataset'); 
    
    
    
    foreach($data as $value){
    $Dataset1->addPoint($value['name'], $value['number']);
    } // this gets the $data array from the PDF file, and loops it to create 
    
    
    $Graph->done(array('filename' => 'output.png'));
    
    }

     

     

     

     

     

     

     

     

    I took out a lot of stuff from it, because I didnt see a need to post it but it works in generating a file.

     

     

    now here is the problem,

     

    when I call the function from another file with this code,

     

     

     

     

    include("charts.php");
    makePieChart($data)

    ;

     

     

     

    it gives me an error, saying the headers were already sent. So the script is making the php file act as a png correct?

    is there a way so that when I call up the function it just creates the new output.png file?

     

     

    Thanks,

  14. create a table for friends,

     

    columns like:

    ID, USERID, FRIENDID

     

    it isnt very efficient but it will work if your user base isn't too large. 

     

    for messages,

    ID, FROM, TO, READ, DATE, MESSAGE

     

    READ is set to a 0 as soon as a message is sent then set to 1 when the recipient sees it.

     

    these things are complicated, you wont find too many people giving tutorials on it. There is a reason MySpace and Facebook make millions of dollars ever month!

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.