Jump to content

Search the Community

Showing results for tags 'mysql'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

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


Languages

Found 276 results

  1. hello everyone m New In Php anyone Can Help I Want Upload Mutltifile with form name 2nd name file 1 file 2 file 3 file 4 than i want save in mysql like this id name 2ndname file3 file 4
  2. Hi guys, I'm new in PHP. I cannot find tutorial about how to get all categories article is listed in together with article title, author printed on the article list. I have 4 tables in DB: articles = DB for articles detailse: id, title, user_id, post_date articles_categories = id, category_id categories = category_id, category_name users = user_id, user_name, user_mail I want to do this: Which script logic do you suggest? Any kind of help is welcomed.
  3. Unknown column 'col' in 'field list' Is the error message, i tried all kinds of backticks, and quotes but doesnt work So I was thinking, how can I check (in phpmyadmin or in the mysql console) whether a table has the columns that are needed?
  4. My script gives a sort of an errormessage. Actually i can see a part of the code at the output screen in the browser. Like wth the php parser you get a notice or fatal error, but in this case the script does not work. How can i avoid these problems in the future?
  5. The idea is to insert with the browser a multiple input field, a loop, into mysql database. Is the solution to first put this loop input variable in an array and after that create in this case multible tables? Or is an array not necessary?
  6. I have a script and a MYSQL query its supossed to create a new table $variable now I have $sql = "CREATE TABLE '$variabele' "; But it doesnt work. I think CREATE TABLE works for constants not for variables. Which query should I use?
  7. Here's a fully working login system. Where users can sign up and access a members page. Features Include: - Login & Sign Up Page - Members Page Only **NOTE: I have not added any security code, you'll need to add this by yourself...** Step 1: Creating a Login and Sign Up Form. This will be a simple login page where users can enter their username and password, then click the submit button to access the members page. "login.php" will be the script that will be executed when they login. This processes the user information entered to check the validity through a database of users. HTML LOGIN FORM:<form method="post" action="login.php"><input type="text" placeholder="username" name="username"><input type="password" placeholder="password" name="password"><input type="submit" value="Submit"></form> This will be a simple register page where users can enter their desired username and password, then click the submit button to register button to make an account. "register.php" will be the script that will be executed when they register. This processes the user information and enters the information to the database <form method="post" action="register.php"><input type="text" placeholder="Desired Username"><input type="password" placeholder="Desired Password"><input type="password" placeholder="Password Again"><input type="submit" value="Register"></form> Step 2: Creating the login.php and register.php scripts Login Script<?phpsession_start(); //Starts User Session... will explain laterinclude("connect.php")//I'm going to assume you know how to connect to a database.$username = $_POST["username"];$password = $_POST["password"];//Sanitize DATA HERE//Assuming you have the corresponding column names...$q = mysqli_query($connect, "SELECT * FROM users WHERE username='$username' AND password='$password' ")$numrows = mysqli_num_rows($q);//Here we get the number of rows that correspond with the users informationif($numrows == 1){//If the number of rows is equal to 1, let them loginwhile($rows = mysqli_fetch_assoc($q)){//Here we retrieve values from database and initiate SESSION Variables $_SESSION["username"] = $row["username"]; $_SESSION["password"] = $row["password"];}header("location: memberspage.php")//redirect to members page... information correct.} else {header("location: index.php")//go back to login page... information incorrect.//error message here...} Register Script<?phpsession_start(); //Starts User Session... will explain laterinclude("connect.php")//I'm going to assume you know how to connect to a database.$username = $_POST["username"];$password = $_POST["password"];$password2 = $_POST["confirm"];//Sanitize DATA HEREif($password == $password2){//Assuming you have the corresponding column names...$q = mysqli_query($connect, "SELECT * FROM users WHERE username='$username'")$numrows = mysqli_num_rows($q);//Check if username is taken...if($numrows == 0){//If the number of rows is equal to 0, let them register$q = mysqli_query($connect, "INSERT INTO users (username, password) VALUES ('$username', '$password")header("location: index.php")//redirect to login page//login success message here} else {header("location: index.php")//go back to login page//username taken message}} else {//password no match message} Step 3: Members Page This is the members page... you can only access this page after login. memberspage.php<?phpif(!isset($_SESSION["username"])){//IF user is not logged in, redirect to login page. This checks whether the username session var has been created yet.header("location: index.php");}//else... load the members page?><!DOCTYPE html><!--HTML HERE FOR MEMBERS PAGE--> This is pretty much it... Remember to change column names where necessary... Don't forget the connect.php file ! Its is suggested you change mysqli_query() to prepared statements. You can do this on your own.
  8. Im, a beginner and i just wanna know how to save html table data to mysql database using php..please help..thank you
  9. One example of a multiple query, which runs fine in my server is: SELECT city, name FROM customers However, another way (though not a better way) of writing same has been running fine in a tutorial I saw, but is not running in my case: SELECT city FROM customers; SELECT name FROM customers; I would appreciate any thought on why it runs for that person and not for me, noting that there was no typos in my queries, which I attempted many times. MySQL Server version: 5.6.16, Xampp 1.8.33 for windows.
  10. I want to update users when they purchase premium by their email OR database ID, either one would work, BUT the only way it's working for me at the moment is by me entering their ID in the $_SESSION at the top. I want the page to get the users ID OR email after they purchase. I have asked this many places and have got no answer, people basically tell me to just type it. That would be crazy to do that for every single user. If you have an answer, PLEASE! I literally beg for you to copy the code above and place stuff where it needs to be, I've been stuck for days/weeks. I've tried EVERYTHING, except the right thing. Nothing is working for me on this, I also can't find anything on Google about it. I'm not an expert with PHP, so I may be missing bits, if I am, feel free to tell me I'm doing it wrong and let me know what I need to do. <?phprequire_once ('vendor/autoload.php');$_SESSION['user_id'] = '?';$stripe = array( "secret_key" => "sk_test_vDYOBYxCErhrgGCeWQJhR4mQ", "publishable_key" => "pk_test_4mIuE3OsajKO4cnFppcDDISu" ); StripeStripe::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 = id "); $userQuery->execute(['user_id' => $_SESSION['user_id']]); $users = $userQuery->fetchObject();
  11. hello so i created a registration page in html and a php code to connect to a database and enter the information to the database that all works. Now i want to ask if the user wants to log in would they need a separate php code to have a sort of certification that the account is valid? i made a html page for login but i need it to look back to the database to see if the user is registered so they can log in, not just anyone can log in...any ideas? or advice where i can find information about this? i see a lot of tutorials for making a log in page, making a registration page but how about when someone registers and wants to log in but to make sure the database can also check to see if the user is registered.
  12. Cat and sub category Table (cat_tbl) : id | cat_n | parent_id1 | cat | 02 | dog | 03 | tiger | 24 | lion | 05 | abc | 06 | bcd | 3 Now i have a product table as below (prod_tbl) : id | pwght | cid | cpid10 | 1.2 | 1 | 011 | 2.4 | 2 | 012 | 3.4 | 2 | 013 | 4.5 | 6 | 3 and user final weight product table is below (userprod_tbl) id | pwght | cid | cpid | prod_id ( is above prod_tbl primary id )1 | 1.1 | 1 | 0 | 102 | 2.3 | 2 | 0 | 113 | 3.1 | 3 | 2 | 124 | 4.0 | 6 | 3 | 13 **RESULT : ( OUTPUT WHICH I WANT ) IS comparison of prod_tbl with userprod_tbl as below :** Prod tbl Userprod tblcat 1.2 cat 1.1dog 2.4 dog -- -- 2.3dog 3.4 dog tiger -- 3.1dog 4.5 dog tiger bcd 4.0 Hence in above result 2.4,3.4,4.5 are belong to Parent 2**But i am getting as below** Prod tbl Userprod tblcat 1.2 cat 1.1dog 2.4 dog -- -- 2.3dog 3.4 dog tiger -- 3.1 here i am not getting 4.5 value as 4.5 has 6,3 relation from above prod table but its parent of 2**Below is my query which i have return:** SELECT pt.pwght , upt.pwght ,ct.cat_n,uct.cat_n,umct.cat_nFROM prod_tbl AS ptLEFT JOIN userprod_tbl AS upt ON (pt.id = upt.prod_id)LEFT JOIN cat_tbl AS ct ON pt.packet_id = ct.idLEFT JOIN cat_tbl AS uct ON upt.packet_id = uct.idLEFT JOIN cat_tbl AS umct ON upt.parent_packet_id = umct.id Please let me know what is missingThanks
  13. Hi everybody!Im newbie to php. please,suppose we have a MYSQL DATABASE with table CUSTOMERS.In the page: addCustomer.php, we echoed this table and it returned us a number of rows.on the same page, we have a form that contains empty fields. (name, birth, adress).Questions:How to add a button front of each displayed row? and how to when we click on the related button we fill the content of the form and submit it to the table CUSTOMERS. we want to verify if the customer exists when echoing...if so we click on the relative row, and the form is filled. if no we fill the form manually thanks <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><title>Untitled Document</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css"><!--.style2 {font-size: 36px}.style4 {font-size: 24px}#hauttableau { background-color:black; color:white; text-align:center; padding:5px;}--></style><script language="JavaScript" type="text/JavaScript"><!--function MM_reloadPage(init) { //reloads the window if Nav4 resized if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) { document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }} else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();}MM_reloadPage(true);//--></script></head><body><p align="left" class="style2">NOUVEAU CLIENT </p><form name="form1" method="post" action="insert_pdo_ajout_client.php"> <p class="style4"></p> <p><span class="style4">CLIENT</span> </p> <p> NOM CLIENT<input name="nomclientField" type="text" id="nomclientField"> <p> PRENOM <input name="prenomclientField" type="text" id="prenomclientField"> <p>ADRESSE <input name="adresseclientField" type="text" id="adresseclientField"></p> <p>DATE NAISSANCE <input name="datedenaissanceField" type="text" id="datedenaissanceField"></p> <p> CIN <input name="cinclientField" type="text" id="cinclientField"> </p> <p>TEL <input name="telclientField" type="text" id="telclientField2"> </p> <p> <input type="submit" name="Submit" value="ENREGISTRER"> </p></form><p class="style2"> </p><?phpecho "<table style='border: solid 2px black;' class= 'hauttableau'>"; echo "<tr><th>Id</th><th>Firstname</th><th>Lastname</th></tr>";class TableRows extends RecursiveIteratorIterator { function __construct($it) { parent::__construct($it, self::LEAVES_ONLY); } function current() { return "<td style='width: 150px; border: 1px solid black;'>" . parent::current(). "</td>"; } function beginChildren() { echo "<tr>"; } function endChildren() { echo "</tr>" . "n"; }}$servername = "localhost";$username = "root";$password = "root";$dbname = "zg";try { $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $stmt = $conn->prepare("SELECT idclient, nomclient,prenomclient,datedenaissanceclient,adresseclient, cinclient,telclient FROM client"); $stmt->execute(); // set the resulting array to associative $result = $stmt->setFetchMode(PDO::FETCH_ASSOC); foreach(new TableRows(new RecursiveArrayIterator($stmt->fetchAll())) as $k=>$v) { echo $v; }}catch(PDOException $e) { echo "Error: " . $e->getMessage();}$conn = null;echo "</table>";?> </body></html>
  14. I love what w3schools is doing with the SQL tutorial - good stuff. I noticed that one of the most fundamental elements of w3schools (the "Try it now" button) goes missing about half-way through the SQL Tutorial. May I ask why? I teach sql at a local community colleg. I have gone through several textbooks with mixed results, and I am always keeping my eyes open for new ways to teach. I would love to incorporate w3schools SQL tutorial into my class; do you have a db dump available for download of the tables you use? One of my lessons will be having students figuring out how to get the data from the tutorial into a local database, but having the entire dataset available up front would be handy. If such a db dump is not available, no worries - easy enough to generate one. Thanks again for your time and attention.
  15. I need to upload my images to a folder and need the image name with file type to be places in a mysql database so it can be accessed by another page. This is my php where everything works except uploading the image name to the database; Instaead the column is populated with the word array. Does anyone know how to fix this. MySql column is set to varchar(50). <?php require_once("connect.php"); $name = $_POST['job_name']; $img = $_FILES['job_timg']; $desc = $_POST['job_desc']; $plug = "INSERT INTO tbl_job VALUES (NULL,'".$name."','".$desc."', '".$img."')"; $Set = mysql_query($plug); if($Set==1){ $qJob = "SELECT * FROM tbl_job WHERE job_name = '".$name."' "; $Result = mysql_query($qJob); $row = mysql_fetch_array($Result); $lastID = $row['job_id']; $Link1 = "INSERT INTO tbl_l_ji(ji_id, job_id, image_id) VALUES(NULL, '".$lastID."','".$cat."')"; $place1 = mysql_query($Link1); header("Location: index.php"); }else{ } if($_POST){// $_FILES["file"]["error"] is HTTP File Upload variables $_FILES["file"] "file" is the name of input field you have in form tag.if ($_FILES["job_timg"]["error"] > 0){// if there is error in file uploadingecho "Return Code: " . $_FILES["job_timg"]["error"] . "<br />";}else{// check if file already exit in "images" folder.if (file_exists("_/img/" . $_FILES["job_timg"]["name"])){echo $_FILES["job_timg"]["name"] . " already exists. ";}else{ //move_uploaded_file function will upload your image. if you want to resize image before uploading see this link http://b2atutorials.blogspot.com/2013/06/how-to-upload-and-resize-image-for.htmlif(move_uploaded_file($_FILES["job_timg"]["tmp_name"],"_/img/" . $_FILES["job_timg"]["name"])){// If file has uploaded successfully, store its name in data base$query_image = "INSERT INTO tbl_job (job_timg) VALUES ('".$_FILES['job_timg']['name'].")";if(mysql_query($query_image)){echo "Stored in: " . "_/img/" . $_FILES["job_timg"]["name"];}else{echo 'File name not stored in database';}}}}}?> My Form: div class="container"> <div class="row"> <div class="twelvecol last"> <form action="add_site.php" method="post" enctype="multipart/form-data"> <!--add in the enctype in order to handle file management--> <label>Name:</label><br> <input name="job_name" type="text" size="32"><br><br> <label>Job Front Image:</label><br> <input name="job_timg" type="file" size="32"><br><br> <label>Description:</label><br> <textarea name="job_desc" cols="80" rows="10"></textarea><br><br> </select><br><br> <input type="submit" value="Add Job"> </form> </div> Thank you, Connor McDonald
  16. RaRa3

    registration php

    hello so i am making a registration page using html and php, i need to make the information send to mysql that i made with table but i never made select statements..i am not sure on how to make it i need help i am new to this so please bare with me. So I this code to connect to mysql none I am not sure how to fix it i know there must be a problem with the code for the submit line and with the isset. I got them from another user but made minor changes to fit my database. My database has 2 tables one named UserAccount with the information listed in the registration page and then another table named Cart for purchases to be made. Please if you can help me with my code or if you see other errors i think i might have an error with my php where i put firstName, and etc. and if you know any other material or links that would help me for making product information and a cart send to a database if you can share it, im trying but having many issues
  17. Cat and sub category Table (cat_tbl) : id| cat_n | parent_id1 | cat | 02 | dog | 03 | tiger | 24 | lion | 05 | abc | 06 | bcd | 3 Now i have a product table as below (prod_tbl) : id | pwght | cid | cpid10 | 1.2 | 1 | 011 | 2.4 | 2 | 012 | 3.4 | 2 | 013 | 4.5 | 6 | 3 and user final weight product table is below (userprod_tbl) id | pwght | cid | cpid | prod_id ( is above prod_tbl primary id )1 | 1.1 | 1 | 0 | 102 | 2.3 | 2 | 0 | 113 | 3.1 | 3 | 2 | 124 | 4.0 | 6 | 3 | 13 **RESULT : ( OUTPUT WHICH I WANT ) IS comparison of prod_tbl with userprod_tbl as below :** Prod tbl Userprod tblcat 1.2 cat 1.1dog 2.4 dog -- -- 2.3dog 3.4 dog tiger -- 3.1dog 4.5 dog tiger bcd 4.0 Hence in above result 2.4,3.4,4.5 are belong to Parent 2**But i am getting as below** Prod tbl Userprod tblcat 1.2 cat 1.1dog 2.4 dog -- -- 2.3dog 3.4 dog tiger -- 3.1here i am not getting 4.5 value as 4.5 has 6,3 relation from above prod table but its parent of 2 **Below is my query which i have return:** SELECT pt.pwght , upt.pwght ,ct.cat_n,uct.cat_n,umct.cat_nFROM prod_tbl AS ptLEFT JOIN userprod_tbl AS upt ON (pt.id = upt.prod_id)LEFT JOIN cat_tbl AS ct ON pt.packet_id = ct.idLEFT JOIN cat_tbl AS uct ON upt.packet_id = uct.idLEFT JOIN cat_tbl AS umct ON upt.parent_packet_id = umct.id Please let me know what is missingThanks
  18. I have a mySQL posts table, a files table, and a relationships table. I need to sum file download counts grouped by the post the files are associated with. SELECTp.id, p.post_title, count(d.download_id) FROM posts p INNER JOIN file_log d ON p.id = d.file_idgroup by p.post_title The above query works as long as the titles of the files are the same, which is not always the case. I really need to group them by their relationship to the post they are associated with. The relationships are stored in relationships r, which shows r.post_id (which is p.id from posts), and r.file_id (which is d.file_id from file_log) I have tried a few subqueries, but I am not sure how to join the relationships table to my query and group counts by r.post_id Thanks for any help.
  19. producttable : id | mid | pid | owgh | nwgh | 1 3 12 1.5 0.6 2 3 12 1.5 0.3 3 3 14 0.6 0.4 4 3 15 1.2 1.1 5 4 16 1.5 1.0 6 4 17 2.4 1.2 7 3 19 3.0 1.4 8 3 19 3.0 1.2 I need result in while loop as **below** : as per mysql query $sql = "SELECT pid,owgh,nwgh from produttable WHERE mid = 3 "; **RESULT I WANT AS BELOW :** Product Id | Old weight | New weight --------------------------------------- 12 1.5 0.6 12 1.5 0.3 Tot: 3.0 0.9 -------------------------------- 14 0.6 0.4 Tot: 0.6 0.4 -------------------------------- 15 1.2 1.1 Tot: 1.2 1.1 -------------------------------- 19 3.0 1.4 19 3.0 1.2 Tot: 6.0 2.6 $query = mysql_query($sql); echo"<table> <tr> <td> Product Id </td> <td> Old Weight </td> <td> New Wight </td> </tr> "; while($row = mysql_fetch_array($query )){ echo "<tr>"; echo "<td>".$row['pid']."</td>"; echo "<td>".$row['owgh']."</td>"; echo "<td>".$row['nwgh']."</td>"; echo "</tr>"; echo "<tr><td>-----</td> <td>Tot : </td> <td> </td></tr>"; } echo " </table>"; But result i am getting is as below Product Id | Old weight | New weight --------------------------------------- 12 1.5 0.6 -------------- Tot 12 1.5 0.3 ---------------Tot 14 0.6 0.4 ---------------Tot 15 1.2 1.1 ---------------Tot 19 3.0 1.4 ---------------Tot 19 3.0 1.2which i dont want , **i want as below** : Product Id | Old weight | New weight --------------------------------------- 12 1.5 0.6 12 1.5 0.3 Tot: 3.0 0.9 -------------------------------- 14 0.6 0.4 Tot: 0.6 0.4 -------------------------------- 15 1.2 1.1 Tot: 1.2 1.1 -------------------------------- 19 3.0 1.4 19 3.0 1.2 Tot: 6.0 2.6 **Update : 27/3/2015**Can i get below result, with sum of each Product Id | Old weight | New weight --------------------------------------- 12 1.5 0.6 12 1.5 0.3 Tot: 3.0 0.9 -------------------------------- 14 0.6 0.4 Tot: 0.6 0.4 -------------------------------- 15 1.2 1.1 Tot: 1.2 1.1 -------------------------------- 19 3.0 1.4 19 3.0 1.2 Tot: 6.0 2.6------------------------------------------Grand Total : 6.3 5 Note in above Old weight : repeat value is not added thats 1.5 , 3.0 is coming twice hence while addition takensingle of it**OR** Product Id | Old weight | New weight --------------------------------------- 12 1.5 0.6 1.5 0.3 Tot: 3.0 0.9 -------------------------------- 14 0.6 0.4 Tot: 0.6 0.4 -------------------------------- 15 1.2 1.1 Tot: 1.2 1.1 -------------------------------- 19 3.0 1.4 3.0 1.2 Tot: 6.0 2.6------------------------------------------ Grand Total : 6.3 5Note in above Old weight : repeat value is not added thats 1.5 , 3.0 is coming twice hence while addition takensingle of it as product id 12, 19 are coming twice hence shown once with its resp valuePlease help me, if i am wrong in HTML tr td format please correct me , it not necessary to get in same table tr,td ..i just want my result in above format
  20. producttable : id | mid | pid | owgh | nwgh | 1 3 12 1.5 0.6 2 3 12 1.5 0.3 3 3 14 0.6 0.4 4 3 15 1.2 1.1 5 4 16 1.5 1.0 6 4 17 2.4 1.2 7 3 19 3.0 1.4 8 3 19 3.0 1.2 I need result in while loop as **below** : as per mysql query $sql = "SELECT pid,owgh,nwgh from produttable WHERE mid = 3 ";**RESULT I WANT AS BELOW :** Product Id | Old weight | New weight --------------------------------------- 12 1.5 0.6 12 1.5 0.3 Tot: 3.0 0.9 -------------------------------- 14 0.6 0.4 Tot: 0.6 0.4 -------------------------------- 15 1.2 1.1 Tot: 1.2 1.1 -------------------------------- 19 3.0 1.4 19 3.0 1.2 Tot: 6.0 2.6 $query = mysql_query($sql); echo"<table> <tr> <td> Product Id </td> <td> Old Weight </td> <td> New Wight </td> </tr> "; while($row = mysql_fetch_array($query )){ echo "<tr>"; echo "<td>".$row['pid']."</td>"; echo "<td>".$row['owgh']."</td>"; echo "<td>".$row['nwgh']."</td>"; echo "</tr>"; echo "<tr><td>-----</td> <td>Tot : </td> <td> </td></tr>"; } echo " </table>"; But result i am getting is as below Product Id | Old weight | New weight --------------------------------------- 12 1.5 0.6 -------------- Tot 12 1.5 0.3 ---------------Tot 14 0.6 0.4 ---------------Tot 15 1.2 1.1 ---------------Tot 19 3.0 1.4 ---------------Tot 19 3.0 1.2which i dont want , **i want as below** : Product Id | Old weight | New weight --------------------------------------- 12 1.5 0.6 12 1.5 0.3 Tot: 3.0 0.9 -------------------------------- 14 0.6 0.4 Tot: 0.6 0.4 -------------------------------- 15 1.2 1.1 Tot: 1.2 1.1 -------------------------------- 19 3.0 1.4 19 3.0 1.2 Tot: 6.0 2.6 **Update : 27/3/2015**Can i get below result, with sum of each Product Id | Old weight | New weight --------------------------------------- 12 1.5 0.6 12 1.5 0.3 Tot: 3.0 0.9 -------------------------------- 14 0.6 0.4 Tot: 0.6 0.4 -------------------------------- 15 1.2 1.1 Tot: 1.2 1.1 -------------------------------- 19 3.0 1.4 19 3.0 1.2 Tot: 6.0 2.6**OR** Product Id | Old weight | New weight --------------------------------------- 12 1.5 0.6 1.5 0.3 Tot: 3.0 0.9 -------------------------------- 14 0.6 0.4 Tot: 0.6 0.4 -------------------------------- 15 1.2 1.1 Tot: 1.2 1.1 -------------------------------- 19 3.0 1.4 3.0 1.2 Tot: 6.0 2.6 as product id 12, 19 are coming twice hence shown once with its resp valuePlease help me, if i am wrong in HTML tr td format please correct me , it not necessary to get in same table tr,td ..i just want my result in above format
  21. Hello again my friends I've had some problems again, I'm trying to select the last id, or the max(id) but it keeps returning resource id. <?php $getLastData = mysql_query("SELECT MAX(id) FROM `database`.`forumTopics` WHERE category='$outData->id'");$getInfo = mysql_fetch_object(mysql_query("SELECT * FROM `database`.`forumTopics` WHERE id='$getLastData'")) or die("Error: ".mysql_error());?> Hope anyone can help Thanks, Kris
  22. Hey you all! I'm sorry if it's in the wrong topic, but couldn't find a more suitable one.I've struggled with my code for the past two days, but somehow can't get it to work.First off HTML+PHP+MySQL code: if($_POST){ $name = $fgmembersite->UserFullName(); $comment = $_POST['comment']; $connect = mysql_connect("random", "ranom", "random", "random") or die(mysql_error()); if($connect){ mysql_select_db("random",$connect); $query = "INSERT INTO data(Name, Comment, date) VALUES ("" . $name . "","" . $comment . "",'DATETIME: Auto CURDATE()')"; if(mysql_query($query)){ } } else { die ("Error: " . mysql_error()); } } $connect = mysql_connect("random", "random", "random", "random"); if($connect){ mysql_select_db("random",$connect); $query7 = "SELECT * FROM data ORDER BY date DESC"; $result = mysql_query($query7); while ($row = mysql_fetch_array($result)){ echo '<br />' . $row['Name'] . ': ';; echo $row['Comment']; } } else { die ("Error: " . mysql_error()); } ?>CSS code: body{ background:#FFFFFF; font:bold 12px Arial, Helvetica, sans-serif; margin:0; padding:0; min-width:960px; color:#303030; text-align: center; } #header { background-color:#FFFFFF; color:#303030; padding:5px; list-style-type: none; margin-left:0px; padding-left:0px; min-width: 960px; } #section { margin-left: 80%; width:350px; padding:10px; } #vasak { line-height:30px; background-color:#eeeeee; height:300px; width:100px; float:left; padding:5px; } #parem { width:350px; float:left; padding:10px; } .logo img { float: left; margin-left: 10%; } .logo p { float: right; text-align: right; display:inline-block; padding: 0; } .kastike { text-align: center; } .container {width: 960px; margin: 0 auto; overflow: hidden;} #content { float: left; width: 100%;} .tervitus { margin-left: 10%; margin-top: 0; } .sein { margin-left: 10%; margin-top: 0%; } .ptekst { float: none; margin-left: 600px; } <div id="header"> <div class="kastike"> <form action = "" method = "POST"> <textarea style="resize:none" name = "comment" rows = "5" cols = "60"></textarea> <input type = "submit" value = "Postita"> </form> </div> </div> I have a header with a textarea in it, CODE:This is what I have this far:When I type something in the textarea and click "submit" - it is sent to MySQL database, after that my code reads from the table and echoes it back on the page.My 1st problem: My table has three rows: "Name - varchar" ; "Comment - varchar" ; "date - timestamp".I'd like to print all the messages in reverse order (newest post are on the top). My code at the moment sometimes works, sometimes messes it all up.Second problem - I can't make the textarea "submit" work via 'Enter'. Things I have tried this far: jQuery and JS.Third problem (with CSS). I'd like my page to look something like that: | <textbox> | | | |side| |$name 1 :| |$comment1| | | |$name 2 :| |$comment2| | | |$name 3 :| |$comment3| I'd like to read from the MySQL table and but the $name and $comment in separate <div>s. All the imported divs should be on a new line.I believe I have tried almost everything and now I'm out of ideas. Sorry if my poor skill in English messed something up.Thanks in advance!Architect
  23. Hy everyone I would like to get some kind of input for a problem I have. I've got a page (A) wich calls an guestid and selects from the DB the data. Now, I wanna do a Page ( witch is a form Thing is, I need to bring the Guestid from page (a) to page ( - also need to have a new ID (ex. clientid) for the form So far I did it with $_GET['id']; in the page ( i got: $id= (isset($_GET['id']) && is_numeric($_GET['id'])) ? $_GET['id'] : 'new'; the thing is, by opening the form I loos the guestid which I need to reecall somehow. so that there will be at the end: $ID = 'new' $guestid = $guestid for any Inputs I would be more then pleased.
  24. Hello, I have run into an issue with what i think might be special characters. Basically I have expanded on the W3 Web Tutorial. http://www.w3schools.com/website/web_spa_daas.asp I have a PhP file that successfully retrieves data form a MySql database (I call the PhP file directly from my browser and it displays the data in the correct format etc) When i then attempt to display the data in an HTML table (of the called upon PhP file ^mentioned above) it fails to display. I am pretty sure that the issue is that in several fields of the PhP query the data contains "[" and "]". Because when i remove those specific fields form the query it does display properly in the HTML table. I do WANT to display the data sets as they are including the "[" and "]" as it is critical to my end goal. (editing the data sets from the HTML table/form). I have googled and read a ton of article/blogs/tutorials with no luck on this exact issue.I did find one article that suggested all Char-Sets be set the same and that it be UTF-8 and that it be declared on all files/databases etc, so i have checked that they all do/are. example PhP file.... (the "Item", "Buy", and "Sell" fields each contain as part of the data "[" and "]" ) if i remove these three fields it works perfectly, but obviously i need them displayed. <?phpheader("Access-Control-Allow-Origin: *");header("Content-Type: application/json; charset=UTF-8");$servername = "127.0.0.1";$username = "root";$password = "";$dbname = "xdoadayzepoch";$conn = new mysqli($servername, $username, $password, $dbname);$result = $conn->query("SELECT ID, Qty, Item, Orders, Buy, Sell, Tid, Afile FROM Traders_Data");$outp = "[";while($rs = $result->fetch_array(MYSQLI_ASSOC)) { if ($outp != "[") {$outp .= ",";} $outp .= '{"ID":"'. $rs["ID"]. '",';$outp .= '"Item":"'. $rs["Item"]. '",'; $outp .= '"Qty":"'. $rs["Qty"]. '",'; $outp .= '"Buy":"'. $rs["Buy"]. '",'; $outp .= '"Sell":"'. $rs["Sell"]. '",'; $outp .= '"Orders":"'. $rs["Orders"]. '",'; $outp .= '"Tid":"'. $rs["Tid"]. '",'; $outp .= '"Afile":"'. $rs["Afile"]. '"}';}$outp .="]";$conn->close();echo($outp);?> example of returned data from above, when called directly from browser.... [{"ID":"4996","Item":"["Skin_CZ_Special_Forces_GL_DES_EP1_DZ",1]","Qty":"10","Buy":"[2,"ItemGoldBar",1]","Sell":"[1,"ItemGoldBar",1]","Orders":"0","Tid":"476","Afile":"trade_items"},{"ID":"4999","Item":"["Skin_Drake_Light_DZ",1]","Qty":"10","Buy":"[2,"ItemGoldBar",1]","Sell":"[1,"ItemGoldBar",1]","Orders":"0","Tid":"476","Afile":"trade_items"},{"ID":"5002","Item":"["Skin_Soldier_Sniper_PMC_DZ",1]","Qty":"10","Buy":"[2,"ItemGoldBar",1]","Sell":"[1,"ItemGoldBar",1]","Orders":"0","Tid":"476","Afile":"trade_items"},{"ID":"5003","Item":"["Skin_FR_OHara_DZ",1]","Qty":"10","Buy":"[2,"ItemGoldBar",1]","Sell":"[1,"ItemGoldBar",1]","Orders":"0","Tid":"476","Afile":"trade_items"}] HTML code to display above returned data in a table.... <!DOCTYPE html><html><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>[DoA]DayZ</title> <link href="Site.css" rel="stylesheet"></head><body><nav id="nav01"></nav><div id="main"> <h1>[DoA]DayZ Server Db - Trader Tids</h1><div id="id01"></div><footer id="foot01"></footer></div><script src="Script.js"></script><script>var xmlhttp = new XMLHttpRequest();var url = "http://127.0.0.1/[DoA]DayZ/datafetch/fetch_tradersdata.php";xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { myFunction(xmlhttp.responseText); }}xmlhttp.open("GET", url, true);xmlhttp.send();function myFunction(response) { var arr = JSON.parse(response); var i; var out = "<table><tr><th>ID</th><th>Item</th><th>Qty</th><th>Buy</th><th>Sell</th><th>Orders</th><th>Tid</th><th>Afile</th></tr>"; for(i = 0; i < arr.length; i++) { out += "<tr><td>" + arr[i].ID + "</td><td>" + arr[i].Item + "</td><td>" + arr[i].Qty + "</td><td>" + arr[i].Buy + "</td><td>" + arr[i].Sell + "</td><td>" + arr[i].Orders + "</td><td>" + arr[i].Tid + "</td><td>" + arr[i].Afile + "</td></tr>"; } out += "</table>" document.getElementById("id01").innerHTML = out;}</script></body></html> the above HTML fails to display the table with the returned data, it actually displays nothing, UNLESS i remove the three fields from the whole process (that contain the "[" and "]" character). So My Questions is, how do i get the table to display with the "[" and "]" in their respective fields?
×
×
  • Create New...