Jump to content

mraza

Members
  • Posts

    329
  • Joined

  • Last visited

    Never

Everything posted by mraza

  1. Thanks again sir now i get the point, and to answer regarding multiple categories i just wants to display any of one category posts but this your code solved it i guess i will test it now and to reverse engineer not really as i stated above i am building my own posting system, i hv already built registration, user comments etc, so if i was upto like that i will not goto build a new system for me there are several available like wordpress,joomla, i am learning php from several months and trying to do whatever comes in my mind as it is the only way i can learn, and thankfully there are people like you who helps people like me. i really appreciate for your kind support. Regards
  2. I am using include function to include that related posts page , thing is when after search i go to index.php?action=test&cat=2&post=5 there i have code to display post like this include('leftbar.php'); // Here comes the post data from above url of post id 5 include('rightbar.php'); // in this page i hv code to use $_GET['cat'] to display related posts so to display a category id i need to hv $_GET['cat'] in my url or else rightbar.php would not work, also i found a link here which explain to prevent this behavior but that's in virtuemart http://forum.virtuemart.net/index.php?topic=45182.msg189142 but dont understand what exactly need todo Regards
  3. Actually sir if u note this line in above code $results[] = "{$i} : <a href=index.php?action=test&cat={$row['catid']}&post={$row['id']}>{$row['title']}</a> ({$row['year']}) Body: ss{$row['body']}<br />"; i am using a related post feature so when after search i click on any return result it will take me to that post and as i have category id in my url so there i am displaying related topics tile with $row['catid'] from $_GET['cat']
  4. this {} is to separate variables from other code, so when using a variables inside a string etc, its always good practice to close variable inside {$variable}
  5. one more issue, as i also have one search function associated with it, so now for example if i have one post in three categories, it shows me three results after search how can i prevent it to show only one post when search something, here is code i used from here: $searchSQL = "SELECT * FROM posts as p JOIN post_category as pc ON p.id = pc.postid WHERE "; // grab the search types. $types = array(); $types[] = isset($_GET['title'])?"`title` LIKE '%{$searchTermDB}%'":''; $types[] = isset($_GET['body'])?"`body` LIKE '%{$searchTermDB}%'":''; $types[] = isset($_GET['year'])?"`year` LIKE '%{$searchTermDB}%'":''; $types = array_filter($types, "removeEmpty"); // removes any item that was empty (not checked) if (count($types) < 1) $types[] = "`title` LIKE '%{$searchTermDB}%'"; // use the body as a default search if none are checked $andOr = isset($_GET['matchall'])?'AND':'OR'; $searchSQL .= implode(" {$andOr} ", $types) . " ORDER BY `title`"; // order by title. $searchResult = $db->query($searchSQL) or trigger_error("There was an error.<br/>" . mysql_error() . "<br />SQL Was: {$searchSQL}"); if ($db->Numrows($searchResult) < 1) { $error[] = "The search term provided {$searchTerms} yielded no results."; }else { $results = array(); // the result array $i = 1; while ($row = $db->fetchArray($searchResult)) { $results[] = "{$i} : <a href=index.php?action=test&cat={$row['catid']}&post={$row['id']}>{$row['title']}</a> ({$row['year']}) Body: ss{$row['body']}<br />"; $i++; } } so with above i get multiple results like if i search "My first Post" it will return me three results as it is associated with three categories, how can i fix it, i checked array_unique but did not figured it out. Regards
  6. ($ch, CURLOPT_POSTFIELDS, 'p_entity_name='. $name .'&p_name_type=A&p_search_type=BEGINS'); u need to use concatenation operator
  7. something like this? $query = mysql_query("SELECT id,systems FROM table1"); while($row = mysql_fetch_array($query)) { mysql_query("INSET INTO table2 (`id2`, `value` ) VALUES ({$row['id']}, {$row['systems']})"); }
  8. hv u tried to check ur spam folder? it could be sending email in ur spam box.
  9. not sure if u are looking for they i1,i2... here is way to get key value with $key <?php $formarray = array( 'name' => array( 'i1'=> array('a'=>'a1', 'b'=>'b1', 'c'=>'c1', 'd'=>'d1', 'e'=>'e1', 'f'=>'f1', 'g'=>'g1'), 'i2'=> array('a'=>'a2', 'b'=>'b2', 'c'=>'c2', 'd'=>'d2', 'e'=>'e2', 'f'=>'f2', 'g'=>'g2'), 'i3'=> array('a'=>'a3', 'b'=>'b3', 'c'=>'c3', 'd'=>'d3', 'e'=>'e3', 'f'=>'f3', 'g'=>'g3'), 'i4'=> array('a'=>'a4', 'b'=>'b4', 'c'=>'c4', 'd'=>'d4', 'e'=>'e4', 'f'=>'f4', 'g'=>'g4'), ) ); foreach ($formarray as $newarray => $a) { ?><strong><?=$newarray;?></strong><br><? foreach ($a as $key => $k) { ?>"<?=$key;?>", <? foreach ($k as $b) { ?>"<?=$b;?>", <? } ?><br><? } //end of second foreach ?><br><br><br><? } //end of first foreach ?>
  10. i think if u do that with decimal it would work but as a simple fix i used this once $var = ($num<10) ? "0$num" : $num;
  11. Thanks again for taking time to look in it, as u can see the same post has been repeated three time above in ur example: posttitle | postbody | catname ================================================ My First Post This is a test post | Gaming My First Post This is a test post | Discussion My First Post This is a test post | Community what i wants is like this: posttitle | postbody | catname ================================================ My First Post This is a test post | Gaming, Discussion, Community so it display catnames rather then repeating post itself. Regards
  12. Thank you sir now i understand this join stuff, just one last thing, now i can get that post but how can i get categories names associated with that post, i tried this one $id = $row['id']; $sql = "SELECT * FROM categories as p JOIN post_category as pc ON p.id = pc.catid WHERE pc.postid = '$id'" ; $query= $db->query("$sql"); $rows = $db->fetchArray($query); // print_r($rows); echo $rows['name']; and with that i only get one name of category, how can i get all categories names. thanks again.
  13. solved <input type="hidden" name="action" value="search" />
  14. hi i hv a form to submit on this url http://localhost/site/index.php?action=search and in my html <form method="GET" action="<?php echo $_SERVER['PHP_SELF'];?>" name="searchForm">// my code</form>// i also tried //http://localhost/site/index.php?action=search&// but did not helped now problem is i wants to go that URL so after submit it should look a like this as i am loading search page with action. http://localhost/site/index.php?action=search&searchstring=word but it keeps me redirecting to http://localhost/site/index.php?searchstring=word how can i make it work so it will goto this URL http://localhost/site/index.php?action=search&searchstring=word Thanks for help.
  15. Thank you for help but what will be my query to insert and retrieve data from those tables
  16. hi i hv built a small posting system, i hv built few categories like this in mysql i hv these tables Categories table: id catname Post Table: id postbody posttile date catid so i am getting posts with catid for related posts like http://localhost/site/index.php?action=category&cat=1 so where $_GET['cat'] is 1 it display posts from that category 1, now what i need is when i post a new post i hv choice to assign multiple categories to one post, so a post could be in cat1 and in cat2 as well . plz any idea how can i do that? i was thinking to make a new rows in posts table for each category and set it to 0 or 1 , and when i submit new post it will set 1 to those categories which i select upon writing post. but if i have like 20 categories i need to add more 20 rows in posts table. is there any other better way i can accomplish this? Thanks for help
  17. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <script type="text/javascript"> // <![CDATA[ function display(obj,id1,id2,id3) { txt = obj.options[obj.selectedIndex].value; document.getElementById(id1).style.display = 'none'; document.getElementById(id2).style.display = 'none'; document.getElementById(id3).style.display = 'none'; if ( txt.match(id1) ) { document.getElementById(id1).style.display = 'block'; } if ( txt.match(id2) ) { document.getElementById(id2).style.display = 'block'; } if ( txt.match(id3) ) { document.getElementById(id3).style.display = 'block'; } } // ]]> </script> <style type="text/css"> #id1 { /* The id does not have to match the above script */ position:relative; display: none; } #id2 { position:relative; display: none; } #id3 { position:relative; display: none; } </style> </head> <body> <select name="source" onchange="display(this,'id1','id2','id3');"> <option class="highlight">Select Heading:</option> <option value="id1">One</option> <option value="id2">Two</option> <option value="id3">Three</option> </select> <div id="id1"> <table width="100%" cellspacing="2" cellpadding="2"> <tr> <td align="right">first: </td> <td><input type="text" name="url" /></td> </tr> </table> </div> <div id="id2"> <table width="100%" cellspacing="2" cellpadding="2"> <tr> <td align="right">second: </td> <td><input type="text" name="url" /></td> </tr> </table> </div> <div id="id3"> <table width="100%" cellspacing="2" cellpadding="2"> <tr> <td align="right">third: </td> <td><input type="text" name="url" /></td> </tr> </table> </div> </body> </html> SOLVED
  18. hi i hv a javascript what it dos is if i select an option it will show related div below, here is code <script type="text/javascript"> // <![CDATA[ function display(obj,id1) { txt = obj.options[obj.selectedIndex].value; document.getElementById(id1).style.display = 'none'; if ( txt.match(id1) ) { document.getElementById(id1).style.display = 'block'; } } // ]]> </script> <select name="type" onchange="display(this,'first');"> <option>Please select:</option> <option value="first">First</option> <option value="second">Second</option> <option value="third">third</option> <option value="fourth">fourth</option> </select><br /> <div id="first" style="display: none;"> show first <input name="going" type="text" id="" size="80"> </div> now what i need is if i selecd Second it will display the next div with id second and hide others, so i can have multiple divs like this, above code is working only for first div. <div id="first" style="display: none;"> show first <input name="going" type="text" id="" size="80"> </div> <div id="second" style="display: none;"> show second <input name="going" type="text" id="" size="80"> </div> <div id="third" style="display: none;"> show third <input name="going" type="text" id="" size="80"> </div> //and so on please any idea how can i do that. Thanks
  19. thanks sir i guess i found it here was problem changed this $row = mysql_fetch_row($result); to $row = mysql_fetch_array($result); and now i can see those variables with last code thx for ur help, appreciated
  20. thanks sir, yes i did like this function is_login() { if(isset($_POST['username'])) { session_start(); $username = $_POST['username']; $password = $_POST['password']; $strSQL = "SELECT * FROM ".USERS_TABLE_NAME." WHERE username ='$username' AND password = '$password' "; $result = mysql_query ($strSQL); $row = mysql_fetch_row($result); $_SESSION['user'] = $row['username']; $_SESSION['id'] = $row['id']; $exist = count($row); if($exist >=2) { $this->jscript_location(); } else { $this->notify_show();} exit; } } also tried like this too function is_login() { if(isset($_POST['username'])) { $username = $_POST['username']; $password = $_POST['password']; $strSQL = "SELECT * FROM ".USERS_TABLE_NAME." WHERE username ='$username' AND password = '$password' "; $result = mysql_query ($strSQL); $row = mysql_fetch_row($result); $exist = count($row); if($exist >=2) { session_start(); $_SESSION['user'] = $row['username']; $_SESSION['id'] = $row['id']; $this->jscript_location(); } else { $this->notify_show();} exit; } } but did not get there values, it sets empty session variables.
  21. hi all , i am working on a script which is oop driven and i m not much familiar with it, i appericiate if someone can help me to solve this problem , so basicaly current script is only setting one session variable to true if user login $_SESSION['is_successful_login'] , here is my code <?php include('files/db.php'); class ajaxLoginModule { private $timeout = null; private $target_element = null; private $wait_text = null; private $form_element = null; private $wait_element = null; private $notify_element = null; function __construct() { include ('config.php'); $msql = new Db; $msql->connect(); $this->is_login(); } function get_config() { $this->set_ajax_config(); } function set_ajax_config() { $this->timeout = AJAX_TIMEOUT; $this->target_element = AJAX_TARGET_ELEMENT; $this->wait_text = AJAX_WAIT_TEXT; $this->wait_element = AJAX_WAIT_ELEMENT; $this->notify_element = AJAX_NOTIFY_ELEMENT; $this->form_element = AJAX_FORM_ELEMENT; } function initLogin($arg = array()) { $this->get_config(); $this->login_script(); } function initJquery() { return "<script type='text/javascript' src='files/jquery-1.3.2.min.js'></script>"; } function login_script() { include ('files/login_script.php'); } function is_login() { if(isset($_POST['username'])) { $username = $_POST['username']; $password = $_POST['password']; $strSQL = "SELECT * FROM ".USERS_TABLE_NAME." WHERE username ='$username' AND password = '$password' "; $result = mysql_query ($strSQL); $row = mysql_fetch_row($result); /* //THIS IS WHAT I NEED $_SESSION['user'] = $row['username']; $_SESSION['id'] = $row['id']; */ $exist = count($row); if($exist >=2) { $this->jscript_location(); } else { $this->notify_show();} exit; } } function notify_show() { echo "<script>$('.".AJAX_NOTIFY_ELEMENT."').fadeIn();</script>"; } function jscript_location() { $this->set_session(); echo "<script> $('#container').fadeOut();window.location.href='".SUCCESS_LOGIN_GOTO."'</script>"; } function set_session() { session_start(); $_SESSION['is_successful_login'] = true; } } ?> i comment that line what i need is username and id to store in those session variables $_SESSION['user'] = $row['username']; $_SESSION['id'] = $row['id'] i tried to add code in function set_session but did not helped, appreciate for any help. Thanks
  22. plz anyone know something about it? thx for any suggestion
×
×
  • 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.