Ian Hunt
Members-
Posts
16 -
Joined
-
Last visited
Ian Hunt's Achievements
Newbie (1/14)
0
Reputation
-
Problem Printing Table Info
Ian Hunt replied to Ian Hunt's topic in PHP for the Web: Visual QuickStart Guide (5th Edition)
Thanks Larry, I get the idea. However I am not sure of the syntax. Would it be possible to show how the code would be written using my example. No problem if this is something you don't do on the forum. Ian -
Problem Printing Table Info
Ian Hunt replied to Ian Hunt's topic in PHP for the Web: Visual QuickStart Guide (5th Edition)
Sorry code should read: <table class="data-table"> <?php do { ?> <tr> <td><a href="#"><?php echo $rs_display_groups['GroupName']; ?></a></td> </tr> <?php } while ($rs_display_groups = mysqli_fetch_array($display_groups_result)); ?> </table> -
Hi, I want to display a table of interest groups in a html table. My loop prints out a new row, which is fine. The problem I have is that I want my table to print 4 columns i.e. the <td> tag four times. I am not sure of the code to repeat the <td> tag four times. Any ideas would be gratefully accepted. Here is my code for the moment. <table class="data-table"> <?php do { ?> <tr> <td><a href="#"><?php echo $rs_display_groups['GroupName']; ?></a></td> <?php } while ($rs_display_groups = mysqli_fetch_array($display_groups_result)); ?> </tr> </table>
-
Details Page
Ian Hunt replied to Ian Hunt's topic in PHP for the Web: Visual QuickStart Guide (5th Edition)
Hi Guys, Any ideas on this for me. Regards -
Hi, I am building a website that holds cats for sale. I have a page that lists the cats but then I want to go to a page where there is more details about the cat via a link that shows the cats name. It seems to work in principle and it takes you to the page associated with that cat. However I get this error:- Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in (then goes on to state the page name and line where the error is). Here is my code:- CIN is Cat Idenfication Name <?php if (isset($_GET['CIN']) && is_string($_GET['CIN']) ) // Define the display kitten details query: $query = "SELECT * FROM tbl_kittens_for_sale WHERE CIN={$_GET['CIN']}"; $display_kitten_details_result = mysqli_query($dbc, $query); // Run the query. $rs_display_kitten_details = mysqli_fetch_array($display_kitten_details_result); ?> Any help would be much appreciated. Thanks
-
Hi Abigail, Thanks for looking. I want to print and repeat 3 separate divs/columns on the same line and so on, so it loops and goes onto the next line if more than 3. Bit hard to explain I guess if can't see what I am trying to achieve. At the moment it is printing everything in one long column and I am sure I need a do while loop or similar on the outside of the div. Unsure of what the code would be. Any ideas gratefully appreciated. Ian
-
Thanks Larry, I think I know the problem but unsure of the syntax. At the moment it is printing and repeating all the database info in one big div. I possibly think the div needs a loop on the outside but unsure how to go about it. Here is how my divs are set up. <section class="row"> <div class="col-md-4"> <div class="gallery"> <?php My php info as above ?> </div> </div> </section> Hope someone can help. Thanks.
-
Hi, Firstly thank you Larry for sorting my last problem. I can get my database to display the information ok but I have a small problem where my database information seems to display on a new line. It is a div consisting of images of kittens for sale and some text about the kitten. I want them display inline. Here is my php/mysql script and also the stylesheet. I am using bootstrap grid. PHP script: <section class="row"> <?php /* This script retrieves all available kittens from the database. */ // Connect and select: $dbc = mysqli_connect('localhost', 'root', '', 'new_era_bengals'); // Define the query: $query = 'SELECT * FROM tbl_kittens_for_sale'; ?> <div class="col-md-4"> <div class="gallery"> <?php if ($r = mysqli_query($dbc, $query)); // Run the query. // Retrieve and print every record: while ($row = mysqli_fetch_array($r)) { print " <img src={$row['Image']} > <p>{$row['Name']} {$row['Sex']}</p> "; } ?> </div> </div> </section> CSS: .gallery { margin-bottom: 1em; padding: 1em; background: #663300; display: inline-block; -webkit-border-radius: 7px; -moz-border-radius: 7px; border-radius: 7px; } .gallery img { width: 100%; height: auto; } .gallery p { margin-top: 1em; padding-left: 1em; color: #F5F2E8; text-transform: uppercase; } Hope anyone can help. Many thanks.
-
Inserting Into Mysql Database
Ian Hunt replied to Ian Hunt's topic in PHP for the Web: Visual QuickStart Guide (5th Edition)
Just to explain I have a table called images which holds a column for ID, VIN and ImageFile. Thanks. Here is upload form. <!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> </head> <body> <form action="upload-file.php" method="post" enctype="multipart/form-data"> <label for="file">Filename:</label> <input type="file" name="file" id="file"><br> <input type="submit" name="submit" value="Submit"> </form> </body> </html> Here is upload file. <!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> </head> <body> <?php $vin = trim($_POST['VIN']); $currentfolder = getcwd(); print "This script is running in: " .$currentfolder."<br>"."\n"; $target_path = getcwd()."/uploads/"; print "The uploaded file will be stored in the folder: " .$target_path."<br>"."\n"; $target_path = $target_path . basename($_FILES['file']['name']); $imagename = "uploads/".basename( $_FILES['file']['name']); print "The full name of the uploaded file is ".$target_path."<br>"."\n"; print "The relative name of the file for use in the IMG tag is " .$imagename."<br><br>"."\n"; if(move_uploaded_file($_FILES['file']['tmp_name'],$target_path)) { print "The file ". basename($_FILES['file']['name']). " has been uploaded<br>". "\n";} // Connect and select: $dbc = mysqli_connect('localhost', 'root', '', 'cars'); // Define the query: $file_name = $_FILES["file"]["name"]; $query = "INSERT INTO tbl_images (VIN, ImageFile) VALUES ('$vin', '$file_name')"; print $query."<br>\n"; if ($r = mysqli_query($dbc, $query)) { // Run the query. print "<p>You have successfully entered $target_path into the database</p>\n"; } mysqli_close($dbc); // Close the connection. ?> </body> </html> The script successfully uploads the image into ImageFile column in images table and my print messages confirm this but does n't allocate to the VIN (Vehicle Identification Number), I am not sure how to get it into that particular VIN. Any help would be much appreciated. Thanks -
Hi, I am developing a database for a used car salesman and am having trouble uploading a set of images for a particular car i.e. a gallery of images for that particular car. I can get it to insert into the database but it's assigning it to that particular car that I am stuck with, If copy and paste my code, would someone be willing to have a look at where it's going wrong. Thanks.