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. Hello everyone! I'm having issues with a delete button on a table row, im getting this error: Catchable fatal error: Object of class mysqli could not be converted to string in C:\xampp\htdocs\consultas\newdatapull.php on line 19 I'm not sure whats going on, here's my code: <?php include('header.php'); $servername = "localhost"; $username = "un"; $password = "admin"; $dbname = "emelyconsultas"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); }; if (isset($_POST['delete'])) { $deleteQuery = "DELETE FROM hoteles WHERE id='$_POST[delete]'"; mysqli_query("$conn, $deleteQuery, "); }; $sql = "SELECT id, Full_Name, Email_Address, Telephone_Number, pais, ciudad, nombre_hotel, fecha_in, Fecha_out, adultos, ninos, mensaje FROM hoteles"; $result = $conn->query($sql); if ($result->num_rows > 0) { echo "<div class='container-fluid'> <div class='col-md-12'> <div id='datatable'class='table-responsive well'> <h1 class='text-center'>Entradas</h1> <table id='table' class='table'> <tr> <th>ID</th> <th>Nombre</th> <th>Correo Electronico</th> <th>Numero Telefonico</th> <th>Pais Destinado</th> <th>Ciudad Destinada</th> <th>Hotel</th> <th>Check In</th> <th>Check Out</th> <th>Adultos</th> <th>Niños</th> <th>Mensaje</th> </tr>"; // output data of each row while($row = $result->fetch_assoc()) { echo "<form action=newdatapull.php method=post>"; echo "<tr>"; echo "<td>" .$row['id'] . " </td>"; echo "<td>" .$row['Full_Name'] . " </td>"; echo "<td>" .$row['Email_Address'] . " </td>"; echo "<td>" .$row['Telephone_Number'] . " </td>"; echo "<td>" .$row['pais'] . " </td>"; echo "<td>" .$row['ciudad'] . " </td>"; echo "<td>" .$row['nombre_hotel'] . " </td>"; echo "<td>" .$row['fecha_in'] . " </td>"; echo "<td>" .$row['Fecha_out'] . " </td>"; echo "<td>" .$row['adultos'] . " </td>"; echo "<td>" .$row['ninos'] . " </td>"; echo "<td>" .$row['mensaje'] . " </td>"; echo "<td>" .$row['id'] . " </td>"; echo "<td>" ."<input class=input-group type=submit name=delete value=Borrar>" . "</td>"; "</form>"; echo "</tr></table></div></div></div>"; } } else { echo "0 results"; } $conn->close(); include('footer.php'); ?> thanks in advance to anyone that can help, Error comes up once I click the Delete button on the row...
  2. Hi all, For example, many vendor websites allow users to refine a search e.g. Lowest Price First. I need some help to implement this into my website. I have tired to do this using a submit button but it just refreshes the page, and the data that the user has used to search for the produce in the first place.
  3. Hi I’m looking for a standalone PHP OOP framework or code that follows best practices using - PDO prepared statements - Singleton Design Pattern Not looking for a massive library, something short and sweat straight to the point Any comments, feedback would be appreciated
  4. I'm making my own CMS for my company so going through making the pages for the back end. What I want to do that I'm stuck on is -------------- I want to allow the user to specify how many input text fields they want shown on the page. I'm thinking that they could write a number then click submit, send the data to the same page (PHP self or action blank) and then the required amount of input fields would be echoed out. Echoing out is easy, I want to know how to find out how many fields are required, and then process it. Thanks in advance.
  5. After uploading my PHP project to a live server, I get this error message when accessing some pages. But when running on localhost, I do not get this error and every script is working properly. I have checked white spaces, PHP opening closing tags, and Encoding without BOM. But I still couldn't figure this out. This is my header.inc.html page: <?php # -- header.html // This page begins the HTML header for the site. // Check for a $page_title value: if (!isset($page_title)) $page_title = 'Computer store | Control Panel'; ?><!DOCTYPE html> <!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]--> <!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]--> <!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]--> <!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]--> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title><?php echo $page_title; ?></title> <meta name="description" content=""> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="icon" type="image/ico" href="favicon.ico"/> <link rel="apple-touch-icon" sizes="152x152" href="apple-touch-icon-precomposed.png" /> <link rel="stylesheet" href="css/styles.css"> <script src="js/vendor/modernizr.min.js"></script> </head> <body> <!--[if lt IE 7]> <p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p> <![endif]--> <!-- End of header. -->
  6. Hi there, I'm learning PHP and working on building an ecommerce site using a MVC. I can display all six categories from the database on the index page however I only want to show four of these, as the links at the top will be the six categories. By using the next() method I can display all six categories: <?php while ($categories->next()) { ?> <section class="product"> <a href="products/<?= $categories->getURL() ?>"><h3 class="upper"><?= $categories->getName() ?></h3></a> <br/> <img src="<?= IMAGE_URL . $categories->getImage() ?>" style="width:80%; height:auto;" alt="Menu Tab"/> <h3 class="under"><a href="products/<?= $categories->getURL() ?>">SHOP NOW >></a></h3> </section> <?php } } } ?> I am wondering how to only extract certain products (each has a catID in the database). I thought the switch statement might be the answer and here was my attempt that did not work. I guess I am still not saying which catID to get but unsure how to fix this. Or is there another way not using switch? while ($categories->next()) { switch ($categories->getID()) { case 1: case 2: case 3: case 4: ?> <section class="product"> <a href="products/<?= $categories->getURL()?>"><h3 class="upper"><?=$categories->getName() ?></h3></a> <br/> <img src="<?=IMAGE_URL. $categories->getImage()?>" style="width:80%; height:auto;" alt="Menu Tab"/> <h3 class="under"><a href="products/<?= $categories->getURL()?>">SHOP NOW >></a></h3> </section> <?php break; default: return ""; } } } } ?> Any help would be greatly appreciated! Cheers
  7. Hello guys. I have a problem with signup form record in database. My code works good but only firstname input doesnt send it to database. Other all information shown up in database. Do you have any idea why it is not working? <?php // index.php session_start(); require_once 'functions.php'; $userfirstname = $lastname = $email = $remember = $error = $username = $pass = $password1 = $password2 = $user = $birthday = $bdd = $bdm = $bdy = ""; $imgavatar = 'img/default_user_avatar.png'; $userstr = '(Guest)'; if (isset($_SESSION['user'])) { $user = $_SESSION['user']; $loggedin = TRUE; $userstr = " ($user)"; } else $loggedin = FALSE; if ($loggedin){ //redirect for profile page } if(isset($_POST['username'])&&($_POST['first']) && ($_POST['lastname']) && ($_POST['email'])){ $username = sanitizeString($_POST['username']); $password1 = sanitizeString($_POST['p']); $password2 = sanitizeString($_POST['p2']); $email = sanitizeString($_POST['email']); $userfirstname = sanitizeString($_POST['first']); $lastname = sanitizeString($_POST['lastname']); $bdd = sanitizeString($_POST['day']); $bdm = sanitizeString($_POST['month']); $bdy = sanitizeString($_POST['year']); $birthday = $bdd." / ".$bdm." / ".$bdy; if ( ($username == "") || ($email =="") || ($password1 =="") || ($password2 =="") || ($userfirstname = "") || ($lastname == "")) { $error = "You didn't give us enough information for Signup"; } else { $result = queryMySQL("SELECT * FROM Members WHERE username='$username'"); if($result->num_rows) { $error ="This Username is already exists"; } else { queryMysql("INSERT INTO Members VALUES( '$userfirstname','$lastname','$email','$username','$password1','$birthday')"); die("<h4>Account created</h4>Please Log in. Your first name is $userfirstname<br><br>"); } } } echo <<<_END <DOCTYPE html> <html> <head> <title>World. Your New World</title> <link rel='stylesheet' href='styles.css' type='text/css'> <script type="text/javascript" src="javascript/javascript.js"></script> </head> <body class='home'> <div class='loginform'> <img id='imgavatar' src='$imgavatar'> <form method='post' action='index.php'> <input class = 'loginput' type='text' maxlength='16' name='user' value='$user' placeholder='Username'> <input class = 'loginput' type='password' maxlength='16' name='pass' value='$pass' placeholder='Password'> <h6 id='rememberme'><input type="checkbox" value="None" name="check" checked='checked' />Remember Me</h6> <span>$error<br></span> <input type='submit' value='Login'> </form> </div> <div class='signupform'> <h1 id='signhead'>Join Us!</h1> <p id='signhead'>It will be free and it will always be free!<br> Creat your own personal tree</p><br><br><br> <form method='POST' action='index.php'> <input class= 'loginput' type='text' maxlength='16' name='first' value='$userfirstname' placeholder='Name'> <input class= 'loginput' type='text' maxlength='16' name='lastname' value='$lastname' placeholder='Last Name'><br> <input class= 'loginput' type='email' maxlength='32'name='email' value='$email' placeholder='E-mail'> <input class= 'loginput' type='text' maxlength='16' name='username' value='$username' placeholder='Username' onBlur='checkUser(this)'><br> <input class= 'loginput' type='Password' maxlength='16' name='p' value='$password1' placeholder='Password'> <input class= 'loginput' type='Password' maxlength='16' name='p2' value='$password2' placeholder='Repeat Password'><br> <select name="month" onchange="call()" value='$bdm'> <option value="0">-Month-</option> <option value="1">January</option> <option value="2">February</option> <option value="3">March</option> <option value="4">April</option> <option value="5">May</option> <option value="6">Jun</option> <option value="7">July</option> <option value="8">August</option> <option value="9">September</option> <option value="10">October</option> <option value="11">November</option> <option value="12">December</option> </select> <select name="day" value='$bdd'> <option value="">-Day-</option> </select> <select name="year" onchange="call()" value='$bdy'> <option value="">-Year-</option> </select> $userfirstname $lastname <input type='submit' value='Sign Up'> </form> </div> </body> </html> _END; ?>
  8. Hi everyone, i am marking a number of php questionnaire forms on my webpage and they connect up to a Mysql database, so far so good. However, the part i am having trouble with is... i need certain questionnaires to only be released for fixed periods of time (for example 1/2 weeks). Would anyone be able to help me out and give me some idea of how i would go about this? Thanks
  9. Good Afternoon Ladies & Gentlemen, I am interested in learning php programming. I do not have any programming background in any other programming languages be it computer programming (C, C++, C#, Perl, Java, etc.) or web programming ( Server Side: Php, Perl Cgi, Python, Ruby on Rails; Clientside: Javascript, Xml, Xhtml, CSS, etc.). I only know basic Html and currently use a bot programmign tool "Ubotstudio" but that's all. Can you be kind enough to recommend me a paper book where I can learn php without getting confused ? It must teach the latest stable version. Q1. Which php version is stable and which version is installed on webhosts the most ? 5.5.8 ? If so, where can I get a paper book to learn it or where can I learn it online from some free tutorial ? I actually prefer to learn it from a paper book as I am not always connected to the internet. I am using internet cafe to send this message/post. I was just checking Amazon now but a lot of books meant for the beginners have got bad reviews/ratings from customers and that has left me confused and worried. The book must be for total beginners and not for intermediate or advanced programmers. It must not leave out any basics but teach it. Must teach the full default library (all the "Commands", "Functions", "Sub functions", "Syntaxes" or whatever that exists in the language from top to bottom and not miss out anything. Must teach the full grammer of the language and not leave-out anything). You may recommend any free tutorial websites too but like I said I actually prefer to learn it from a paper book as I am not always connected to the internet. I am using internet cafe to send this message/post. Q2. What is Php frame work ? Reusable code blocks meant for a specific task such as deal with database, etc. ? If so, I'm not interested in getting into heaviuly learning one framework and not learn the full language. No good being just an eye specialist or a bone specialist (one field only). Might aswell be a general doctor (GP) that knows a little bit of all fields. I think you know what I mean. Let's learn the basics of the general stuffs first (the core of the language), I can them later-on move-on to other fields such as database, etc. And so, the book must not concentrate on one field only such as to build CMS or Social Network Account Logins or Forums or Database (MySql) because then I'd only learn one aspect of php and not the basics. In short, I want to learn the basics of the language and get a strong background in it. I prefer to build php scripts for Unix/Linux, Apache Webserver using MySql database. Book must teach step by step. Must teach A, B, C then 1, 2, 3 and 1+1=2, 2*2=4, 5-2=3, 25/5=5 and so on before jumping into the algebra and geometry (if you understand what I mean when we speak in terms of learning basic English and Maths). I don't want to program in one version and then see my webhost uses another version. Currently, my webhost is Hostgator. If I have come to the wrong department/category then kindly forward this message/post to whoever can help. I await every php lover's reply. Q3. Where did you learn php ? WHich website you used and which paper book ? Were they good or not so good or bad ? PS - What do you think about this book: http://www.amazon.co.uk/PHP-Programming-Ultimate-Course-Beginners-ebook/dp/B00PSNRK16/ref=sr_1_12?s=books&ie=UTF8&qid=1429028734&sr=1-12&keywords=php+5 It seems it's not a paper version. Do you reckon it will do the job or not ? PPS - if you can't recommend any paper books then do you recommend any website where I can go and printout the tutorials ? The website must qualify all that I said earlier about the book. Anyway, I was expecting the Php Board to provide basic teachings of the language on their website but I'm disappointed to see they don't! Thank You Mr. Ali
  10. I am trying to change the class of a button if a conditon is not met ( if(strlen($username) < 5) ) this is my code : <?php $buttonClass = 'btn btn-primary'; ?> <?php if(isset($_POST['name']) && $_POST['name'] != ""){ $username = preg_replace('#[^a-z0-9]#i', '', $_POST['name']); $quer = "SELECT * FROM users WHERE username = '$username'"; $resu = mysqli_query($dbc,$quer); $check = mysqli_num_rows($resu); if(strlen($username) < 5){ echo '<span class = "glyphicon glyphicon-remove" style = "color:red"> More then 4 caracters </span>'; $buttonClass = 'btn btn-primary disabled'; exit(); } elseif(is_numeric($username[0])){ echo '<span class = "glyphicon glyphicon-remove" style = "color:red"> First character mst be a letter </span>'; $buttonClass = 'btn btn-primary disabled'; exit(); } elseif($check < 1){ echo '<span class = "glyphicon glyphicon-ok" style = "color:green"> ' . $username . ' is available</span>'; }else{ echo '<span class = "glyphicon glyphicon-remove" style = "color:red"> This username is already taken </span>'; $buttonClass = 'btn btn-primary disabled'; exit(); } } ?> <script type="text/javascript" language = "javascript"> function checkUsername () { var status = document.getElementById("usernamestatus"); var u = document.getElementById("username").value; if(u != "") { status.innerHTML = 'Se verifica...'; var hr = new XMLHttpRequest(); hr.open("POST","register.php",true); hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); hr.onreadystatechange = function(){ if(hr.readyState == 4 && hr.status == 200){ status.innerHTML = hr.responseText; } } var v = "name="+u; hr.send(v); } } </script> AND this is my html(under the php and the script) <div class="form-group"> <label for="username" class="col-lg-2 control-label">Username:</label> <div class="col-lg-10"> <input type="text" name = "username" class="form-control" id="username" onkeyup="checkUsername()"> <br><div class = "userspan"> <span style = "font-size:15px"id = "usernamestatus"></span> </div> </div> </div> <button type="reset" class="btn btn-default">Cancel</button> <button type="submit" class="<?php echo $buttonClass ?>" id = "submit" >Submit</button> Now i know there is something to do with the exit() function but if i don't put it then the html apears on the page twice,how can i stop that from happening ? Please can someone help ?
  11. I'm trying to get a users email so it will update them when they purchased premium, I'm using Stripe as my payment system. The only way I can get it to work, is if I insert their email/id into my php page. I'm wanting the page to get the users email on it's on. $_SESSION['user_id'] = 9; $stripe = array( "secret_key" => "sk_test_rDYOBYxCErhrgGCeWQJhR4mQ", "publishable_key" => "pk_test_3mIuE3OsajKO4cnFppcDDISu" ); \Stripe\Stripe::setApiKey($stripe['secret_key']); $db = new PDO('mysql:host=127.0.0.1;dbname=blog', 'root', ''); $userQuery = $db->prepare(" SELECT id, username, email, premium FROM users WHERE id = :user_id "); $userQuery->execute(['user_id' => $_SESSION['user_id']]); $users = $userQuery->fetchObject(); I'm using ID's right now, I have to enter them on my own. The website isn't live, just testing. I can get the users email with Stripe on my checkout page by putting echo $users->email & the email shows up on the purchase screen, where normally they would have to type it. I'm not sure how to get it on purchase so it will update the user in the DB though.
  12. Is there a way to get the count of rows like this? $count = somefunctionthatreturnscount(mysqli_query($mysqli, "SELECT COUNT(*) FROM table")); Instead of... $count = mysqli_num_rows(mysqli_query($mysqli, "SELECT id FROM table")); //or even... $count = mysqli_fetch_array(mysqli_query($mysqli, "SELECT COUNT(*) as count FROM table")); Ultimately, I want the method that will get the count the quickest and if can be done similarly to the first code and still have good performance. Thanks in advance! Update: Reported post as duplicate. Need moderate to delete duplicates as that option is not appearing for me.
  13. I have the following code, my bad if it is not in correct format... still learning. <?php $string = file_get_contents('/path/to/file'); $found = 'found'; if($string == $found){ echo "string match"; } else { echo "string does not match found"; } echo "<br>"; echo "value of string: $string"; echo "<br>"; echo "value of found: $found"; ?> The output of that says: "string does not match found". and the value for $string and $found is the same. If the value of $string and $found are not the same it still says:"string does not match found". Am I missing something or am I going nuts... Please let me know what is wrong with my code.Thanks in advance
  14. Hi Guys, Can someone please help me. I have following PHP code that works fine. The only issue I am facing is, if there is a payment thats not sucessfull I just get a blank screen, and do not receive error on the screen. However the error is dispalyed in execption, I just can catch it. CODE: <?PHP require './lib/Stripe.php'; $ccnum=$_GET['ccNum']; $ccmon=$_GET['ccExpMo']; $ccyr=$_GET['ccExpYr']; $amount=$_GET['amt']; $jobid=$_GET['JobId']; $multiply=100; $amountcents=$amount*$multiply; $cvc=172; $description='something'; if(isset($_POST)) { Stripe::setApiKey("stripe_key_here"); $payment = Stripe_Charge::create(array( 'amount' => $amountcents, 'currency' => 'gbp', 'card' => array( 'number'=> $ccnum, 'exp_month' => $ccmon, 'exp_year'=> $ccyr, 'name'=> 'some name', 'cvc'=> $cvc), 'description' => $description)); } print_r($payment); ?> Following is the error (or any other error) which I cant seem to catch as an execption. error: message: "Your card has insufficient funds." type: "card_error" code: "card_declined" charge: ch_12asdasweAAFdgooXDUd2tvKJgW Thanks a lot again for any advise. Regards,
  15. hi guys i have been trying to limit users in my registration page to no avail the code exceeds the limit user of users in the db pliz help here is my code <?php include("connect.php"); // first we write the html layout code //code to check if the user pressed the button if($_SERVER['REQUEST_METHOD'] == 'POST') { $username = mysql_real_escape_string($_POST['username']); $password = mysql_real_escape_string(md5($_POST['password'])); // retrieving the input from the user, also securing for SQL injection and encrypting the password //to md5 //now its time to check if the user input works(fields not empty) if(empty($username)) { echo ("You have to fill in a username!"); } else { if(empty($password)) { echo("you have to fill in a password!"); } else { $query= mysql_query("SELECT * FROM users WHERE username = '$username' && password='$password'"); $rowcount = mysql_num_rows($query); if ($rowcount > 4){ die("Sorry, no more users can sign up"); }else{ //if $rows = 0 username is not taken and user can be saved in the database. $user_input = mysql_query("INSERT INTO users (username,password) VALUES ('$username', '$password')"); echo ("Successful registration!"); // last thing to do is include the config.php file where the connection is to the database } } } } ?>
  16. i just created a new website for my local school i want to create a databse which will contain roll number ,marksof variosu subjects & name of students i created the database but now when i am trying to create a php script to enter students details i am having prouble in connection access denied for user 'abc'@'localhost' todatabse 'abc_db' what am i doing wrong ?? i think its because of user dont have proper privileges, how to give user privileges ?
  17. I am trying to create a page which displays user profile. I have created two classes one is dbconnect(which is database class) and the other is Profile class(which shows profile). Now I am trying to pass object of dbconnect class as arguments for the constructor of profile class. I am getting error undefined variable database_profile Here is my code of profile php class Profile{ private $user_id; private $profile_array; private $database_profile; public function __construct($user,dbconnect $database_link){ $this->user_id = $user; $this->database_profile = $database_link; } public function make_array(){ $sql = "SELECT * FROM users WHERE id = '$this->user_id'"; $result = $database_profile->run_query($sql); $profile_array = mysqli_fetch_array($result, MYSQLI_ASSOC); echo $profile_array['first_name']; } public function show_profileinfo(){ } public function profilepic(){ return $profile_array['avatar']; } } //Loads database $database_connect = new dbconnect("localhost","root",""); $database_connect->select_database("selftest"); //Loads Profile $profile = new Profile($_SESSION['userid'],$database_connect); $profile->make_array(); Here is my code of dbconnect class class dbconnect{ public $database_selected; private $data_select; public function __Construct($host,$user,$pass){ $this->database_selected = mysqli_connect($host,$user,$pass); if (!$this->database_selected) echo "Connection to database failed"; else echo "Connection to database successful!"; } public function select_database($database_name){ $this->data_select = mysqli_select_db($this->database_selected, $database_name); if(!$this->data_select) echo "Connection to table failed"; else echo "Connection to table successful!"; } public function close_connection(){ $close = mysqli_close($this->database_selected); if ($close) echo "<p>Connection successfully closed</p>"; else echo "<p>Failure in closing connection</p>"; } //Returns aither true or false public function run_query($sql){ return $query_success = mysqli_query($this->database_selected,$sql); } }
  18. I's trying to transform data from mysql into something like $books below but it doenst seem to be working $books = array( "phil" => array("my girl" => 2.5, "the god delusion" => 3.5, "tweak" => 3, "the shack" => 4, "the birds in my life" => 2.5, "new moon" => 3.5) ) this is how I tried doing: $sql = "SELECT * from rating where user_id=11 limit 5"; $db_result = mysql_db_query($dbname,$sql) or trigger_error(mysql_error()); $num_rows = mysql_num_rows($db_result) or trigger_error(mysql_error()); while ($row = mysql_fetch_array($db_result)) { $one = $row['bookId']; $two = $row['user_id']; $three = $row['rating']; $ArraY= array( $two => array($one=>$three) ); print_r($ArraY); } but this is what i get : Array ( [11] => Array ( [123715] => 5 ) ) Array ( [11] => Array ( [140329] => 5 ) ) Array ( [11] => Array ( [3083854] => 4 ) ) Array ( [11] => Array ( [871236761] => 1 ) ) Array ( [11] => Array ( [451179757] => 1 ) ) Array ( [11] => Array ( [451403886] => 3 ) ) Array ( [24] => Array ( [044661095X] => 4 ) ) Array ( [24] => Array ( [014010268X] => 1 ) ) Array ( [24] => Array ( [812576063] => 5 ) ) Array ( [24] => Array ( [038076654X] => 1 ) ) instead of something like: Array ( [phil] => Array ( [my girl] => 2.5 [the god delusion] => 3.5 [tweak] => 3 [the shack] => 4 [the birds in my life] => 2.5 [new moon] => 3.5 ) [sameer] => Array ( [the last lecture] => 2.5 [the god delusion] => 3.5 [the noble wilds] => 3 [the shack] => 3.5 [the birds in my life] => 2.5 [new moon] => 1 ) [john] => Array ( [a thousand splendid suns] => 5 [the secret] => 3.5 [tweak] => 1 ) [peter] => Array ( [chaos] => 5 => 3.5 ) [jill] => Array ( [the last lecture] => 1.5 [the secret] => 2.5 [the noble wilds] => 4 [the host: a novel] => 3.5 [the world without end] => 2.5 [new moon] => 3.5 ) [bruce] => Array ( [the last lecture] => 3 [the hollow] => 1.5 [the noble wilds] => 3 [the shack] => 3.5 [the appeal] => 2 [new moon] => 3 ) [tom] => Array ( [chaos] => 2.5 ) ) Any help with how i can transform that will be much appreciated THANKS
  19. Hello, I have created two tables "category" and "subcategory". So what i need to do is that i have organized two combobox and one will retrieve values from category table and populate the data. However, i need to fill the other combobox when one selected from the category combobox and populate all the values from subcategory table. I really thank you all for helping me out. Looking for great answer. Thank you in advance. Fekade
  20. I want to disable the checkboxes that are already booked..........I have done some coding but it disables just only one checkbox...and others remain unchecked.....i am new to php and so i can't figure it out..... Here is my try--> <!DOCTYPE html> <html> <body> <form action="" method="POST"> <input type="submit" name="submit" value="submit"/></br></br> </form> <fieldset> <?php if(isset($_POST['submit'])) { $con=mysqli_connect("host","abc","abc","demo"); $focus=array(); $result=mysqli_query($con,"select focus from chkdemo where statuss='Booked'"); while($row=mysqli_fetch_assoc($result)) { $focus[]=array($row['focus']); } ?> Art <input type="checkbox" name="focus[]" value="Art" <?php if(in_array("Art",$focus)) { ?> disabled="disabled" checked="checked" <?php } ?> ></br></br> Dance <input type="checkbox" name="focus[]" value="Dance" <?php if(in_array("Dance",$focus)) { ?> disabled="disabled" checked="checked" <?php } ?> ></br></br> Music <input type="checkbox" name="focus[]" value="Music" <?php if(in_array("Music",$focus)) { ?> disabled="disabled" checked="checked" <?php } ?> ></br></br> <?php } ?> </fieldset> </body> </html>
  21. In the beginning, I had just one unique key set up in a table: username. When a username duplication in the Registration form was entered, I'd catch it and handle it like this: catch (PDOException $ex){ if ($ex->getCode() == 23000){ //Check if it's a duplciate key violation. $unameErr = '* Username already in use'; } Today, in the same table, I added another unique key: email. Now that I have two unique keys that will both have the same violation, how can I tell which one was the duplicate so I can provide the correct error to the user?
  22. Hi, I have my login system working fine with sessions. Now I want to use access levels. So if user 1 with access level 1 logs in, he redirects to profile.php. If user 2 with access level 2 logs in, he redirects to main_stats.php. Here is what I have so far for my login.php, however it is not reading the $user_id nor the $access_id: http://codepad.viper-7.com/Ck0Tsr Wondering if anyone can help?
  23. Hey guys I am struggling here. I am making an recipe website and right now attempting to create an search engine, to search the database for recipes. BUT the search form has form filters the user can edit such as one dropdown menu with preptime, another with what type of meal type, another like what type of cooking method etc etc. So how would the php if statements, query look like, I am not very experienced in sql so that is an main reason I am having such an struggle. Thanks
  24. Hello guys, am new to this forum. I have a question that i'd like some help with, this is part of my dissertation project. So i'm creating a system that will gather hardware parts from the database manually (I have 7 hardware parts for each component which is cpu,gpu,psu,motherboard,ram and case) for each and the user will input the price tag in the listbox ($300-$450) for example and the system will display hardware parts from the database within that price range. How can I link the listbox with the database? And how can I make the total price from hardware parts display depending on what the user pressed? Thanks
  25. Hi all. I have two tables where the username is what they have in common. i want to perform a join for both tables but i'm having problems with mysql joins. //to get the desire result individually i did //table one $stmt = $pdo->query("SELECT * FROM tableone WHERE username = '$_GET[id]'"); $row = $stmt->fetch(PDO::FETCH_ASSOC); $credit_score = $row['credit_score']; $acct_num = $row['acct_num']; $acct_name = ucwords($row['surname']) ." ". ucwords($row['firstname']); $username = $row['username']; if($credit_score ==3){ $bill_limits = 2000; }elseif($credit_score ==2){ $bill_limits = 1000; }elseif($credit_score ==1){ $bill_limits = 500; } //table two $stmt=$pdo->query("SELECT SUM(amt) as bill FROM tabletwo WHERE username = '$_GET[id]' AND relationship = 'PARENT'"); $row = $stmt->fetch(PDO::FETCH_ASSOC); $bill = $row['bill']; $service_charge_for_limits = '0.05' * $bill; $tax_rate_for_limits = '0.13' * $service_charge_for_limits; $bill_sum = $tax_rate_for_limits + $service_charge_for_limits + $bill; Approved Bill Limits = $<?php echo number_format($bill_limits,2); ?> <br> Bill Limits Used = $<?php echo number_format($bill_sum,2); ?> <br> <?php $available_limits = $bill_limits - $bill_sum; ?> Bill Limits Available = $<?php echo number_format($available_limits,2); ?> The above gives me the correct result, but now i have another page where i want to all the clients and their corresponding available limits, used limits and approve limits form table two and other information from table one On the page i have $stmt = $pdo->prepare("SELECT * FROM tableone WHERE status = 'COMPLETED' ORDER BY id DESC LIMIT $start, $limit"); $stmt->execute(); $num_rows = $stmt->rowCount(); echo "<table width='100%' class='table-responsive table-hover table-condensed table-striped'>"; echo "<tr> <th bgcolor='#444444' align='center'><font color='#fff'>Account Number</th> <th bgcolor='#444444' align='center'><font color='#fff'>Subscriber's Name</font></th> <th bgcolor='#444444' align='center'><font color='#fff'>Username</font></th> <th bgcolor='#444444' align='center'><font color='#fff'>Limits ($)</font></th> <th bgcolor='#444444' align='center'><font color='#fff'>View Profile</font></th> <th bgcolor='#444444' align='center'><font color='#fff'>Delete Account</font></th> </tr>"; // keeps getting the next row until there are no more to get while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { // Print out the contents of each row into a table echo "<tr><td>"; echo $row['acct_num']; echo "</td><td>"; echo ucwords($row['surname']." ". $row['firstname']); echo "</td><td>"; echo $row['username']; echo "</td><td>"; $credit_score = $row['credit_score']; if($credit_score ==3){ $bill_limits = 2000; }elseif($credit_score ==2){ $bill_limits = 1000; }elseif($credit_score ==1){ $bill_limits = 500; } echo number_format($bill_limits, 2); echo "</td><td>"; echo "<a href='view-client-profile.php?id={$row['username']}'>view more</a>"; echo "</td><td>"; echo "<a href='delete-account.php?id={$row['username']}'>Delete Account</a>"; echo "</td></tr>"; //echo "</td><td>"; //echo "<a href='settle.php?id={$row['acct_num']}'>Points</a>"; } echo "</table>"; How ca i join tableone and tabletwo (plus sum)
×
×
  • 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.