Jump to content

zeeshan_haider000

Members
  • Posts

    75
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

zeeshan_haider000's Achievements

Member

Member (2/5)

0

Reputation

  1. Okay, I finally found what the problem was, it was a stupid spelling mistake that I made when calling the function. GetAlbums("nauhey") should have been GetAlbums("nohay"). Now it's working properly. Spent so much time on this small silly mistake. Thanks for replying @ PFMaBiSmAd.
  2. Hi, thanks for the reply @PFMaBiSmAd. You are right, I just checked and the query is returning zero rows. Let me check what's wrong with the query and see if i am able to solve the problem by myself.
  3. When I remove the "while" loops from the script, the fwrite function works correctly and writes data to file. But I need the while loop to get data from database. Anyone know what the problem could be?
  4. Hi there, I am trying to create a file using fwrite function, but for something reason all I get is a blank file with no content inside. Here is the code, go to the bottom where the fwrite function is called: <?php //Get Nohay Albums function function GetAlbums($cattype){ if ((isset($_GET['year']))||(isset($_GET['reciter']))){ //nothing displayed } else{ $query = "SELECT COUNT(Topic), SUM(Hits) AS totalhits, FileFormat, Speaker, Language, Year, FileType, Cat FROM nauhey WHERE Cat='".addslashes($cattype)."' AND Year='".date('Y')."' GROUP By Speaker, Year"; $result = mysql_query($query) or die (mysql_error()); //<!------------ Create Cache -------------!> //folder where cache is saved $path = "cache/"; //Page name format: FunctionName_Category_Year.html $pagename = $path."getalbums_".$cattype.".html"; $cacheFile = fopen($pagename, "w"); if ($cacheFile == FALSE){ die ("Unable to create cache file"); } //Get HTML in a variable $obstart = ob_start(); if ($obstart == FALSE){ die ("Unable to buffer cache content!"); } //<!------------ Cache closed -------------!> if ($cattype = strtolower('nauhey')){ while ($row = mysql_fetch_array($result)){ echo ("<div class='container'>"); echo ("<img src=\"http://localhost/HAQMOLAAALI/backed up/haqmolaali/images/".$row['FileFormat'].".gif\">"); echo ("<b style=\"font-size:10px; color:#000066; position:absolute; margin-left: 500px;\">DOWNLOADS: ".$row['totalhits']."</b>"); echo (" <a href=\"nohay.php?reciter=".urlencode($row['Speaker'])."&year=".urlencode($row['Year'])."\">".$row['Speaker']." Vol ".$row['Year']."</a> <b style=\"font-size:10px; color:#000000;\">(".strtoupper($row['Language']).")</b>"."\n"); echo ("<div class='small'><b>Year: ".$row['Year']." | Language: ".ucfirst($row['Language'])." | Tracks: ".$row['COUNT(Topic)']."</b></div>"); echo ("</div>"); }//while loop closed } else { while ($row = mysql_fetch_array($result)){ echo ("<div class='container'>"); echo ("<img src=\"http://localhost/HAQMOLAAALI/backed up/haqmolaali/images/".$row['FileFormat'].".gif\">"); echo ("<b style=\"font-size:10px; color:#000066; position:absolute; margin-left: 500px;\">DOWNLOADS: ".$row['totalhits']."</b>"); echo (" <a href=\"majlis.php?reciter=".urlencode($row['Speaker'])."&year=".urlencode($row['Year'])."\">".$row['Speaker']." Vol ".$row['Year']."</a> <b style=\"font-size:10px; color:#000000;\">(".strtoupper($row['Language']).")</b>"); echo ("<div class='small'><b>Year: ".$row['Year']." | Language: ".ucfirst($row['Language'])." | Lectures in series: ".$row['COUNT(Topic)']."</b></div>"); echo ("</div>"); } } //<!------------ Cache Code -------------!> $cacheContent = ob_get_contents(); //Write to cache file fwrite ($cacheFile, $cacheContent) or die ("Cannot write cache content to file!"); fclose ($cacheFile); ob_flush(); ob_end_clean(); //<!------------ Cache Closed-------------!> } } GetAlbums("nauhey"); ?> When I execute the function, I get my self-made error "Cannot write cache content to file!". Help would be much appreciated. Thank you.
  5. @Kickstars Thanks for answering @Jay, thank you too for answering. Yupe that's what I did, I didn't want to create a separate table, but with no options left, I had to.
  6. Hi, well here is an alternative: <head> <META HTTP-EQUIV='refresh' CONTENT='3; URL=index.php?n= <? if (!isset ($_GET['n'])) { $n = 0; } else { $n = $_GET['n']; } if ($n == {$n = 0; } /* Reset the loop */ else {$n = $n + 1;} echo $n; ?>'> <title>VD Poem: <? echo $n; ?></title> </head> <?php $poem = array (0 => 'When I am down and, oh my soul, so weary;', 1 => 'When troubles come and my heart burdened be;', 2 => 'Then, I am still and wait here in the silence,', 3 => 'Until you come and sit awhile with me.', 4 => 'You raise me up, so I can stand on mountains;', 5 => 'You raise me up, to walk on stormy seas;', 6 => 'I am strong, when I am on your shoulders;', 7 => 'You raise me up: To more than I can be.', 8 => 'Thanks... Happy Valentine\'s Day!'); ?> <body bgcolor='#FFCC66'> <p> <br> <table width=50% align=center bgcolor=#FFFFCC border=1> <tr><td align=center><font color=#996600><h1 align=center><? echo $poem[$n]; ?></text> </font></td> </tr> </body> </html>
  7. Is it possible to have like "subfields" in mysql? I mean if I have a field, let's say a field named Fieldy, could I create sub fields under "Fieldy" using PHP? Ex: Fieldy (Parent field) -Child Field 1 -Child Field 2 -ETC Field I want to this so that I could be able to edit parts of a data without altering the whole thing. How would I do this? Or any alternative? Thanks
  8. Thanks for replying guys, I was asking the wrong question, here is my code... $file = file($file); $linenum = count($file); foreach($file as $line){ $tabs = explode('||', $line); /* Get the total lines in the file */ $no = count($tabs); for ($i = 0; $i < $no; $i++){ echo $tabs[$i].$linenum.'<br/>'; } instead of echoing $linenum, i was echoing $i...
  9. Hi, I have a text file such as: Tab1a||Tab2a||Tab3a Tab1b||Tab2b||Tab3b Now when i display this data, i want to display the line number next to it (i.e. Tab1b... line 2) How would i do that? Thanks
  10. Sorry if i wasn't clear, the group can be anything, that was just an example. I want a query like ex: Count Number of Fields that are under the group 'group' (anything can be in this 'group' field) Say in my table i have 20 different groups and there are 100 people in these groups, i wnat to know how many ppl are in each group. I want to accomplish this using one query only. Regards..
  11. Hi, My table looks something like this: table1: Name : abc Id: 1 Group: a Num: 1 --------------- table1: Name : sds Id: 3 Group: a Num: 2 -------------- Name: bbc Id: 2 Group: b Num: 5 -------------- I am trying to get total number of rows that are in Group "a" and group "b". For example in group "a" there are 2 peoples and in group "b", 1 person. So how would you achieve this using a query? Inner join etc? Regards...
  12. Well i just figured how to do what i wanted to do. if your ID field are auto incrementing or any other field that is INT, you can use this: SELECT data.* FROM data INNER JOIN (SELECT MAX(id) AS id FROM data group by url) ids ON data.id = ids.id to get a unique Field1 with last inserted data Field2..
  13. I already tried that, when you use LIMIT 1, you are limiting the results to only one row. What i want is to get rows with DISTINCT Enames + in those Enames i want to get the last Enumber... and i don't know if it's possible using a query?
×
×
  • 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.