Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This here is my form and i am using this form to take the input when a user clicks on it
<?php
          global $row6;
          $query= "select s.name ,s1.price from services s ,seller_services s1 where s1.service_id = s.id;";
          $result= mysqli_query($conn3,$query) or die(mysqli_error($conn3));
          while($row6=mysqli_fetch_array($result))
          {
            ?>
          <div class="col-md-3 col-sm-4">
            <div class="pro-box">
              <div class="pro-thumb"><img src="https://udemy-images.udemy.com/course/240x135/1192700_6496_2.jpg" alt=""></div>
              <div class="pro-txt"> <a href="#" class="add2cart">class="fa fa-shopping-cart"></a>
                <h6><a href="manageservice.php"><?php echo $row6['name'];?></a></h6>
                <p class="price">class="fa fa-inr"><?php echo $row6['price'];?></p>
                <form action="manageservice.php" method="POST">
                   <input type="submit" hidden="id" value="buy" namw="buy"/>
                 </form>
                 <div class="pro-rating"><a href="#">class="fa fa-star"__^ ^__i class="fa fa-star"> ^__i class="fa fa-star"> ^__i class="fa fa-star"></a></div>
              </div>
            </div>
          </div>
          <?php } ?> 

and next i have a page manageservices.php where this id shoould go on clciking and now what should happen is all the users having that service id mapped in the corresponding table seller_services must be displayed .
<div class="team-page">
      <div class="container">
        <div class="row"> 
           <?php 
          global $row;
          if(isset($_POST['buy']))
                                    {
                                        $id=$_POST['id'];
          $query5= "Select *from services where id = '$id'; ";
          $result=mysqli_query($conn3,$query5) or die("Mysql error");

           while($row=mysqli_fetch_array($result))
                                        {
                                          ?>
                                          <?php } ?>
          <!--Team Box Start-->
          <div class="col-md-3 col-sm-6">
            <div class="team-box">
              <div class="thumb">
                <div class="team-hover">
                  <h6>Michelle WU</h6>
                  <p>Aliquam nec finibus dui, eget dapibus leo. Suspendisse aliquam, justo in venenatis congue, sem odio vestibulum lorem, quis consectetur arcu nulla in est. </p>
                  <div class="mayor-social"> <a class="fb" href="#">class="fa fa-facebook" href="#"></a> <a class="lin" href="#">^__i class="fa fa-linkedin"></a> <a class="yt" href="#">^__i class="fa fa-youtube"></a> </div>
                </div>
                <img src="images/timg-1.jpg" alt=""></div>
              <div class="team-txt">
                <h5><?php  echo $row['name'];?></h5>
                <p><?php  echo $row['email'];?></p>
              </div>
            </div>

i am not that good at query writing and also the page just shows a blak screen
here is the databse tables to be used :
1.table relating user id with service id
`seller_services` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `service_id` int(50) NOT NULL,
  `subservice_id` int(50) NOT NULL,
  `price` int(50) NOT NULL,
  `time` varchar(50) NOT NULL,
  `user_id` int(50) NOT NULL,
  `shop_id` int(50) NOT NULL,
  PRIMARY KEY (`id`)
)

2.table services
`services` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `image` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
)

table users:
`users` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
  `email` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
  `password` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
  `gender` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
  `phone` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
  `photo` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
  `admin` int(11) NOT NULL,
  `remember_token` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `users_email_unique` (`email`)
)


What I have tried:

i have shown u what i tried in the above code i just need help in query and with the white blank space it shows
Posted
Updated 13-Apr-18 16:10pm

PHP
$query5= "Select *from services where id = '$id'; ";

Not a solution to your question, but another problem you have.
Never build an SQL query by concatenating strings. Sooner or later, you will do it with user inputs, and this opens door to a vulnerability named "SQL injection", it is dangerous for your database and error prone.
A single quote in a name and your program crash. If a user input a name like "Brian O'Conner" can crash your app, it is an SQL injection vulnerability, and the crash is the least of the problems, a malicious user input and it is promoted to SQL commands with all credentials.
SQL injection - Wikipedia[^]
SQL Injection[^]
SQL Injection Attacks by Example[^]
PHP: SQL Injection - Manual[^]
SQL Injection Prevention Cheat Sheet - OWASP[^]
 
Share this answer
 
You should check your query spacing (for a start). You have
PHP
select *from 
instead of
select * from
Using 'u' instead of 'you' and other such cell-phone-texting junk is a sure way to develop sloppy habits. It's OK for error in English - it is not your first language. I am not referring to language errors, but deliberate junk. Computers are very rough on coders with sloppy habits. "Almost doesn't count".
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900