Jump to content

Search the Community

Showing results for tags 'php'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. Hi I'm trying to find some code that would tell the bit of code that I created what the device width is so I can make this navigation menu dynamic. Meaning: if the device width is 480px and the navigation menu would come to 1024px then using PHP the code would automatically put the <li> items in to a more tab untill the the width is equal or less than 480px. I don't want to use Javascript to do this as I know most of you will recommend using..... Here's my code. Change the variable $deviceWidth to and refresh.... change between 1 and 10. <? $navItems = array("ME", "MUSIC", "VIDEO", "GIGS", "FESTIVALS", "CONTACT"); $deviceWidth = 3; $diffrence = count($navItems) - $deviceWidth; while($diffrence > 0){ $more[] = array_pop($navItems); $diffrence = $diffrence - 1; } foreach($navItems as $nav){ $lower = strtolower($nav); $upper = strtoupper($nav); $lower1 = strtolower($more); $upper1 = strtoupper($more); echo"<li class='Nav'><a href='$lower.php'>$upper</a></li>"; } if(!empty($more)){ echo"<li class='Nav-more'><a href='#'>MORE</a> <ul class='more'>"; foreach($more as $more){ $lower1 = strtolower($more); $upper1 = strtoupper($more); echo "<li class='Nav-more'><a href='$lower1.php'>$upper1</a></li>"; } echo"</ul> </li>"; } ?> And the CSS to give an example. .Navigation { background-image:url(images/H_BG.png); background-repeat:repeat-x; width:100px; height:50px; } .Nav-bar { background-image:url(images/H_BG.png); background-repeat:repeat-x; width:90%; min-width:700px; _width:700px; font-size:20px; line-height:40px; margin-left:5%; margin-right:5%; height:50px; } ul.Nav { list-style:none; margin:0px; padding:0px; } ul.Nav li { font-weight:20; display:inline; } ul.Nav li a { font-weight:bold; text-decoration: none; float: left; color:#7D7D7D; border-left:1px solid #D1D1D1; padding:5px; padding-left:10px; padding-right:10px; } ul.Nav li a:hover { background-image:url(images/H_BG2.png); background-repeat:repeat-x; font-weight:bold; text-decoration: none; float: left; } ul.more { display:none; } ul.Nav li.Nav-more:hover ul.more { display:block; font-weight:bold; text-decoration: none; float: left; color:#111; border-left:1px solid #0f0; padding:5px; padding-left:10px; padding-right:10px; }
  2. <body> <div class="header"> <?php include('navbar.php'); ?> </div> <div class="container"> <div class="row mt-4"> <div class="col-sm-3"> <p>Patient Name :</p> </div> <div class="col-sm-3"> <p><?php echo $_POST['name']; ?></p> </div> </div> <div class="row" id="fir"> <div class="col-sm-3"> <p>UHID :</p> </div> <div class="col-sm-3"> <p><?php echo $_POST['id']; ?></p> </div> </div> <?php $_SESSION['p_name'] = $_POST['name']; $_SESSION['p_id'] = $_POST['id']; ?> <form action="personal_medical_record_download.php" method="POST"> <div class="form-header mt-4 text-center">Medical Record</div> <div class="card"> <div class="card-header"> <h2>Any Allergies</h2> </div> <div class="card-body"> <?php $uhid = $_SESSION['p_id']; $conn = mysqli_connect("127.0.0.1", "root", "iMpAcTHeaLTH7%", 'threephih'); $query = " Select * from allergies where uhid = '$uhid' "; $query_res = mysqli_query($conn, $query); while ($query_run = mysqli_fetch_array($query_res)) { ?> <div class="form-group"> <label for="1">1. Are you allergic to any substance?</label> <p style="margin-left: 25px"><?php echo $query_run['ques_1']; ?></p> </div> <div class="form-group"> <label for="2">2. What happened to you when you took this substance?</label> <p style="margin-left: 25px"><?php echo $query_run['ques_2']; ?></p> </div> <div class="form-group"> <label for="3">3. When was this reaction?</label> <p style="margin-left: 25px"><?php echo $query_run['ques_3']; ?></p> </div> <div class="form-group"> <label for="4">4. Since when have you taken that substance?</label> <p style="margin-left: 25px"><?php echo $query_run['ques_4']; ?></p> </div> <div class="form-group"> <label for="5">5. Any other kind of allergies?</label> <p style="margin-left: 25px"><?php echo $query_run['ques_5']; ?></p> </div> <?php } ?> </div> </div> <div class="submit-button mt-4 text-center"> <button type="submit" value="Pdf" name="pdf">PDF</button> </div> </form> </div> </body> I'm trying to show that "No records" message when there are no data in sql table but if there is data then go to the pdf page. please help me
  3. I am using parent::__construct() in almost every classes to connect Mysql DB. Example class class secondClass extends dbconnect { public function __construct() { parent::__construct(); dbconnect class class dbconnect { private $mysqli_handler; public function __construct() { try { mysqli_report(MYSQLI_REPORT_STRICT); $this->mysqli_handler = mysqli_connect(DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DBNAME); } catch (mysqli_sql_exception $e) { throw new Exception('Error: Could not make a database link using ' . DB_USERNAME . '@' . DB_HOSTNAME . '!'); } if ($this->mysqli_handler->connect_error) { trigger_error('Error: Could not make a database link (' . $this->mysqli_handler->connect_errno . ') ' . $this->mysqli_handler->connect_error); } $this->mysqli_handler->query("SET NAMES 'utf8'"); $this->mysqli_handler->query("SET CHARACTER SET utf8"); $this->mysqli_handler->query("SET CHARACTER_SET_CONNECTION=utf8"); $this->mysqli_handler->query("SET SQL_MODE = ''"); $this->mysqli_handler->query("SET time_zone = 'Asia/Kolkata'"); } Is this create multiple instance of mysql dbconnection? I am frequently getting mysql connection error on my shared hosting. If so how to avoid? I am using PHP Version 7.4.16, some detailed explanation will be useful for me as I am using like this for many projects. Thank you for your time. Prabakaran
  4. Just another usefull tool id like to share for WordPress, To start my DigitalDev community of free and paid PHP plugins/scripts i am trying not to download other peoples plugins for quickness, i would much rather build my own tool for whatever function i need and share turn it into a project and share it. WPTimeTracker is just a small tool to track tasks and my time, users in WP can create tasks and clock in/out with timers to record your time and assign it to tasks, so we can see how long we worked on our projects, future features will include a timecaqrd where you can assign multiple tasks(and there time records) to create a complete "overall" project time cart, it will allow you to export PDF of all the tasks and time taken on a given project. You can help me by using (beta testing) the plugin and give me your feedback and future feature suggestions, this would be much appreciated, because i build the tool for myself i often miss out on neat features you might like to see in the applications so please share your ideas.
  5. I am creating a recently viewed article index for my PHP/MYSQL forum script that will store recently viewed articles that a user may have forgoten to bookmark. This way the Web site will be able to remember which articles they read and present a list. To remember which documents have been read by a given user, i am identifying each user and each document by a unique identifier.For the user, the session ID satisfies this requirement. I have got the script working but the viewed list is not incrementing, rather a new viewed article always overwrites the old one. What i want to create is a list of all articles read. My code is below: topic.php session_start() // database connection //Extract articles from database for display on the topics page $_SESSION['post']=array(); //create an array to hold read articles // Add article title and link to list $PostLink = "<a href='topic.php?topic={$topic}'>{$topic}</a>"; if (! in_array($PostLink, $_SESSION['post'])){ $_SESSION['post'][] = $PostLink;} // Output list of requested articles this bit of code is to be place in the sidebar if(isset($_SESSION['post'])){ echo "<p>Recently Viewed Articles</p>"; echo "<ul>"; foreach($_SESSION['post'] as $doc) { echo "<li>$doc</li>"; } echo "</ul>";} Any thoughts on how i may achieve this
  6. I'm facing some issue adding noindex header tag to my robots txt file. So, I'm using plugin called rankmath on a website to manage my robots.txt file. I want search engine not to index my robots txt file. Below is the php code. <?php /** * The robots.txt editor module. * * @since 0.9.0 * @package RankMath * @subpackage RankMath * @author Rank Math <support@rankmath.com> */ namespace RankMath; use RankMath\Helper; use RankMath\Traits\Hooker; use MyThemeShop\Helpers\Arr; use MyThemeShop\Helpers\WordPress; defined( 'ABSPATH' ) || exit; /** * Robots_Txt class. */ class Robots_Txt { use Hooker; /** * Class constructor. */ public function __construct() { if ( is_super_admin() ) { $this->filter( 'rank_math/settings/general', 'add_settings' ); } // Custom robots text. if ( ! is_admin() && Helper::get_settings( 'general.robots_txt_content' ) ) { $this->action( 'robots_txt', 'robots_txt', 10, 2 ); } } /** * Replace robots.txt content. * * @param string $content Robots.txt file content. * @param bool $public Whether the site is considered "public". * * @return string New robots.txt content. */ public function robots_txt( $content, $public ) { return 0 === absint( $public ) ? $content : Helper::get_settings( 'general.robots_txt_content' ); } /** * Add module settings into general optional panel. * * @param array $tabs Array of option panel tabs. * * @return array */ public function add_settings( $tabs ) { Arr::insert( $tabs, [ 'robots' => [ 'icon' => 'rm-icon rm-icon-robots', 'title' => esc_html__( 'Edit robots.txt', 'rank-math' ), /* translators: Link to kb article */ 'desc' => sprintf( esc_html__( 'Edit your robots.txt file to control what bots see. %s.', 'rank-math' ), '<a href="' . KB::get( 'edit-robotstxt' ) . '" target="_blank">' . esc_html__( 'Learn more', 'rank-math' ) . '</a>' ), 'file' => dirname( __FILE__ ) . '/options.php', 'classes' => 'rank-math-advanced-option', 'after_row' => '<div class="rank-math-desc">' . __( 'Leave the field empty to let WordPress handle the contents dynamically. If an actual robots.txt file is present in the root folder of your site, this option won\'t take effect and you have to edit the file directly, or delete it and then edit from here.', 'rank-math' ) . '</div>', ], ], 5 ); return $tabs; } /** * Get robots.txt related data: whether the file exists, the contents * of the file, and the "Search engine visibility" setting for the site. * * @return array */ public static function get_robots_data() { $wp_filesystem = WordPress::get_filesystem(); $public = absint( get_option( 'blog_public' ) ); $default = '# This file is automatically added by Rank Math SEO plugin to help a website index better'; $default .= "\n# More info: https://s.rankmath.com/home\n"; $default .= "User-Agent: *\n"; if ( 0 === $public ) { $default .= "Disallow: /\n"; } else { $default .= "Disallow: /wp-admin/\n"; $default .= "Allow: /wp-admin/admin-ajax.php\n"; } $default = apply_filters( 'robots_txt', $default, $public ); if ( empty( $wp_filesystem ) || ! Helper::is_filesystem_direct() ) { return [ 'exists' => false, 'default' => $default, 'public' => $public, 'writable' => false, ]; } if ( $wp_filesystem->exists( ABSPATH . 'robots.txt' ) ) { return [ 'exists' => true, 'noindex' => true, 'default' => $wp_filesystem->get_contents( ABSPATH . 'robots.txt' ), 'public' => $public, ]; } return [ 'exists' => false, 'default' => $default, 'public' => $public, ]; } }
  7. Basically I created a leapyear calculator, but to improve user experience i want it to display a message on the webpage confirming whether or not the year entered is a leapyear without changing the webpage. However I keep getting '1 is not leap year' regardless of the the year I enter. What am I doing wrong? <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>Leap year form</title> </head> <body> <?php $year = isset($_GET["leapyear"]); function is_leapyear($year){ if(is_numeric($year)){ if($year%4 ==0) if($year%100 ==0) if($year%400 ==0){ return true; } return false; } } if (isset($_GET["confirm"])){ if (is_leapyear($year)){ echo'<span style="color:#008631;">'; echo"$year is a leap year</span>"; } else { echo'<span style="color:#FF0000;">'; echo "$year is not a leap year</span>"; } } ?> <h1>Leap Year</h1> <form action = "leapyear_selfcall.php" method = "get" > <label for="leapyear">Enter a year</label> <input type="text" name="leapyear"/> <p><input type="submit" name="confirm" value="Check For Leap Year"/></p> </form> </body> </html>
  8. Hello, i'm currently developing a website using laravel. I have added a 3 new columns for bravo_book_others table the columns are other_name, gender, and other_address. I have a case like this : User1 want to buy 4 holiday package for user1 friends, so user1 have to input 3 of user1 friends like this : Gender#1 : male Name#1 : a Email#1 : a@gmail.com Address#1 : a street Gender#2 : female Name#2 : b Email#2 : b@gmail.com Address#2 : b street Gender#3 : male Name#3 : c Email#3 : c@gmail.com Address#3 : c street I already done it with the email in the controller like this : foreach ($request->input('other_emails') as $email){ BookOther::create([ 'booking_id'=>$booking->id, 'user_id'=>$booking->customer_id, 'other_emails'=>$email ]); Mail::to($email)->send(new OthersEmail($isi_email1)); } How can i put the other_name, gender, and other_address and store it into the database?? The Model : class BookOther extends Model { use HasFactory; protected $table = 'bravo_book_others'; protected $fillable = [ 'booking_id', 'user_id', 'gender', 'other_name', 'other_address', 'other_emails' ]; public function booking(){ return $this->belongsTo('Modules\Booking\Models\Booking', 'booking_id', 'id'); } public function user(){ return $this->belongsTo('App\User', 'user_id', 'id'); } } The Controller : foreach ($request->input('other_emails') as $email){ BookOther::create([ 'booking_id'=>$booking->id, 'user_id'=>$booking->customer_id, 'other_emails'=>$email ]); Mail::to($email)->send(new OthersEmail($isi_email1)); }
  9. I have screwed up my code, was working but copied wrong file and was running incorrect file. Basically it appears to work and runs without error, but it should print the verse I have chosen but prints 'You have selected an invalid Verse. Please try again' which is an error message in the file Prnpdf.php. My conclusion is therefore that the session is not passing the data from the previous file, varinput.pdf, but the file that I messed up as the one called varinput.php and all the other files are the original files, so I can't see why it is not working! Is there something wrong with the session in that file? The sequence of the files running is as follows: vinput.php -> vquery.php -> varinput.php -> prnpdf.php -> fpdf.php vinput.php <!DOCTYPE html> <html lang="en-GB"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width,initial-scale=1"> <meta name="generator" content="RSD 5.0.3519"> <meta name="description" content="Created by Inger Eik, Dec. 2021"> <title>Verse Input</title> <link rel="stylesheet" href="css/bootstrap4.min.css"> <link rel="stylesheet" href="css/wireframe-theme.min.css"> <script>document.createElement( "picture" );</script> <script class="picturefill" async="async" src="js/picturefill.min.js"></script> <link rel="stylesheet" href="css/main.css"> <style> /* Interaction Elements */ a.link-button.button-link-1 { margin-right: 5px; margin-bottom: 5px; margin-left: 5px; padding-top: 4px; width: 120px; height: auto; border: .0625rem solid rgba(255, 255, 255, .5); background-color: #0f0e14; color: #fff; text-align: center; text-decoration: none; line-height: 22px; } select.select.dd-fc { margin-right: 5px; margin-bottom: 5px; margin-left: 5px; padding-top: 5px; padding-bottom: 3px; width: 120px; border-color: rgba(255, 255, 255, .5); background-color: #0f0e14; color: #fff; opacity: .98; } .container-grid.dropdown-menubar { position: absolute; top: auto; bottom: 0; display: -webkit-box; display: -webkit-flex; display: -moz-box; display: -ms-flexbox; display: flex; -ms-flex-pack: center; margin-right: 0; margin-left: 0; padding-top: 10px; padding-bottom: 5px; max-width: 1200px; width: 100%; background-color: #0f0e14; -webkit-box-pack: center; -webkit-justify-content: center; -moz-box-pack: center; justify-content: center; -webkit-flex-wrap: wrap; -ms-flex-wrap: wrap; flex-wrap: wrap; } @media screen and (min-width: 75rem) { /* Interaction Elements */ a.link-button.button-link-1 { height: auto; } } option:first-child { display:none; } </style> </head> <body> <div class="outer-limit container-grid"> <div class="header container-grid"> <div class="header-inner container-grid"></div> <div class="dropdown-menubar container-grid"> <?php include("inc/menu.php"); ?> </div> </div> <h1 class="heading-5">1066 Card Craft</h1> <div class="content container-grid"> <div class="aside container-grid"> <div class="responsive-picture"> <picture> <img alt="Placeholder Picture" width="485" height="477" src="./img/writing.jpg" loading="lazy"> </picture> <?php include("inc/aside-verse.php"); ?> </div> </div> <div class="main container-grid"> <?php include ("cons/connect_Verses4Cards.php"); $conn = get_db_conn_verse(); //Function to build select options based on passed array function buildSelectOptions($name, array $options, $current=null){ $htmlString = "<select name='{$name}' id='{$name}'>\n"; foreach($options as $value=>$option){ $htmlString .= "\t<option value='{$value}'"; if($value == $current){ $htmlString .= " selected"; } $htmlString .= ">{$option}</option>\n"; } $htmlString .= "</select>\n"; return $htmlString; } function getEvents($conn){ $qry = "SELECT id ,Event_Type FROM Events ORDER BY id"; $sql = mysqli_query($conn, $qry)or die(mysqli_error($conn)); if(mysqli_num_rows($sql) < 1){ return array(); } while($res1 = mysqli_fetch_array($sql)){ $ret1[$res1['id']] = $res1['Event_Type']; } return $ret1; } function getMoods($conn){ $qry = "SELECT id ,Event_Sub_Type FROM Event_Sub ORDER BY id"; $sql = mysqli_query($conn, $qry)or die(mysqli_error($conn)); if(mysqli_num_rows($sql) < 1){ return array(); } while($res2 = mysqli_fetch_array($sql)){ $ret2[$res2['id']] = $res2['Event_Sub_Type']; } return $ret2; } ?> <h3>Choose Your Verse Options</h3> <br></br> <!-- Start of FORM --> <form action="vquery.php" method="post"> <?php echo buildSelectOptions('event', getEvents($conn), 1);?> <?php echo buildSelectOptions('mood', getMoods($conn), 1);?> <input type="submit" value="submit" /> </form> <!-- End of FORM --> </div> </div> <div class="footer container-grid"> <?php include("inc/footer.php"); ?> </div> </div> <script src="js/jquery.min.js"></script> <script src="js/outofview.js"></script> <script src="js/popper.min.js"></script> <script src="js/bootstrap.min.js"></script> </body> </html> vquery.php <!DOCTYPE html> <html lang="en-GB"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width,initial-scale=1"> <meta name="generator" content="RSD 5.0.3519"> <meta name="description" content="Created by Inger Eik, Dec. 2021"> <title>Verse Query</title> <link rel="stylesheet" href="css/bootstrap4.min.css"> <link rel="stylesheet" href="css/wireframe-theme.min.css"> <script>document.createElement( "picture" );</script> <script class="picturefill" async="async" src="js/picturefill.min.js"></script> <link rel="stylesheet" href="css/main.css"> <?php include_once("cons/connect_Verses4Cards.php"); $conn=get_db_conn_verse(); $display_block =""; //check for required info from the query string //verify the Event exists $verify_Event_sql = "SELECT ID, Event_Type FROM Events WHERE ID = '".$_POST["event"]."'"; $verify_Event_res = mysqli_query($conn, $verify_Event_sql) or die(mysqli_error($conn)); if (mysqli_num_rows($verify_Event_res) < 1) { //this Event does not exist $display_block = "<p><em>You have selected an invalid Event.<br/> Please try again.</em></p>"; } else { //get the Event ID while ($Event_info = mysqli_fetch_array($verify_Event_res)) { $Event_ID = stripslashes($Event_info['ID']); $Event_Name = ($Event_info['Event_Type']); } $verify_Mood_sql = "SELECT ID, Event_Sub_Type FROM Event_Sub WHERE ID = '".$_POST["mood"]."'"; $verify_Mood_res = mysqli_query($conn, $verify_Mood_sql) or die(mysqli_error($conn)); if (mysqli_num_rows($verify_Mood_res) < 1) { //this Event does not exist $display_block = "<p><em>You have selected an invalid Mood.<br/> Please try again.</em></p>"; } while($Mood_info = mysqli_fetch_array($verify_Mood_res)) { $Mood_ID = ($Mood_info['ID']); $Mood_Name = ($Mood_info['Event_Sub_Type']); } //gather the Events $get_Event_sql = "SELECT verses.ID AS versesID, verses.Verse, verses.Sub_Type, verses.Event, Events.ID AS eventsID, Events.Event_Type, Event_Sub.ID AS event_SubID, Event_Sub.Event_Sub_Type FROM verses LEFT JOIN Events ON verses.Event = Events.ID LEFT JOIN Event_Sub ON verses.Sub_Type = Event_Sub.ID WHERE verses.Event = '".$_POST["event"]."' And verses.Sub_Type = '".$_POST["mood"]."' ORDER BY verses.ID ASC"; $get_Event_res = mysqli_query($conn, $get_Event_sql) or die(mysqli_error($conn)); //create the display string $display_block .= " <table width=\"90%\" cellpadding=\"3\" cellspacing=\"1\" border=\"1\" BGCOLOR=\"white\" > <tr> <th>ID</th> <th>VERSE</th> <th>MOOD/SUB TYPE</th> <th>CHOOSE</th> </tr>"; while ($Verse_info = mysqli_fetch_array($get_Event_res)) { $Verse_id = $Verse_info['versesID']; $Verse_text = nl2br(stripslashes($Verse_info['Verse'])); $Mood_info = $Verse_info['Event_Sub_Type']; $VID = $Verse_id; //add to display $display_block .= " <tr> <td width=\"1%\" valign=\"top\">".$Verse_id."<br/></td> <td width=\"55%\" valign=\"top\">".$Verse_text."<br/></td> <td width=\"35%\" valign=\"top\">" .$Mood_info."<br/></td> <td width=\"35%\" valign=\"middle\"> <form METHOD=\"POST\" ACTION=\"varInput.php\"> <input type=\"Radio\" name=\"VID\" value=$VID ></td> </tr>"; } $display_block.="<input type=submit value=Submit> </form>"; //free results mysqli_free_result($get_Event_res); mysqli_free_result($verify_Event_res); //close up the table $display_block .="</table>"; } ?> <style> /* Interaction Elements */ a.link-button.button-link-1 { margin-right: 5px; margin-bottom: 5px; margin-left: 5px; padding-top: 4px; width: 120px; height: auto; border: .0625rem solid rgba(255, 255, 255, .5); background-color: #0f0e14; color: #fff; text-align: center; text-decoration: none; line-height: 22px; } select.select.dd-fc { margin-right: 5px; margin-bottom: 5px; margin-left: 5px; padding-top: 5px; padding-bottom: 3px; width: 120px; border-color: rgba(255, 255, 255, .5); background-color: #0f0e14; color: #fff; opacity: .98; } .container-grid.dropdown-menubar { position: absolute; top: auto; bottom: 0; display: -webkit-box; display: -webkit-flex; display: -moz-box; display: -ms-flexbox; display: flex; -ms-flex-pack: center; margin-right: 0; margin-left: 0; padding-top: 10px; padding-bottom: 5px; max-width: 1200px; width: 100%; background-color: #0f0e14; -webkit-box-pack: center; -webkit-justify-content: center; -moz-box-pack: center; justify-content: center; -webkit-flex-wrap: wrap; -ms-flex-wrap: wrap; flex-wrap: wrap; } @media screen and (min-width: 75rem) { /* Interaction Elements */ a.link-button.button-link-1 { height: auto; } } option:first-child { display:none; } </style> </head> <body> <div class="outer-limit container-grid"> <div class="header container-grid"> <div class="header-inner container-grid"></div> <div class="dropdown-menubar container-grid"> <?php include("inc/menu.php"); ?> </div> </div> <h1 class="heading-5">1066 Card Craft</h1> <div class="content container-grid"> <div class="aside container-grid"> <div class="responsive-picture"> <picture> <img alt="Placeholder Picture" width="485" height="477" src="./img/writing.jpg" loading="lazy"> </picture> <?php include("inc/aside-verse.php"); ?> </div> </div> <div class="main container-grid"> <h2 class="heading-2">Your Verse Query</h2> <main class="container-grid"> <?php if(isset($display_block)){ echo $display_block;}?> </main> </div> </div> <div class="footer container-grid"> <?php include("inc/footer.php"); ?> </div> </div> <script src="js/jquery.min.js"></script> <script src="js/outofview.js"></script> <script src="js/popper.min.js"></script> <script src="js/bootstrap.min.js"></script> </body> </html> varinput.php <!DOCTYPE html> <html lang="en-GB"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width,initial-scale=1"> <meta name="generator" content="RSD 5.0.3528"> <meta name="description" content="Created by Inger Eik, Dec. 2021"> <title>Input Page</title> <link rel="stylesheet" href="css/bootstrap4.min.css"> <link rel="stylesheet" href="css/wireframe-theme.min.css"> <script>document.createElement( "picture" );</script> <script class="picturefill" async="async" src="js/picturefill.min.js"></script> <link rel="stylesheet" href="css/main.css"> <style> /* Interaction Elements */ a.link-button.button-link-1 { margin-right: 5px; margin-bottom: 5px; margin-left: 5px; padding-top: 4px; width: 120px; height: auto; border: .0625rem solid rgba(255, 255, 255, .5); background-color: #0f0e14; color: #fff; text-align: center; text-decoration: none; line-height: 22px; } select.select.dd-fc { margin-right: 5px; margin-bottom: 5px; margin-left: 5px; padding-top: 5px; padding-bottom: 3px; width: 120px; border-color: rgba(255, 255, 255, .5); background-color: #0f0e14; color: #fff; opacity: .98; } .container-grid.dropdown-menubar { position: absolute; top: auto; bottom: 0; display: -webkit-box; display: -webkit-flex; display: -moz-box; display: -ms-flexbox; display: flex; -ms-flex-pack: center; margin-right: 0; margin-left: 0; padding-top: 10px; padding-bottom: 5px; max-width: 1200px; width: 100%; background-color: #0f0e14; -webkit-box-pack: center; -webkit-justify-content: center; -moz-box-pack: center; justify-content: center; -webkit-flex-wrap: wrap; -ms-flex-wrap: wrap; flex-wrap: wrap; } @media screen and (min-width: 75rem) { /* Interaction Elements */ a.link-button.button-link-1 { height: auto; } } option:first-child { display:none; } </style> </head> <body> <div class="outer-limit container-grid"> <div class="header container-grid"> <div class="header-inner container-grid"></div> <div class="dropdown-menubar container-grid"> <?php include("inc/menu.php"); ?> </div> </div> <h1 class="heading-5">1066 Cards 4 U</h1> <div class="content container-grid"> <div class="aside container-grid"> <?php include("inc/aside.php"); ?> </div> <div class="main container-grid"> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="generator" content="RSD 5.0.3519"> <title>VInput1</title> <link rel="stylesheet" href="css/bootstrap4.min.css"> <link rel="stylesheet" href="css/wireframe-theme.min.css"> <script>document.createElement( "picture" );</script> <script class="picturefill" async="async" src="js/picturefill.min.js"></script> <link rel="stylesheet" href="css/main.css"> </head> <body> <div class="container-grid container-2"></div> <div class="container-grid main"> <?php session_start(); $_SESSION['test']=$_POST['VID']; include("cons/connect_Verses4Cards.php"); $conn=get_db_conn_verse(); $display_block =""; $CardSz =""; $Card_info['Size']=""; $Card_info['Narative']=""; //Function to build select options based on passed array $CardSz = array($Card_info['Size'], $Card_info['Narative']); buildSelectOptions($CardSz); function buildSelectOptions($options) { $optionsHTML = "<select name=\"CSize\">\r\n"; foreach($options as $id => $label) { $optionsHTML .= "<option value='{$id}'>{$label}</option>\n"; } return $optionsHTML; } //Run query to get the ID and Name from the table //Then populate into an array $clist_sql = "SELECT * FROM CSize ORDER BY GP"; $clist_res= mysqli_query($conn, $clist_sql) or die(mysqli_error($conn)); if (mysqli_num_rows($clist_res) < 1) { //this Card does not exist $display_block = "<p><em>You have selected an invalid Country.<br/> Please try again.</em></p>"; } $CardSz = array(); while($Card_info = mysqli_fetch_array($clist_res)) { $CardSz[$Card_info['Size']] = $Card_info['Narative']; } $CardOptions = buildSelectOptions($CardSz); ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta name="keywords" content="" /> <meta name="description" content="On this page the user choose the variables to align the verse on the paper" /> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>1066 Cards 4U - Variable Input Form</title> <link href="style.css" rel="stylesheet" type="text/css" media="screen" /> </head> <body> <div id="wrapper"> <div id="menu"> <ul> <div id="content"> <h1>Card Variable Input Form</h1> <form name="Lists" action="Prnpdf.php" method="post"> <p><strong>Card Size</strong></p> <select name="CSize"> <option value= "<?php echo $CardOptions;?>" </option> </select> <br/> <p><strong>Input Distance from top in mm:</strong> <input type="number" name="Top" value="50" min="20" max="200"/></p><br/> <p><strong>Input Font size in points:</strong> <select name="font"> <option value="18" > 18 point</option> <option value="20" > 20 point</option> <option value="22" > 22 point</option> <option value="24" selected="selected" > 24 point</option> <option value="26" > 26 point</option> <option value="28" > 28 point</option> <option value="30" > 30 point</option> <option value="32" > 32 point</option> </select></p><br/> <p><strong>Text Colour</strong></p> <select name="color"> <option value="000000000" > Black</option> <option value="255215000" > Gold</option> <option value="192192192" > Silver</option> <option value="255000000" > Red</option> <option value="000255000" > Green</option> <option value="000000255" > Blue</option> <option value="255195203" > Pink</option> <option value="132112255" > Slate Blue</option> <option value="128000128" > Purple</option> <option value="168099030" > Brown</option> </select><br/> <p><strong>Text Font</strong></p> <select name="fontface"> <option value="French Script MT" > French Script MT</option> <option value="Batavia" > Batavia </option> <option value="Algerian" > Algerian </option> <option value="Bladerunner" > Bladerunner </option> <option value="Brush Script" > Brush Script</option> <option value="Helterskelter" > Helterskelter</option> <option value="Justice" > Justice</option> <option value="Magneto" > Magneto</option> <option value="Old English" > Old English</option> <option value="Sneakerhead Outline" > Sneakerhead Outline</option> <option value="Trendy" > Trendy</option> <option value="Vladimir Script" > Vladimir Script</option> </select><br/> <p><strong>Border Images </strong></p> <select name="image"> <option value="images/empty.jpg" selected="selected"> No Border</option> <option value="images/Border10p.jpg" > Rose Border - Portrait</option> <option value="images/Border2p.jpg" > Chequered Border - Portrait</option> <option value="images/Border11p.jpg" > Ribbon Border - Portrait</option> <option value="images/Border5p.jpg" > Yellow Border - Portrait</option> <option value="images/Corner2p.jpg" > Leaf Corners - Portrait</option> <option value="images/corner1p.jpg" > Laurel Corners - Portrait</option> <option value="images/Border12P.jpg" > Holly Corner - Portrait</option> <option value="images/116070.jpg" > Ornate -Portrait</option> <option value="images/116122.jpg" > Ornate2 -Portrait</option> <option value="images/Border10l.jpg" > Rose Border -Landscape </option> <option value="images/Border2l.jpg" > Chequered Border -Landscape</option> <option value="images/Border11l.jpg" > Ribbon Border -Landscape</option> <option value="images/Border5l.jpg" > Yellow Border -Landscape</option> <option value="images/Corner2l.jpg" > Leaf Corners -Landscape</option> <option value="images/corner1l.jpg" > Holly Corner -Landscape</option> <option value="images/Border12L.jpg" > Yellow Border -Landscape</option> <option value="images/Holly1.jpg" > Holly-Landscape</option> <option value="images/Xmastree2.jpg" > Xmas Tree - Landscape</option> <option value="images/Decoborder1.png" > Art Deco Border - Portrait</option> </select><br /><br /> <input type="submit" value="Submit"/> </form> </div><!-- end #content --> </body> </html> </div> <div class="container-grid footer"> <?php include("inc/footer.php"); ?> </div> <script src="js/jquery.min.js"></script> <script src="js/outofview.js"></script> <script src="js/popper.min.js"></script> <script src="js/bootstrap.min.js"></script> </div> </body> </html> prnpdf.php <?php session_start(); include("cons/connect_Verses4Cards.php"); $conn=get_db_conn_verse(); $display_block =""; $color=""; $r =""; $g =""; $b =""; $image =""; //echo $r,$g,$b; //Get the Card Variables $Get_Size_sql = "SELECT * FROM `CSize` WHERE `Size` ='".$_POST["CSize"]."'"; $Get_Size_res = mysqli_query($conn, $Get_Size_sql) or die(mysqli_error($conn)); if (mysqli_num_rows($Get_Size_res) < 1) { //this Card does not exist $display_block = "You have selected an invalid Card size. Please try again."; } else { //get the print variables while ($Size_info = mysqli_fetch_array($Get_Size_res)) { $BoxX = stripslashes($Size_info['BoxX']); $Cellw = stripslashes($Size_info['Cellw']); $Cellh = stripslashes($Size_info['Cellh']); $SizeI = stripslashes($Size_info['Size']); $SID = stripslashes($Size_info['SID']); $floatx = stripslashes($Size_info['floatx']); $floaty = stripslashes($Size_info['floaty']); $floatw = stripslashes($Size_info['floatw']); $floath = stripslashes($Size_info['floath']); $ort = stripslashes($Size_info['ort']); } //create the display string $display_block = "$ort"; } //verify the Event exists //$the_id = mysqli_real_escape_string($mysqli, $_SESSION[VID]); $Get_Verse_sql = "SELECT id, Event, Sub_Type, Verse FROM verses WHERE id='".$_SESSION['Test']."'"; $Get_Verse_res = mysqli_query($conn, $Get_Verse_sql) or die(mysqli_error($conn)); if (mysqli_num_rows($Get_Verse_res) < 1) { //this Event does not exist $display_block = "You have selected an invalid Verse. Please try again."; } else { //get the Event ID while ($Verse_info = mysqli_fetch_array($Get_Verse_res)) { $Verse = stripslashes($Verse_info['Verse']); } //create the display string $display_block = "$Verse"; //free results mysqli_free_result($Get_Verse_res); mysqli_free_result($Get_Size_res); //close connection to MySQL } mysqli_close($conn); require('fpdf.php'); class PDF extends FPDF { var $B; var $I; var $U; var $HREF; function __construct($orientation='P', $unit='mm', $size='A4') { // Call parent constructor parent::__construct($orientation,$unit,$size); // Initialization $this->B = 0; $this->I = 0; $this->U = 0; $this->HREF = ''; } function SetStyle($tag, $enable) { // Modify style and select corresponding font $this->$tag += ($enable ? 1 : -1); $style = ''; foreach(array('B', 'I', 'U') as $s) { if($this->$s>0) $style .= $s; } $this->SetFont('',$style); } } $color = $_POST['color']; //$r = substr($color,0,3); //$b = substr($color,3,3); //$g = substr($color,4,6); //**** This is what I added to make it work and commented out the original above. $r = hexdec(substr($color,0,2)); $g = hexdec(substr($color,2,2)); $b = hexdec(substr($color,4,2)); //echo $r.'r<br>'; //echo $g.'g<br>'; //echo $b.'b<br>'; //exit(); $image=$_POST['image']; $pdf = new PDF($ort,'mm','A4'); $pdf->AddPage(); $pdf->AddFont('French Script MT','','frscript.php'); $pdf->AddFont('Batavia','','Batavia_.php'); $pdf->AddFont('Algerian','','Alger.php'); $pdf->AddFont('Bladerunner','','BLADRMF_.php'); $pdf->AddFont('Brush Script','','BRUSHSCI.php'); $pdf->AddFont('Helterskelter','','Helte___.php'); $pdf->AddFont('Justice','','Justice_.php'); $pdf->AddFont('Magneto','','MAGNETOB.php'); $pdf->AddFont('Old English','','OldEngl.php'); $pdf->AddFont('Sneakerhead Outline','','Sneabo__.php'); $pdf->AddFont('Trendy','','Trendy__.php'); $pdf->AddFont('Vladimir Script','','VLADIMIR.php'); $pdf->SetLeftMargin('float0'); $pdf->SetTextColor($r,$g,$b); $pdf->SetFont($_POST['fontface'],'',$_POST['font']); $pdf->SetXY($BoxX, $_POST['Top']); $pdf->Image($image,$floatx,$floaty,$floatw,$floath,'',''); $pdf->MultiCell($Cellw,$Cellh,$display_block,'' ,'C'); //$pdf->SetDisplayMode('fullpage',''); $pdf->SetFont(''); $pdf->Output('verse.pdf','D'); //end: ?>
  10. I have tried this code below to solve my problem , but in front end number is increasing buy in Mysql the numbers are not increasing <?php $con=mysqli_connect('localhost','root','','youtube'); $alias=$_GET['alias']; $sql="SELECT * FROM articles where alias='$alias'"; $res=mysqli_query($con,$sql); $row=mysqli_fetch_assoc($res); ?> <!DOCTYPE html> <html lang="en"> <head> <title>Like Dislike</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet"> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script> <script src="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js" integrity="sha256-Lsk+CDPOzTapLoAzWW0G/WeQeViS3FMzywpzPZV8SXk=" crossorigin="anonymous"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script> </head> <body> <div class="container"> <div class="row main_box"> <div class="col-md-6 title"> <h3><?php echo $row['title']; ?></h3> </div> <div class="col-md-3"> <a href="javascript:void(0)" class="btn btn-info"> <span class="glyphicon glyphicon-thumbs-up" onclick="like_update('<?php echo $row['id']; ?>')">Like (<span id="like_loop_<?php echo $row['id']; ?>"><?php echo $row['like_count']; ?></span>)</span> </a> </div> <div class="col-md-3"> <a href="javascript:void(0)" class="btn btn-info"> <span class="glyphicon glyphicon-thumbs-down" onclick="dislike_update('<?php echo $row['id']; ?>')">Dislike (<span id="dislike_loop_<?php echo $row['id']; ?>"><?php echo $row['dislike_count']; ?></span>)</span> </a> </div> </div> <script> function like_update(id) { var cur_count=jQuery('#like_loop_'+id).html(); cur_count++; jQuery('#like_loop_'+id).html(cur_count); jQuery.ajax({ url:'update_count.php', type:'post', data:'type=like&id='+id, success:function(result){ } }); } function dislike_update(id) { var cur_count=jQuery('#dislike_loop_'+id).html(); cur_count++; jQuery('#dislike_loop_'+id).html(cur_count); jQuery.ajax({ url:'update_count.php', type:'post', data:'type=dislike&id='+id, success:function(result){ } }); } </script> </div> </body> </html> update_count.php <?php $con=mysqli_connect('localhost','root','','youtube'); $type=$_POST['type']; $id=$_POST['id']; if ($type=='like') { $sql="UPDATE articles SET like_count=like_count+1 WHERE id=$id"; } else { $sql="UPDATE articles SET dislike_count=dislike_count+1 WHERE id=$id"; } $res_count=mysqli_query($con,$sql); ?> Please help me my seniors here... Thanks in advance
  11. Basically thought I got this working before and now i'm stuck. I'm setting and getting a cookie using a set function ("setRememberMeToken") and retrieving them using a get function ("getRememberMeCheck") [see functions bellow in the final box]... however when i close the browser the cookie session is lost when i reopen.. I used a browser extension called Cookie-editor in chrome to check and I see nothing saved upon reopening (cookie named "token" as it uses tokens in MYSQL DB). This is the thing, if i run (this code bellow).. it actually saves the session fine and works great... saved in a experimental file I named ~/test/test/cookithing.php. <?php include '../includes/config.php'; function setRememberMeToken($pdo, $user_id) { $token = bin2hex(random_bytes('25')); $expirationDate = time() + (86400 * 7); // <-- 7 days later setcookie("token", $token, $expirationDate, "/"); echo $_COOKIE["token"] = $token; $test = true; $to = date('Y-m-d', $expirationDate); $sql = "INSERT INTO `user_token` (`user_id`, `expires`, `tokenHash`) VALUES (?, ?, ?);"; $stmt= $pdo->prepare($sql); $stmt->execute([$user_id, $to, sha1($token)]); } setRememberMeToken($pdo, 1); echo "<br>"; echo sha1($_COOKIE["token"]); ?> So by vising this page it works!.. however not ideal situation to be in as I need it to get to work upon login... Forgetting about the code above for s second, here is the code I use for login (ask if you need more)... if (isset($_POST['remember-me'])){ setRememberMeToken($pdo, $_SESSION["userID"] ); // <----- set token //echo "<br>"; //echo sha1($_COOKIE["token"]); } and the main functions are here:.. <?php function setRememberMeToken($pdo, $user_id) { $token = bin2hex(random_bytes('25')); $expirationDate = time() + (86400 * 7); // <-- 7 days later (make sure your comments are accurate) setcookie("token", $token, $expirationDate, "/"); $_COOKIE["token"] = $token; $test = true; $to = date('Y-m-d', $expirationDate); $sql = "INSERT INTO `user_token` (`user_id`, `expires`, `tokenHash`) VALUES (?, ?, ?);"; $stmt= $pdo->prepare($sql); $stmt->execute([$user_id, $to, sha1($token)]); } function getRememberMeCheck($pdo) { $stmt = $pdo->prepare(" SELECT users.name, users.user_id FROM user_token, users WHERE tokenHash = ? AND expires > NOW() AND users.user_id = user_token.user_id "); $stmt->execute([sha1($_COOKIE["token"])]); $db_query = $stmt->fetch(); if (!$db_query){ return false; } $_SESSION["loggedin"] = true; $_SESSION["username"] = $db_query['name']; $_SESSION["the_usr_id"] = $db_query['user_id']; $_SESSION["userID"] = $db_query['user_id']; // ADDED DUE TO DESCRIPTION ("PROB WILL BE OK") return true; } function isRemembered() { return isset($_COOKIE['token']); } ?> Can anyone see what I'm doing wrong.. right now I'm fairly clueless..? ____________ Edit: also, my header file contains this (see bellow) also.. include 'includes/remember_token.php'; include 'includes/count_online.php'; if (isset($_COOKIE['token'])) { getRememberMeCheck($pdo); } .. this checks if the cookie is set.
  12. Hi Everyone, I am fairly new in PHP Development but have used Wordpress for the last 2 years. I am currently modifying a plugin to suit the client's requirements. It is a Custom To-DO list plugin. You may check out my progress here : [Page on meshfun.com] The plugin I am modifying is WordPress › TaskFreak! Free " WordPress Plugins It is almost all the required features, just the feature of Creating Groups and assigning is absent. When a new task is created,an option of assigned to is present but that can assign task to ONLY ONE Person. It should be able to assign to multiple users. The whole data is stored in the database in 8-9 tables. The main table DO has a field called as user_ID as you can see in the image below. It is updated when a new task is created. It contains a number (User ID of person who is assigned the task) or left blank in case the task is not assigned to anyone. : I would like the ability to assign to multiple users instead of one. What would be the ideal way ? Create new table or store the number of people assigned as array ? If a new table is created, what will be the fields to be created ? Note I was not able to add images so please check out here to see couple of images I wanted to show you : http://www.quora.com/Need-help-in-Modifying-a-Wordpress-Plugin I understand that you guys are quite busy but if you guys can atleast guide me on how to proceed, it would be great ! Thanks, Shalabh Here is the code which displays dropdown menu in the front end (taskfreak/inc/views/front/edit.php) <li> <label for="tfk_user_id"><?php _e('Assigned to', 'taskfreak') ?></label> <select name="user_id" id="tfk_user_id"> <option value="">—</option> <?php foreach ($this->users as $user): ?> <option value="<?php echo $user->ID ?>"<?php if ($this->pid && $this->data->get('user_id') == $user->ID) { echo " selected"; } ?>><?php echo $user->display_name ?></option> <?php endforeach; ?> </select> <?php echo $this->data->errors['user_id'] ?> </li> UPDATE : One gentleman suggested me to create a table with the following SQL COde : CREATE TABLE `task_user` ( `task_id` int(11) unsigned NOT NULL, `user_id` int(11) unsigned NOT NULL, `status` tinyint(4) NOT NULL DEFAULT '1' COMMENT 'status field is optional', UNIQUE KEY `task_user` (`task_id`,`user_id`,`type`) USING BTREE, KEY `task_id` (`task_id`), ) CHARSET=utf8 But I am still not able to convert the display into multiple checkboxes.
  13. I want to display data in my table tbljobcategory but for example , if the return data is Infomation and Technology it is only returning Infomation... <?php $stmt = $pdo->prepare("select * from tbljobcategory where category_id=:catid"); $stmt -> execute(array(":catid"=>$_GET["catid"])); $rows = $stmt ->fetch(PDO::FETCH_ASSOC); $CategoryName = htmlspecialchars($rows["Category"]); ?> <div class="card text-center form-add" style="width:35%;"> <div class="card-header"> Edit Job Category </div> <div class="card-body"> <form method="post" action=""> <div class="mb-3"> <label for="exampleFormControlInput1" class="form-label">Current Job Category</label> <input class="form-control" type="text" value=<?php echo "$CategoryName " ;?> disabled readonly> </div> <div class="mb-3"> <label for="exampleFormControlTextarea1" class="form-label">New Job Category</label> <input class="form-control" type="text" name="NCategory" placeholder="New Job Category" aria-label="default input example"> </div> <button type="submit" name="btn-update" class="btn btn-primary">Save Changes</button> <button type="submit" name="btn-cancel" class="btn btn-secondary">Cancel</button> </div> </form>
  14. I have code where I'm simply calling an API and I've converted it to loop the call so that I can call it with three different argument values. This is because the API is structured where it can accept one value for that argument at a time, but I need to compare the results of the three calls and I think the best way is to build a single array from the responses by either pushing a value if it exists or pushing the whole index if not. Think of it like the API response can give me data that can be as much as 400 products that are sold across 3 stores. All 400 may be sold in one store, but maybe only 120 in another and 100 in the third. I need my array to be all 400 products but I'll want to have an array within that holds the stores for the given product. Code: $IdentifierTest = 1472; $arguments = ['store 1', 'store 2', 'store 3']; $TestApi = app(TestApi::class); $newArray = array(); foreach($arguments as $argument){ $testResponse = $TestApi->getData($IdentifierTest, $argument); $Data = $testResponse->getResult()->getData(); // get the final results of call //check if array empty, and if so, push all records // if not empty, start checking 'id' against existing array records. If match, push stores. If not, add record to array } $this->makeFile($IdentifierTest, $Data); An example of the response is: array:426 [â–¼ 0 => prices {#2698 â–¼ #container: array:11 [â–¼ "prd" => 2380 "id" => "173489" "price" => "65.00" ] } The issue is that specific example only shows up when calling the API with 'store 1' and 'store 2' as the argument, but not 'store 3'. What I'd like to do is call the API with each argument and create a new array with a ```stores``` index that pushes the store number if the id exists in the call, like so: array:426 [â–¼ 0 => prices {#2698 â–¼ #container: array:11 [â–¼ "prd" => 2380 "id" => "173489" "price" => "65.00" stores: array[ 'store 1', 'store 2' ] ] } So when it's called with 'store 1' I would push the response into an array with 'store 1' as the value in 'stores', then on 'store 2' I would take the response and first check to see if the id exists in the array I've made. If it exists, I'll add 'store 2' to the 'stores' and if not I'll make a new index in the array. Basically, if product (id) 178293 is sold in all three stores then that means it would come back in all 3 API response calls and would end up being a single record in this new array with ```stores['store 1', 'store 2', 'store 3']``` How can I create a new array from this where I push only the stores if the id exists in the API call while keeping the current structure?
  15. Hello, I don't really see how to integrate payment via RevolUt into my website despite having read the documentation from the official RevolUt website. Please give me some advice. Have a good day !
  16. I do everything in sandbox mode but I'm blocked at this part: RevolutPHP\Auth\Provider And I get this error: Undefined array key "code" Thank you in advance for your help and advice. This is the guide, i use (https://github.com/sverraest/revolut-php)
  17. Looking to improve on a fulltext-keyed table search process. I have a MyIsam table with a primary index as well as a large varchar column keyed as fulltext. What I would like to learn more about is how to do a search on the fulltext key that uses multiple words. The text field is a set of meeting minutes so there is quite a bit of text in ordinary English. I'd like to improve my current searching capability to help me to do this kind of expanded searching. Right now I can only manage to search on a single word which limits my searching capability and results. I have recently started reading up on this and have gotten myself in pretty deep with Natural Language, Distance and using "" on the search words but it doesn't seem to do what I want to do. Ex. Say I want to find a sentence/phrase that uses "M/C", "donation" and a dollar value indicated by the presence of a $ sign. I apparently am not allowed to do that cause I get no results. And that is why I am here. Here is the query I currently have tried: SELECT meet_date, meet_txt FROM meeting_mins WHERE Match(meet_txt) against('"M/C donation $*" @10 ' in Boolean mode) The above is looking for the existence of 'M/C' and 'donation' and a $ with anything after it. All within 10 words of each other. At least that is what I think I'm composing. I have also tried it without the $ item and again with no slash in the M/C item. No results for any of these. Any mysql aces know what I need to do to accomplish the query I included? To be clear the column 'meet_txt' does have the fulltext index defined. It is using the MyIsam engine and the utf8_general_ci character set. To add some more complexity - would it be possible to derive a position value for where in the field the search was successful, or at least the first place it was?
  18. Hello. I'm a newbie so sorry if this isn't the best forum to post my problem. I am using a MySQL and PHP to create a web app. I have authentication, and I can register users. I also have a form that users provide information and it is successfully inserting data into a table in my database. I will use fictional fields for my database table called meal_info: username dateStartedDiet numberMealsPerDay costPerMeal Problem: Select user-specific data from the MySQL database, using Session username to select only the current user's data, then display it and do some calculations. Here is thecode at the top, and I am fairly sure it's working: session_start(); //execute commone code require("common.php"); //includes code to connect to database, etc. if(empty($_SESSION['user'])) { // If they are not, we redirect them to the login page. header("Location: login.php"); // Remember that this die statement is absolutely critical. Without it, // people can view your members-only content without logging in. die("Redirecting to login.php"); } Here is the part of the code that has to do with displaying user data: $userID = $_SESSION['user']['username']; //create a variable that is the session username which is identical to the field in our MySQL table $query = "SELECT * FROM meal_info WHERE username = $userID"; //our SELECT statement $result = db->query($query); //execute the query $row_count = $result->num_rows;//count the rows in the table and place in variable to use in incremental loop code for ($i = 0; $i < $row_count; $i++) : $row = $result->fetch_assoc(); //for each row in the table, fetch and create and array $dateStart = $row['dateStartedDiet']; $numberMeals = $row['numberMealsPerDay']; $costMeal = $row['costPerMeal']; echo $dateStart; echo $numberMeals; echo $costMeal;
  19. Hello to everybody, I need critiques and "website crawling help" about my website http://enginery.freecluster.eu . My crawling question was that: I tried google search console tools to add my website's sitemap and add it : http://enginery.freecluster.eu/sitemap.xml . It says my sitemap is ok and found 312 pages but not crawl all correctly! Three weeks have passed but nothing changed. I manually request indexing some pages(about 4 pages) and google search console, after than today it only shows some of them(not all 4) when I search using "site:http://enginery.freecluster.eu". My website's all files have php extensions. Did this prevent googlebot to reach the content of my websites' pages? My robots.txt file's content is : User-agent: Googlebot Allow: / User-agent: * Allow: / Sitemap: http://enginery.freecluster.eu/sitemapv1.xml Any critiques and help is appreciated. Thanks.
  20. I have the complete website, and works fine on windows using XAMPP control panel accessing via localhost. Now I am having trouble accessing the table(s) via ubuntu after turning on mysql in ubuntu also I am receving no errors just a blank page. You can check the php but it might not make any difference. All assoicated files for linking with mysql are below if needed I will upload whole webiste without images. I have stopped mysql and restarted it, over and over again. Also tried using sudo /usr/sbin/mysqld --skip-grant-tables --skip networking & command and no luck. Website is running succesfully just mysql is not working any suggestion on what could be wrong. add-aboutme.php add-contactme.php add-guestbook.php delete-contact.php guestbook.php view-aboutme.php view-contactme.php view-guestbook.php
  21. Hi everyone! I'm creating a blog for someone here: http://test4.neshayasmin.com/ I've used this theme as my foundation, but I'm making changes to its appearance: http://themeforest.net/item/novelty-retina-ready-responsive-wordpress-theme/4367335 I want to change the appearance of the older/newer buttons at the bottom. At the moment each page is numbered at the bottom of the blog, but I want to have an 'older posts' and a 'newer posts' link instead. I don't have very good knowledge of php. Any help would be wildly appreciated, friends. Let me know if you need any more info.
  22. Hi everyone, I hope cyberRobot or Guru is reading this thread. I am trying to create a vertical table data in php from method of GET and POST. Is it possible? I succeed created the vertical table data from database (MySQL). I created the vertical table data on php that inside the form thathas method of GET or POST, that should allow any value in php go to another page by method of GET, but seem it doesn't work. Maybe I miss something in code? Help will be very appreciate. I am still learning, ready to get in interaction in php. Here my code: <!doctype html> <html> <head> <title>Test array attendence</title> </head> <body> <table> <?php $columns = 2; if(isset($_GET['member'])) { $display = $_GET['member']; $num_row = $display; $rows = ceil($num_row / $columns); <-- It is causing an error in code, line 14. while ($row = $display) { $data[] = $row; } echo "<table border='1'>"; for($i = 0; $i < $rows; $i++) { echo "<tr>"; for($j = 0; $j < $columns; $j++) { if(isset($data[$i + ($j * $row)])) { echo "<td>".$data[$i + ($j * $row)]."</td>"; $count = $count+1; } } echo "</tr>"; } } ?> </table> <table><tr><td><?php echo $count." are attending this meeting tonight." ?></td></tr></table> </body> </html> I get an error message - Fatal error: Unsupported operand types in /srv/disk10/1141650/www/sigmahokies.biz.ht/testarray3.php on line 14
  23. Well, I am a total Python Newbie but know PHP very well, I wanted to create a website that would help people to generate Word crosswords, hence after a little web search I found this Python Code which I need help in converting to PHP> I tried myself but failed as I know nothing about Python, I also tried an online conversion tool, but without any luck, so if anyone here can help me convert the following code to PHP, it will be highly respected. Heres the code: import random, re, time, string from copy import copy as duplicate class Crossword(object): def __init__(self, cols, rows, empty = '-', maxloops = 2000, available_words=[]): self.cols = cols self.rows = rows self.empty = empty self.maxloops = maxloops self.available_words = available_words self.randomize_word_list() self.current_word_list = [] self.debug = 0 self.clear_grid() def clear_grid(self): # initialize grid and fill with empty character self.grid = [] for i in range(self.rows): ea_row = [] for j in range(self.cols): ea_row.append(self.empty) self.grid.append(ea_row) def randomize_word_list(self): # also resets words and sorts by length temp_list = [] for word in self.available_words: if isinstance(word, Word): temp_list.append(Word(word.word, word.clue)) else: temp_list.append(Word(word[0], word[1])) random.shuffle(temp_list) # randomize word list temp_list.sort(key=lambda i: len(i.word), reverse=True) # sort by length self.available_words = temp_list def compute_crossword(self, time_permitted = 1.00, spins=2): time_permitted = float(time_permitted) count = 0 copy = Crossword(self.cols, self.rows, self.empty, self.maxloops, self.available_words) start_full = float(time.time()) while (float(time.time()) - start_full) < time_permitted or count == 0: # only run for x seconds self.debug += 1 copy.current_word_list = [] copy.clear_grid() copy.randomize_word_list() x = 0 while x < spins: # spins; 2 seems to be plenty for word in copy.available_words: if word not in copy.current_word_list: copy.fit_and_add(word) x += 1 #print copy.solution() #print len(copy.current_word_list), len(self.current_word_list), self.debug # buffer the best crossword by comparing placed words if len(copy.current_word_list) > len(self.current_word_list): self.current_word_list = copy.current_word_list self.grid = copy.grid count += 1 return def suggest_coord(self, word): count = 0 coordlist = [] glc = -1 for given_letter in word.word: # cycle through letters in word glc += 1 rowc = 0 for row in self.grid: # cycle through rows rowc += 1 colc = 0 for cell in row: # cycle through letters in rows colc += 1 if given_letter == cell: # check match letter in word to letters in row try: # suggest vertical placement if rowc - glc > 0: # make sure we're not suggesting a starting point off the grid if ((rowc - glc) + word.length) <= self.rows: # make sure word doesn't go off of grid coordlist.append([colc, rowc - glc, 1, colc + (rowc - glc), 0]) except: pass try: # suggest horizontal placement if colc - glc > 0: # make sure we're not suggesting a starting point off the grid if ((colc - glc) + word.length) <= self.cols: # make sure word doesn't go off of grid coordlist.append([colc - glc, rowc, 0, rowc + (colc - glc), 0]) except: pass # example: coordlist[0] = [col, row, vertical, col + row, score] #print word.word #print coordlist new_coordlist = self.sort_coordlist(coordlist, word) #print new_coordlist return new_coordlist def sort_coordlist(self, coordlist, word): # give each coordinate a score, then sort new_coordlist = [] for coord in coordlist: col, row, vertical = coord[0], coord[1], coord[2] coord[4] = self.check_fit_score(col, row, vertical, word) # checking scores if coord[4]: # 0 scores are filtered new_coordlist.append(coord) random.shuffle(new_coordlist) # randomize coord list; why not? new_coordlist.sort(key=lambda i: i[4], reverse=True) # put the best scores first return new_coordlist def fit_and_add(self, word): # doesn't really check fit except for the first word; otherwise just adds if score is good fit = False count = 0 coordlist = self.suggest_coord(word) while not fit and count < self.maxloops: if len(self.current_word_list) == 0: # this is the first word: the seed # top left seed of longest word yields best results (maybe override) vertical, col, row = random.randrange(0, 2), 1, 1 ''' # optional center seed method, slower and less keyword placement if vertical: col = int(round((self.cols + 1)/2, 0)) row = int(round((self.rows + 1)/2, 0)) - int(round((word.length + 1)/2, 0)) else: col = int(round((self.cols + 1)/2, 0)) - int(round((word.length + 1)/2, 0)) row = int(round((self.rows + 1)/2, 0)) # completely random seed method col = random.randrange(1, self.cols + 1) row = random.randrange(1, self.rows + 1) ''' if self.check_fit_score(col, row, vertical, word): fit = True self.set_word(col, row, vertical, word, force=True) else: # a subsquent words have scores calculated try: col, row, vertical = coordlist[count][0], coordlist[count][1], coordlist[count][2] except IndexError: return # no more cordinates, stop trying to fit if coordlist[count][4]: # already filtered these out, but double check fit = True self.set_word(col, row, vertical, word, force=True) count += 1 return def check_fit_score(self, col, row, vertical, word): ''' And return score (0 signifies no fit). 1 means a fit, 2+ means a cross. The more crosses the better. ''' if col < 1 or row < 1: return 0 count, score = 1, 1 # give score a standard value of 1, will override with 0 if collisions detected for letter in word.word: try: active_cell = self.get_cell(col, row) except IndexError: return 0 if active_cell == self.empty or active_cell == letter: pass else: return 0 if active_cell == letter: score += 1 if vertical: # check surroundings if active_cell != letter: # don't check surroundings if cross point if not self.check_if_cell_clear(col+1, row): # check right cell return 0 if not self.check_if_cell_clear(col-1, row): # check left cell return 0 if count == 1: # check top cell only on first letter if not self.check_if_cell_clear(col, row-1): return 0 if count == len(word.word): # check bottom cell only on last letter if not self.check_if_cell_clear(col, row+1): return 0 else: # else horizontal # check surroundings if active_cell != letter: # don't check surroundings if cross point if not self.check_if_cell_clear(col, row-1): # check top cell return 0 if not self.check_if_cell_clear(col, row+1): # check bottom cell return 0 if count == 1: # check left cell only on first letter if not self.check_if_cell_clear(col-1, row): return 0 if count == len(word.word): # check right cell only on last letter if not self.check_if_cell_clear(col+1, row): return 0 if vertical: # progress to next letter and position row += 1 else: # else horizontal col += 1 count += 1 return score def set_word(self, col, row, vertical, word, force=False): # also adds word to word list if force: word.col = col word.row = row word.vertical = vertical self.current_word_list.append(word) for letter in word.word: self.set_cell(col, row, letter) if vertical: row += 1 else: col += 1 return def set_cell(self, col, row, value): self.grid[row-1][col-1] = value def get_cell(self, col, row): return self.grid[row-1][col-1] def check_if_cell_clear(self, col, row): try: cell = self.get_cell(col, row) if cell == self.empty: return True except IndexError: pass return False def solution(self): # return solution grid outStr = "" for r in range(self.rows): for c in self.grid[r]: outStr += '%s ' % c outStr += '\n' return outStr def word_find(self): # return solution grid outStr = "" for r in range(self.rows): for c in self.grid[r]: if c == self.empty: outStr += '%s ' % string.lowercase[random.randint(0,len(string.lowercase)-1)] else: outStr += '%s ' % c outStr += '\n' return outStr def order_number_words(self): # orders words and applies numbering system to them self.current_word_list.sort(key=lambda i: (i.col + i.row)) count, icount = 1, 1 for word in self.current_word_list: word.number = count if icount < len(self.current_word_list): if word.col == self.current_word_list[icount].col and word.row == self.current_word_list[icount].row: pass else: count += 1 icount += 1 def display(self, order=True): # return (and order/number wordlist) the grid minus the words adding the numbers outStr = "" if order: self.order_number_words() copy = self for word in self.current_word_list: copy.set_cell(word.col, word.row, word.number) for r in range(copy.rows): for c in copy.grid[r]: outStr += '%s ' % c outStr += '\n' outStr = re.sub(r'[a-z]', ' ', outStr) return outStr def word_bank(self): outStr = '' temp_list = duplicate(self.current_word_list) random.shuffle(temp_list) # randomize word list for word in temp_list: outStr += '%s\n' % word.word return outStr def legend(self): # must order first outStr = '' for word in self.current_word_list: outStr += '%d. (%d,%d) %s: %s\n' % (word.number, word.col, word.row, word.down_across(), word.clue ) return outStr class Word(object): def __init__(self, word=None, clue=None): self.word = re.sub(r'\s', '', word.lower()) self.clue = clue self.length = len(self.word) # the below are set when placed on board self.row = None self.col = None self.vertical = None self.number = None def down_across(self): # return down or across if self.vertical: return 'down' else: return 'across' def __repr__(self): return self.word ### end class, start execution #start_full = float(time.time()) word_list = ['saffron', 'The dried, orange yellow plant used to as dye and as a cooking spice.'], \ ['pumpernickel', 'Dark, sour bread made from coarse ground rye.'], \ ['leaven', 'An agent, such as yeast, that cause batter or dough to rise..'], \ ['coda', 'Musical conclusion of a movement or composition.'], \ ['paladin', 'A heroic champion or paragon of chivalry.'], \ ['syncopation', 'Shifting the emphasis of a beat to the normally weak beat.'], \ ['albatross', 'A large bird of the ocean having a hooked beek and long, narrow wings.'], \ ['harp', 'Musical instrument with 46 or more open strings played by plucking.'], \ ['piston', 'A solid cylinder or disk that fits snugly in a larger cylinder and moves under pressure as in an engine.'], \ ['caramel', 'A smooth chery candy made from suger, butter, cream or milk with flavoring.'], \ ['coral', 'A rock-like deposit of organism skeletons that make up reefs.'], \ ['dawn', 'The time of each morning at which daylight begins.'], \ ['pitch', 'A resin derived from the sap of various pine trees.'], \ ['fjord', 'A long, narrow, deep inlet of the sea between steep slopes.'], \ ['lip', 'Either of two fleshy folds surrounding the mouth.'], \ ['lime', 'The egg-shaped citrus fruit having a green coloring and acidic juice.'], \ ['mist', 'A mass of fine water droplets in the air near or in contact with the ground.'], \ ['plague', 'A widespread affliction or calamity.'], \ ['yarn', 'A strand of twisted threads or a long elaborate narrative.'], \ ['snicker', 'A snide, slightly stifled laugh.'] a = Crossword(13, 13, '-', 5000, word_list) a.compute_crossword(2) print a.word_bank() print a.solution() print a.word_find() print a.display() print a.legend() print len(a.current_word_list), 'out of', len(word_list) print a.debug #end_full = float(time.time()) #print end_full - start_full
  24. I'm helping a friend in developing a project for our alma mater. And its based on this paper: An Enhanced Indoor Positioning Method Based on Wi-Fi RSS Fingerprinting So far 80% of the web app is finished except for the algorithm (We have no experience with algorithms to source code translations) that needs to be implemented in the website. Inside this paper there is this algorithm that the proponents of the research used. (attached as screenshot). The algorithm was converted to code by using MATLAB, but we are trying to use PHP with our project. Based on the pseudo code the calculation of the Euclidean Distance is the core of it. Can anyone help us with the translation just to get it started.
  25. Hey. Been a while since I last posted here. Problem: the first 8 lines of code work for the top box, but not the bottom box. Code in question is this: <?php // bottom if ($anon_comment== "1"){ ?> <span style="color: black">Post as anonymous?</span> <input type="checkbox" id="anon" name="anon" value="set" checked> <?php } elseif($anon_comment == "2" ) { ?> <span style="color: black">Post as anonymous?</span> <input type="checkbox" id="anon" name="anon" value="set"> <?php } ?> And for illustration purposes here is the second box... <?php // bottom if ($anon_comment== "1"){ ?> <span style="color: black">Post as anonymous?</span> <input type="checkbox" id="anon" name="anon" value="set" checked> <?php } elseif($anon_comment == "2" ) { ?> <span style="color: black">Post as anonymous?</span> <input type="checkbox" id="anon" name="anon" value="set"> <?php } ?> Like I said it works on line 220 but not line 151. Both are very similar if not the same, but the bottom one never works at all. Its like the conditional statement above is not working the other box (aka "bottom"). The first box works fine and as expected. Whole code: <?php $stmt = $pdo->prepare("SELECT cooment_anon FROM `users` WHERE user_id = ?"); $stmt->execute([$_SESSION['the_usr_id']]); $is_anon_set = $stmt->fetch(); if($is_anon_set['cooment_anon'] == 1){ echo $anon_comment = "1"; } else { echo $anon_comment = "0"; } if (isset($_GET['anon'])){ echo "posting as anon"; } // ---~ login check ~--- // --- ~~ --- ?> <style> .generalclass { color: #ffffff; text-align: left; margin: 10px; padding: 10px; display: none; } </style> <?php //require_once "../config.php"; // create/display nested comments // init $user_id = $_SESSION['the_usr_id']; // fake some data //$_GET['news_id'] = $news['news_id']; $_GET['news_id'] = 0; // <-------------------- TESTING $_COMMENTS_ID= $news['news_id']; $post = []; // array to hold a trimmed working copy of the form data $errors = []; // array to hold user/valdiation errors // post if($_SERVER['REQUEST_METHOD'] == 'POST') { // trim all the data at once $post = array_map('trim',$_POST); // if any input is an array, use a recursive trim call-back function here instead of php's trim // validate inputs here... // if no errors, use the form data if ($post['anon'] == "set"){ $is_anon = 1; } else { $is_anon = 0; } if(empty($errors)) { $sql = "INSERT INTO `comment` (`comment_id`, `parent`, `news_id`, `user_id`, `content`, `karma`, `removed`, `reference____`, `date`, `last_update`, `aproved`, `anonymous`, `image_upld`) VALUES (NULL, ?, ?, ?, ?, '0', '0', '', NOW(), NULL, '1', ?, NULL)"; $stmt = $pdo->prepare($sql); $stmt->execute([ $post['parent_id'], $_COMMENTS_ID, $user_id, $post['comment'], $is_anon ]); } // if no errors, success if(empty($errors)) { die(header("Refresh:0")); } } // get all the rows of data for the requested news id $sql = "SELECT comment.parent, comment.comment_id, comment.news_id, comment.user_id, comment.content, comment.karma, comment.removed, comment.date, comment.last_update, comment.aproved, comment.anonymous, comment.image_upld, users.name, users.avatar FROM `comment` LEFT JOIN `users` ON `comment`.`user_id` = `users`.`user_id` WHERE news_id = ? ORDER BY comment_id DESC LIMIT 800"; $stmt = $pdo->prepare($sql); $stmt->execute([ $_COMMENTS_ID ]); $comment_data = $stmt->fetchAll(PDO::FETCH_GROUP); // recursive function to output parent/child data function list_comments($parent_id, $data, $level=0) { // this just supplies a visual part to the output so you can see what the code does //$indent = str_repeat("<span style='color: transparent;'>---- </span>", $level); $indent = str_repeat("<span style='color: transparent;'>---- </span>", $level); //echo "<pre>"; //print_r($data); //echo "</pre>"; // loop over data for the current parent_id foreach($data[$parent_id] as $arr) { // output the comment and any other information if ($arr['anonymous'] == 1){ $pre_hash = $arr['name']."3434292"; echo $indent ."<a href='profile.php?anonymous'><img src='site-data/avatars/sir.png' style='width: 30px; float: left; margin: 15px; border-radius: 30px;'></a>"; echo "<a href='profile.php?anonymous' title='This user is in anonymous mode so cannot be seen'>Anonymous [hash ID: usranon".substr(md5($pre_hash), 0, -10)."</a><br>"; }else{ echo $indent ."<a href='profile.php?name={$arr['name']}'><img src='site-data/avatars/{$arr['avatar']}' style='width: 30px; float: left; margin: 15px; border-radius: 30px;'></a>"; echo "<a href='profile.php?name={$arr['name']}'>{$arr['name']}</a><br>"; } echo "<b><p style='font-family: Arial, Helvetica, sans-serif;'>$indent{$arr['content']}</p></b>"; // determine and output any child count $count = isset($data[$arr['comment_id']]) ? count($data[$arr['comment_id']]) : 0; $pl = $count == 0 || $count > 1 ? 'ies' : 'y'; echo "<br>$indent$count Repl$pl<br>"; // allow a comment for the current parent // you would probably want to use a javascript 'show' operation for this ?> <p> <?php echo $indent ?><button class="button" onclick="myFunction('button<?=$arr['comment_id']?>')">Reply</button> <div id="button<?=$arr['comment_id']?>" class="generalclass" style="display:none;"> <form method="post"> <input type='hidden' name='parent_id' value='<?=$arr['comment_id']?>'> <?=$indent?><label>Comment:<br> <?=$indent?><textarea name="comment" rows="4" cols="50" placeholder="remember to be polite!"></textarea></label> <input type="submit"> <a href="includes/emojis.php" onclick="window.open(this.href,'targetWindow', `toolbar=no, location=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=300px;, height=500px`); return false; style='float: right; padding-left: 30px;'">Show emojissszz</a> <?php ?> <?php // bottom if ($anon_comment== "1"){ ?> <span style="color: black">Post as anonymous?</span> <input type="checkbox" id="anon" name="anon" value="set" checked> <?php } elseif($anon_comment == "2" ) { ?> <span style="color: black">Post as anonymous?</span> <input type="checkbox" id="anon" name="anon" value="set"> <?php } ?> </form> <br> </div> <?php // recurse if there are children of the current parent if(isset($data[$arr['comment_id']])) { list_comments($arr['comment_id'], $data, $level+1); } } } // html ?> <?php // display any errors if(!empty($errors)) { echo implode('<br>',$errors); } ?> <?php if( $_SESSION["loggedin"] != true){ echo "This category/board comment system is set to private. You must register/login and join to take part. Click <u><a href='login.php'>here</a></u> to login to your account or to register.</div>"; include 'footer.php'; exit(); } // allow a comment on the main article ?> <form method="post"> <input type='hidden' name='parent_id' value='0'> <label>Comment:<br> <textarea name="comment" rows="4" cols="50" placeholder="remember to be polite!" style="border-color: grey; width: 97%;"><?=$post['content']??''?></textarea></label><br> <input type="submit"><br> <a href="includes/emojis.php" onclick="window.open(this.href,'targetWindow', `toolbar=no, location=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=300px;, height=500px`); return false; style='float: right; padding-left: 50px;'">Show emojis</a><br> <?php // top if ($anon_comment== "1"){ ?> <span style="color: black">Post as anonymous?</span> <input type="checkbox" id="anon" name="anon" value="set" checked> <?php } elseif($anon_comment == "0") { ?> <span style="color: black">Post as anonymous?</span> <input type="checkbox" id="anon" name="anon" value="set"> <?php } ?> </form><br> <div style="overflow-y: scroll; height:400px; border: 1px dashed grey; padding: 30px; margin-right: 30px; border-radius: 10px; "> <?php if( $_SESSION["loggedin"] == true){ if($count == 0){ echo "No comments"; } } ?> <?php // list comments, starting with parent 0 list_comments(0, $comment_data, 0); ?> </div> <script> function myFunction(divid) { var x = document.getElementById(divid); if (x.style.display == "none") { x.style.display = "block"; } else { x.style.display = "none"; } } </script><br><br> It should be an anonymous checkbox to allow users to choose if they want to submit anonymously based on a flag stored in the DB - "cooment_anon" which can be true or false (0/1). But the decloration isnt working using the code in he first example, despite it being the same. Strange it should work on one but not the other. Tried pasting [this bellow] in other possible locations as a hack, but never worked :S $stmt = $pdo->prepare("SELECT cooment_anon FROM `users` WHERE user_id = ?"); $stmt->execute([$_SESSION['the_usr_id']]); $is_anon_set = $stmt->fetch(); PS: By "box" i mean the initial comment box and the reply comment boxes.
×
×
  • 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.