Jump to content

guymclarenza

Members
  • Content Count

    53
  • Joined

  • Last visited

Community Reputation

2 Neutral

About guymclarenza

  • Rank
    Regular Member

Contact Methods

  • Website URL
    https://imagimedia.co.za

Profile Information

  • Gender
    Male
  • Location
    Nelspruit, South Africa
  • Interests
    Travel, Bikes, Cars, Books, Learning, Wood, Dad stuff
  • Age
    55
  1. public function getFaq($site) { $sql = "SELECT faq_cats.faqc_name, faqs.faq_id, faqs.faq_question, faqs.faq_answer FROM faq_cats INNER JOIN faqs ON faq_cats.faqc_id = faqs.faq_cat WHERE faq_cats.faqc_site = ? ORDER BY faq_cats.faqc_name"; $stmt = $this->connect()->prepare($sql); $stmt->execute([$site]); $fcid = $stmt->fetchAll(); $fhead = null; $findex = null; $fcont = null; echo "<h1>FAQ Index</h1>"; foreach ($fcid as $faq) { $fname = $faq["faqc_name"]; $fquest = $faq["faq_question"]; $fans = $faq["faq_answer"]; $faid
  2. This does not work public function getFaq($site) { $sql = "SELECT faq_cats.faqc_name, faqs.faq_question, faqs.faq_answer FROM faq_cats INNER JOIN faqs ON faq_cats.faqc_id = faqs.faq_cat WHERE faq_cats.faqc_site = ? ORDER BY faq_cats.faqc_name"; $stmt = $this->connect()->prepare($sql); $stmt->execute([$site]); $fcid = $stmt->fetchAll(); $fhead = null; foreach ($fcid as $faq) { $fname = $faq["faqc_name"]; $fquest = $faq["faq_question"]; $fans = $faq["faq_answer"]; $fcont = null; if ($fhead != $fname) { $fcont .= "<h
  3. I want to reuse the data from getFaq for different levels of a website. $fcid is the variable. Creating the full page in the getFaq function could work but limits the function to one set of results, Do I need to create a new function if I want to create another page with the data and a new call to the database? It seems to me there must be a way to store the array from $fcid and call it from another page to get a subset of the data. I added the getFP class as an attempt to do just that but I am getting no results. If I place the code in the getFP class in
  4. foreach ($table as $table) is the line that contains the faq variable in the code, I replaced it with table to anonymise my code.
  5. I am testing some new code, trying to learn me some OOP. I know the SQL works because I tested it in phpmyadmin. There is something wrong and I cannot fathom why, <? $site= '15'; Class Dbh { private $user='xxx'; private $pass='xxx'; private $db='xxx'; private $host='localhost'; private $charset = 'utf8mb4'; protected function connect() { $dsn = 'mysql:host='.$this->host.'; dbname='.$this->db.';charset='.$this->charset; $pdo = new PDO($dsn, $this->user, $this->pass); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); $pdo-
  6. Should I keep this thread open if I have more questions? or should I start a new thread for my next issues?
  7. I am able to order the rows by the field required $sql = "SELECT table_cats.tablec_name, tables.table_question, tables.table_answer FROM table_cats INNER JOIN tables ON table_cats.tablec_id = tables.table_cat WHERE table_cats.tablec_site = ? ORDER BY table_cats.tablec_name"; $stmt = $this->connect()->prepare($sql); $stmt->execute($site); $fcid = $stmt->fetchAll(); foreach ($table as $table) { $fcat = $table["tablec_name"]; $fquest = $table["table_question"]; $fans = $table["table_answer"]; } , My HTML is not too crap, been doing it for a while
  8. Just one more question, would it be better to use the loops on the page that is viewed or hide them in the functions? In the example above I have one row, In another I have multiple rows dependant on information from a different query. example. for each Get id, name from table idvar echo name Get field1, field2 from anothertable where field3 = idvar for each echo field1 and field 2 I am thinking that an SQL statement inner joining the two tables and grouping them by table.name may be a more elegant solution, yet I am not sure how not to repeat table.name on every itera
  9. Thank you, That was what I thought but was unsure about how to access the data without a loop. I am busy rebuilding an old package as OOP to improve it. The original works but I am concerned about security even though I have updated to PDO. I figure the more secure the better. It's just that sometimes this old brain of mine finds some concepts difficult.
  10. I haven't tested yet, It was a general question about coding practice. Is it as simple as not looping it?
  11. I know this function will get one result, I suspect foreach is the wrong loop to use, should I be using a loop at all? Can someone correct me please. public function getSites($site) { $sql = "SELECT * FROM website WHERE website_id = ?"; $stmt = $this->connect()->prepare($sql); $stmt->execute($site) $siten = $stmt->fetch(); foreach ($siten as $row) { $title = $row["website_title"]; $wname = $row["website_name"]; $image1 = "header.jpg"; $metadesc = $row["website_description"]; $wurl = $row["website_url"]; $gtag = $row["website_gtag"]; $gm
  12. The problems as I see them are as follows. It crawls a page, gets links, then has to discard duplicates, I think the hold up is there. I am removing duplicates after fixing the url, maybe it would be better to strip out all duplicates before "fixing" the url. To get 50 results, it is crawling and doing the whole process on 50 pages Does this make sense. follow links. add links to array remove duplicates fix links echo links repeat at present the logic is follow links fix links remove duplicates echo links repeat
×
×
  • 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.