I have a script that populates a form from MySQL database table row for editing. I'm performing MySQL SELECT and UPDATE via PDO. After editing a particular table row and clicking on the submit button, the table row doesn't update. The following is "modify-course.php": <?php // configuration require("../includes/config.php"); // query admin table to retrieve current admin's profile //select a particular admin by id // query users table to retrieve current admin's profile if (array_key_exists('aid', $_GET)) { // select a particular admin by id $stmt = $pdo->prepare("SELECT * FROM admin WHERE aid=?"); $stmt->execute([$_GET["aid"]]); $admin = $stmt->fetch(); # get admin data if …

Member Avatar
Member Avatar
+0 forum 3

I'm somewhat new to coding websites. I'm trying to have a code where it pulls multiple images from a single database and displays it in a grid, not a table. At the top of my page I have a normal connection to the database. (very sorry about not having a code snippet, I'm new to daniweb and keep having errors when trying to use code snippets.) <div id="grid" class="grid-container"> <?php while ($row = mysqli_fetch_array($query)) echo '<div class="grid-item"> <p>'.$row['images'].'</p> <p>'.$row['project'].'</p> <p>'.$row['summary'].'</p> </div>'; ?> </div>

Member Avatar
Member Avatar
+0 forum 1

Hi, When I was trying to create the IT Request Form and testing it out, I got some problems during the testing. The home page (index.blade.php) ended up getting an error called "Undefined offset: 1", maybe due to the table database problem. ![0TyCAu.png](/attachments/large/4/8730ed8f11be3f5ed672376eee11d83f.png) The checkboxes in the Request Form (requestForm.blade.php) should not be all checked, instead the user has to select a checkbox option. ![0Tyvyx.png](/attachments/large/4/338e30d7d03b784fd3c723e1bf5d80fb.png) Is there a way to fix the form? My IT Request Form project: https://drive.google.com/file/d/1Vpif_1Cxm-Kkw-4_5ZKYt-Tjd1IWJB9_/view?usp=sharing *Please note that the data I entered when testing is fictional (not real).

Member Avatar
+0 forum 0

I would like help with creating a form that when submitted, creates a webpage which is able to be edited by whomever submits the form; I would also like this url/link to be added to a database.

Member Avatar
Member Avatar
+0 forum 1

Hi All, I am building an eCommerce website and I really new to PHP and MYSQL but loving the challenge. On my website I have 9 different categories of products with each page having about 8 items to sell. Rather than duplicating the code from each .php/.html file into a new file and change the SQL query, is it possible to write a script that says when the user clicks on category1 in the navigation bar, show all the products in category1? Hope this makes sense. Thanks in advanced.

Member Avatar
Member Avatar
+1 forum 4

Hi All, So I an creating an online store just to play around with code and learn from it. I am building a store and on the confirmation page, I am trying to update the QTY of items in a cart by using the '-' or '+' buttons. However I am having no luck at all. Here is my code: <?php foreach ($_SESSION["cart_item"] as $item){ $item_price = $item["quantity"]*$item["price"]; ?> <tr> <td><img src="<?php echo $item["image"]; ?>" class="cart-item-image" /><?php echo $item["name"]; ?></td> <td><?php echo $item["code"]; ?></td> <td style="text-align:center;"> <table class ="cart-info"> <tbody> <tr> <form method='post'> <td> <button class="btn-increment-decrement" id="add" onClick="decrement_quantity(<?php echo $_SESSION['quantity']-- …

Member Avatar
Member Avatar
+0 forum 1

Hi All, I am trying to create some search functionaltiy for my website, but for some reason when I search any word, even if its not in my database it will display all the results from a particular column. Here is my code <?php error_reporting( ~E_DEPRECATED & ~E_NOTICE ); define('DBHOST', 'localhost'); define('DBUSER', 'root'); define('DBPASS', 'mypass123'); define('DBNAME', 'topgrub'); $conn = mysqli_connect(DBHOST,DBUSER,DBPASS); $dbcon = mysqli_select_db($conn,DBNAME); if ( !$conn ) { die("Connection failed : " . mysqli_error()); } if ( !$dbcon ) { die("Database Connection failed : " . mysqli_error()); } ?> <?php if(isset($_POST['search'])){ $q = $_POST['q']; $query = mysqli_query($conn,"SELECT * FROM `products` …

Member Avatar
Member Avatar
+0 forum 4

I am working on a anouncement system. the announcements are displayed everywhere in the website, every anouncement has a acknowledge button, basicaly to mark it as seen. what i have: Table: announcements: annId, annTitle, annContent, annDatetime Table: annComplete: annCompletedId, annId, userId, annCompleteDatetime I first pull all the announcements from the table `$result = mysqli_query($link, "SELECT * FROM announcements"); if (mysqli_num_rows($result) > 0) { while($row = mysqli_fetch_assoc($result)) { ` durring the while portion I go to the annComplete: `$check = mysqli_query($link, "SELECT * FROM annComplete WHERE `userId` = "$userId" AND `annId` = '".$row['annId']."'"); if(mysqli_num_rows($check) == 0){` in here I check if …

Member Avatar
Member Avatar
+0 forum 1

Hello i have a mysql statement and i want to add more parameters to get different results. SELECT DISTINCT M.message,F.friend_one,F.friend_two, F.role,U.uid,U.username FROM users U,friends F, messages M WHERE ( U.status='1' AND F.friend_one = '88') OR (F.friend_two='88' ) AND F.role='friend' 88 is the users id so i want to show M.message from friends of 88 but not 88 itself hints: when one is becoming friend with other friend_one is 88 -for example- and friend_two another user id or vice versa M table has id of user as a column of course

Member Avatar
Member Avatar
+0 forum 4

Hello i have a database which users make groups or send messages to other registered, in our project, users. So you have messages as M,users as U, groups as G. So you want to show all updates that happen in these tables WHERE (uid - thats the user id column on U table.). All tables have CREATED as datetime column. Users yable is uid on messages is uid_fk and to groups uid_fk. Can i do that with a single statement or do i need to do anything else?

Member Avatar
Member Avatar
+0 forum 2

Hello i am getting an error on a CASE WHEN THEN syntax on my mySql SELECT DISTINCT u.uid,c.c_id,u.name,u.profile_pic,u.username,u.email,c.time FROM conversation c, users u, conversation_reply r CASE WHEN c.user_one = '99' THEN c.user_two = u.uid WHEN c.user_two = '99' THEN c.user_one= u.uid END AND ( c.user_one ='99' OR c.user_two ='99' ) AND u.status='1' AND c.c_id=r.c_id_fk AND u.uid<>'1'ORDER BY c.time DESC LIMIT 15 #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CASE WHEN c.user_one = '99' THEN c.user_two = u.uid WHEN c.user_t' at …

Member Avatar
Member Avatar
+0 forum 4

I have one table with questions and another table with correct answer If any user attempt question then I need result with marks. ![Screenshot1.png](/attachments/large/4/fd77b92f76ec03f7fe36367afb2390c4.png) I want result:- ![Screenshot2.png](/attachments/large/4/6f7c76256f966297c694cfed242bbbcb.png) Thanks in advance!

Member Avatar
Member Avatar
+0 forum 3

Hi guys, This is my first post and so glad to start sharing the knowledge. I am using Mysql database with VB.NET and I have this code : Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim str As String = "Server=localhost;Port=3306;Database=testdb;Uid=root;Pwd=password" Using con As New MySqlConnection(str) Dim query As String = "select * from testdata where rfid_tag='" & TextBox3.Text & "' and Date_serve<= '" & Date.Now.ToString("yyyy-MM-dd ") & "' and Start_Time<= '" & Date.Now.ToString("HH:mm:ss ") & "' and End_Time>= '" & Date.Now.ToString("HH:mm:ss ") & "' or amount_serve='' " Dim cm As New MySqlCommand(query, con) con.Open() Dim rd …

Member Avatar
Member Avatar
+1 forum 2

What's the difference between LCASE() and LOWER() in MySQL? I found places on the web that said they're similar but not a synonym for each other, so I'm not sure what the differences are?

Member Avatar
Member Avatar
+0 forum 1

I'm doing both SELECT and UPDATE queries using named placeholders. But course data from the database doesn't populate form, as expected. The database table row records don't populate, each time I try to edit a course in the browser. I connect to the database usining PDO. And I do SELECT and UPDATE queries using named placeholders. The following is my "modify-course.php": <?php // configuration require("../includes/config.php"); //select a particular admin by id $admin_id = isset($_GET["admin_id"]) ? $_GET["admin_id"] : ''; $stmt = $pdo->prepare("SELECT * FROM admin WHERE admin_id=:admin_id"); $stmt->execute(['admin_id' => $admin_id]); $admin = $stmt->fetch(); # get admin data if (!$admin) { header("Location: …

Member Avatar
+0 forum 0

*Hello** This has been a question for a long time / Request for help for a PHP script. A year ago I created a homepage for a friend (online tutoring website) and installed a finished script for an occupancy calendar and did not consider / knew that the server will soon be switching to PHP 7.2. I could already test and adjust the rest of the homepage, but unfortunately I am with my Latin at the end and of course the calendar does not work. The problem is of course the database connection .... mysq under PHP 7.2, which I …

Member Avatar
Member Avatar
+0 forum 1

I'm trying to upgrade my script from PHP 5.5 to PHP 7.2. And that came with the script not able to modify a selected table row as before. The records don't even populate whenever I try to edit a course in the browser. Please, note that I'm connecting to the database via PDO. The following is my script: <?php // configuration require("../includes/config.php"); // query admin table to retrieve current admin's profile $admin = query("SELECT * FROM admin WHERE admin_id = ?", $_SESSION["admin_id"]); if (!$admin) { redirect("login.php"); } // query users table to retrieve admin homepage's contents // $users = query("SELECT …

Member Avatar
Member Avatar
+0 forum 3

$query = "INSERT INTO 'user-profiles' ('name', 'avatar', 'description', 'votes', 'pay_methods', 'location', 'user_id') VALUES ('sadj', 'qwesad', 'sadqwdqw', '0','sadsad', 'sadasdsad''4')"; $resultprof = $this -> conn -> query($query); votes and user_id are INT columns, and user_id is a foreign key. Making this insert on mySQL directly it works perfectly, but on my PHP the "success" is false....

Member Avatar
Member Avatar
+0 forum 5

I need help with implementing MySQL transactions with PHP. Specifically, I'm confused between the flags `WITH CONSISTENT SNAPSHOT`, `READ WRITE`, and `READ ONLY`, what their differences are, and how they relate to table locking. I already read the MySQL reference manual but I'm still confused.

Member Avatar
Member Avatar
+2 forum 6

Hi all, I am very new to PHP and MYSQL and have a class assignment I need help with. I am trying to make a page with an HTML form that will update my MYSQL database. You can view my pages online here: [URL="http://baileyjumper.aisites.com/Scripting-Week7/homework4/exercise-five.php"]http://baileyjumper.aisites.com/Scripting-Week7/homework4/exercise-five.php[/URL] I need help with the "Edit" section, if you look online. Here is the code for my Edit page: [CODE=PHP] <?php $hostname = "localhost";//host name $dbname = "baileyjumper_imd203";//database name $username = "baileyjumper_imd";//username you use to login to php my admin $password = "chris4ever";//password you use to login //CONNECTION OBJECT //This Keeps the Connection to the Databade …

Member Avatar
Member Avatar
+0 forum 20

If a bulk MySQL insert takes 5 minutes to complete, and one of the columns in the table is a TIMESTAMP column with a default value of CURRENT TIMESTAMP, will the timestamps of the rows that were inserted be reflective of the entire 5 minutes, or will they all default to the same timestamp from beginning or the end of the query? The bulk insert exists within a transaction.

Member Avatar
Member Avatar
+0 forum 3

Hello! I have a problem with a MySQL database that I haven’t been able to solve no matter how much I tried, either with internet guides or with free tools. I really don’t want to pay hundreds of dollars to a company so please, if anyone knows of a solution, help me because I’m desperate. I was running XAMPP 7.1.22 where I had said database and I decided to install XAMPP 7.2.10 without backing up the database. After that, the site wasn’t working so I figured the problem was the database. And indeed PHPMyAdmin wouldn’t recognize it. I reinstalled the …

Member Avatar
+0 forum 0

<?php $msg=""; $image1=""; $image1_err=""; //if upload button is pressed if(isset($_POST['upload'])){ $target="images/".basename($_FILES['image']['name']); $db=mysqli_connect("localhost","root","","categories"); $image=$_FILES['image']['name']; $text=$_POST['text']; if(isset($_POST['electro'])){ $sql="INSERT INTO electronic(image,text) VALUES ('$image','$text')"; mysqli_query($db,$sql); } //move image to a file if(move_uploaded_file($_FILES['image']['tmp_name'],$target)){ $msg="Image uploaded successfully"; }else{ $msg="There was a problem uploading image"; } } ?> <!DOCTYPE html> <html> <head> <title>Image Upload</title> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <div id="content"> <?php $db=mysqli_connect("localhost","root","","categories"); $sql="SELECT * FROM electronic"; $result=mysqli_query($db,$sql); while($row =mysqli_fetch_array($result)){ echo "<div id='img_div'>"; echo "<img src='images/".$row['image']."'>"; echo "<p>" .$row['text']."</p>"; echo "</div>"; } ?>

Member Avatar
Member Avatar
+0 forum 4

I want to protect my site from hacking. Currently I know about XSS and SQL injection. Do I need to use mysqli instead of mysql? And why? When should I use `htmlentities()` and `striptags()`? I also don't want users to upload melicious files and since I accept file uploading, is it enough to check file type? If not what can I do to prevent this? My website runs on PHP, is there anything else I should worry about?

Member Avatar
Member Avatar
+0 forum 6

Hi, In my application two fields are the user id and user name,i want to show the user name and user id along with other details in a html table. user id is a numeric dropdown menu and user name is text only.How can i show the specfic record in that table for that user which i have selected in both of the fields ,how i can fetch data from backend User table?am using html,css and javascript, Any suggestion would be grateful!Thanks..

Member Avatar
Member Avatar
+0 forum 1

Signup.php <form name="sign-up" method="post" action="process.php?action=sign-up"> <h3><span>Sign-Up</span></h3> <table width="100%" border="0" cellspacing="1" cellpadding="1"> <thead> User Details </thead> <tr> <th scope="row">*User ID :</th> <td><label for="playerid"></label> <input type="text" name="playerid" id="playerid" required="required"></td> </tr> <tr> <th scope="row">*Name :</th> <td><label for="playername"></label> <input type="text" name="playername" id="playername" required="required"></td> </tr> <tr> <th scope="row">*Mobile Number :</th> <td><label for="playermob"></label> <input type="text" name="playermob" id="playermob" required="required"></td> </tr> <tr> <th scope="row">*E-Mail :</th> <td><label for="playermail"></label> <input type="text" name="playermail" id="playermail" required="required"></td> </tr> <tr> <th scope="row">Address :</th> <td><label for="playeraddress"></label> <textarea name="playeraddress" id="playeraddress" cols="45" rows="5"></textarea></td> </tr> <tr> <th scope="row">&nbsp;</th> <td><input type="submit" name="cancel" id="cancel" value="Cancel"> <input type="submit" name="submit" id="submit" value="Submit"></td> </tr> <tr> <th scope="row">&nbsp;</th> <td>&nbsp;</td> </tr> <tr> <th colspan="2" scope="row">&nbsp;</th> …

Member Avatar
Member Avatar
+0 forum 8

<html> <head></head> <link rel="stylesheet" type="text/css" href="style.css" <body> <?php $db = mysqli_connect('localhost', 'root', '', 'formdb'); $formId = ''; $LastName = ''; $FirstName = ''; $Email = ''; $Birthday = ''; $Birthplace = ''; $Comment = ''; if (isset($_GET['upd'])){ $formId = $_GET['upd']; $results = mysqli_query($db, "SELECT * FROM tbl_form WHERE formId=$formId"); } if(isset($_POST['submit'])) { $formId = $_POST['formId']; $LastName = $_POST['LastName']; $FirstName = $_POST['FirstName']; $Email = $_POST['Email']; $Birthday = $_POST['Birthday']; $Birthplace = $_POST['Birthplace']; $Comment = $_POST['Comment']; $query = "UPDATE tbl_form SET LastName='$LastName', FirstName='$FirstName', Email='$Email', Birthday='$Birthday', Birtplace='$Birthplace', Comment='$Comment' WHERE formId='$formId'"; mysqli_query($db, $query); $_SESSION['msg'] = "Successfully Updated!"; header('location: form.php'); //redirect after inserting } ?> <?php …

Member Avatar
Member Avatar
+0 forum 1

hi i make a page for registration and login after that i uploaded image ..i want to show those image by own user id..plz help me..thanks in advance :)

Member Avatar
Member Avatar
+0 forum 1

I am not that much of an expert in PHP as it has been few months since I started playing with it. Currently I am working on creating a basic CRUD operation in PHP. I follow this tutorial on CRUD in PHP (https://www.cloudways.com/blog/execute-crud-in-mysql-php/ ) to create it on a local wamp server. However, I am getting following error: Fatal error: Call to a member function fetch_array () on string in C: \ wamp \ www \ crud_oop \ index.php on line 233 Can anyone point out what I am doing wrong? Here is my full code: <div class="container"> <div style="height:50px;"></div> …

Member Avatar
Member Avatar
+0 forum 1

I have a Table that displays titled and first name columns and delete link on the 3rd column. Unfortunately for a reason i don't understand, records are not deleting when the Delete link is clicked. Please friends, help me figure out what's wrong here. Table <?php $user_id = $_SESSION["user_id"]; //brought here via session //select statement here // output data of each row while($row = $result->fetch_assoc()) { echo '<tr> <td scope="row">' . $row["titled"]. '</td> <td> '.$row["firstname"] .'</td> <td><a href="user_delete.php? delete=$row[user_id]">Delete</a> </td> </tr>'; } } else { echo "0 results"; } ?> user_delete.php code <?php session_start(); require_once $_SERVER['DOCUMENT_ROOT'] . '/soap/includes/server.php'; if(isset($_GET["delete"]) ) …

Member Avatar
Member Avatar
+0 forum 2

The End.