[Solved] How do i upload an image to my mysql database with php? [duplicate]

You don’t need to store image directly into to database. Just store the image name in the database and fetch it when you want to show. For e.g. $target_dir = “uploads/”; $target_file = $target_dir . basename($_FILES[“fileToUpload”][“name”]); $uploadOk = 1; $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION); // Check if image file is a actual image or fake image if(isset($_POST[“submit”])) … Read more

[Solved] filter table column and view the data in the another column [closed]

I can’t explain this Let me explain it for you. You are looking for pivoting the comments values for the concern for each student. Unfortunately, MySQL has no pivot table operator. However, you can use the CASE expression to do this. Like so: SELECT student_name, MAX(CASE WHEN concern = ‘Academics’ THEN comments END) AS ‘Accademics’, … Read more

[Solved] Is this prepared statement?

Yes you are using a prepared statement with a parameter. That’s the right thing to do. Parameters are the best way to write safe SQL statements in the majority of cases. There are just a few edge cases where they don’t help (see my answer to how safe are PDO prepared statements) I can suggest … Read more

[Solved] convert mysql query to laravel query builder

\DB::table(‘cars’) ->join(‘garage’, ‘garage.id’, ‘=’, ‘cars.garage’) ->where(‘garage.name’, ‘main’) The above solves the garage and cars part, but you never specified what is aliased to p. If p is a different table then you need to add another call to join() and making the following \DB::table(‘cars’) ->join(‘garage’, ‘garage.id’, ‘=’, ‘cars.garage’) //<Other table join goes here for table … Read more

[Solved] How to use proper variable in php? [closed]

You should better a try var_dump($row) or print_r($row) first to see if the array contains the datas at right keys. $lang[$row[0]] doesnt work because $row[0] is empty. Your are probably not assigning Hello to $row[0]. So try print_r($row); to see whats stored in the whole array. Add : $lang[$row[0]] will give you $lang[hello]. It should … Read more

[Solved] how to Multiply 2 columns from different tables but same database mysqli php [closed]

$con = mysqli_connect(“localhost”, “root”, “”, “zoo”); if (mysqli_connect_error()) { echo “Failed to connect” . mysqli_connect_error(); } $sel = “select (quantity* bill) as total from animal inner join price on animal.id=price.animal_id group by price.animal_id”; $result = mysqli_query($con, $sel); while ($row = mysqli_fetch_array($result)) { echo “<tr>”; echo”<td>” . $row[‘total’] . “</td>”; } Before copy and paste check … Read more

[Solved] How to loop table in php [duplicate]

There are multiple issues with your current code. You fetch the first row with $row = mysqli_fetch_array($select); (line 3), but you don’t do anything with it. This means that the first result is discarded. Your while loop attempts to loop over an incorrect variable ($query is a string, not the result-object), and you’ve quoted it … Read more

[Solved] PHP How to generate School Year?

Change your code following way- <?php $date2=date(‘Y’, strtotime(‘+1 Years’)); for($i=date(‘Y’); $i<$date2+5;$i++){ echo ‘<option>’.$i.’-‘.($i+1).'</option>’; } ?> solved PHP How to generate School Year?

[Solved] I need a sql query to view data

SELECT cities.cityname, states.statename, countryname FROM cities JOIN states ON cities.states_id = states.id JOIN country ON states.country_id = country.id WHERE cities.id=3; Assuming 3 is the id of the city you are searching for… solved I need a sql query to view data