display result from 2 table [closed] - php

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I am working for small project, the main idea of the project to display
some tours:
DB - Database consist of 2 table like below
The first table consist of 4 raw:
id , tour_id , tour_name, image
and the second table for each tour details like destination and places
and raw is:
id , tour_id , from , to
The main page is done, I can display information of tour with images and url link to details page like www.domain.com/tours/get_tour?=1
where 1 is the tour_id.
My question is how can I show the information from the second table with respect tour_id?
I am working in PHP and HTML and MYSQL.

You need JOIN function of mysql. The use this type of SQL script with PHP:
$sql="SELECT first.tour_id, first.tour_image, second.tour_id
FROM first
JOIN second ON first.tour_id=second.tour_id;";
$results=$conn-->$sql; //with $conn your connection variable
$get_tour = $result->fetch_assoc();
In this way you can get first.tour_name and second.from/to depending on tour_id
Then run a while to export your datas in PHP.
$get_tour is now populated. To call elements, use
$get_tour['first.tour_id'];
$get_tour['second.from'];
...
Let me know if it works!

Related

How to select specific text from quotes in SQL [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I want to get values from the other rows by selecting a specifc text from the quotes from items row
Image:
I tried all the ways I've know but nothing of them working.. example
$this->f3->get('DB')->exec('select tops.id, tops.name, tops.img from tops where tops.items = 1 ');
So what I want I want to select that "1" or "2" from items row ( check the image )
If the row you show in the image is an example of what you are attempting to select, then the SQL string you should be using would be:
'select tops.id, tops.name, tops.img from tops where (tops.items like \'%"1":%\' or tops.items like \'%"2":%\');'
This will select rows where the tops.items column contains either "1": or "2":. If you are trying to match something else, then please try to be a bit clearer in your question.

How to add new value to database column without deleting old data [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I want to add data to mysql table without removing old data of that column
stock = 50
now i want to add 5 more
so i want to get result in table as: stock = 50+5 or stock=60
how i can do this in SQL
This is a simple SQL statement
UPDATE myTable Set stock = stock + 5 WHERE ...
You use update:
update t
set stock = stock + 5
where <whatever condition fro the row you want to set>;

Create address link from database row query [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I would like to ask if anyone have any useful tips for a problem I'm having.
I have table in my database that looks like this:
row_Id unique_ID Name Info Etc...
1 5004007 Alice Doctor
2 6402305 Thomas Actor
I am trying to have an address link that will look something like:
http://mywebsite/ppl/5004007 - site with this link would echo values from row #1
http://mywebsite/ppl/6402305 - would echo values from row #2
And so on.
Can anyone help me please?
Here what I have so far:
<?php
include "./connect.php";
$result = MySQL_DB_Query($ac_db,"SELECT artists_id_gg FROM ivgdb_artists WHERE artists_id_gg = 1001001");
// $unique_link = MySQL_Num_Rows($result);
echo "<a target=\"_new\" href=\"mywebsite/ppl/"; . $result "\">This is the link to the page with that row's info.</a>";
?>
Shoud be something along the lines: ;
but with informations pulled from that table's row
if you change your link to like this :
http://mywebsite/ppl/unique_ID=5004007
you get a variable in php using this
$unique=$_GET["unique_ID"];
edit:
your link must be
http://mywebsite/ppl/?unique_ID=5004007
thanks -rtfm

Save and Display status updates like Twitter and Facebook? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Just a quick question, how can I set up my MySQL database for status updates?
So I already have a column horizontally for each user and a column vertically for each information stored such as their "email" and "username" and such like that. Now how do I set up a thing to make people post status updates and then store each one they post but only display the latest one they post via PHP onto their page? I mean do I make a vertical column for all users that say "statuses" or what?
write sql query like this to get the latest status update.
select * from table_name where user = your_user desc limit 1
You should create a new table in your database for statuses and create a filed (in this table) that refers to the ID of the author. This is the "common way" of doing it.
And then ordering the query results is just a matter of ORDER BY status_time DESC.

Combine Two Column Fields From ONE Table [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I made a new question cause I don't understand the other answers.
I want to get clear here.
I have a table named "experiences".
It has THREE FIELDS: id, experience_name, years.
I want to combine the TWO COLUMNS : experience_name and year and name it like.. experience
Then i want to make a new table and name it resume_experiences and put the COLUMNS id and experience
can you guys please help me..
How am i gonna do it?
OUTPUT SHOULD BE:
table name: resume_experiences
fields: ID | EXPERIENCE
Try this:
INSERT INTO resume_experiences
(id, experience)
SELECT id, CONCAT(experience_name, ' ', CONVERT(years,UNSIGNED))
FROM experiences
CREATE TABLE IF NOT EXISTS `resume_experiences `
SELECT `id`, CONCAT(`experience_name`, ' ', `years`) AS `experience`
FROM `experiences`;

Categories