PHP - Not Able To Call Out Any Values From Database Using Php Codes
Hi,
I will really need some help here. I have posted this similar topic quite a number of times, however no one could actually give me a solution. Currently when I execute the code, it seems like "mysqli_num_rows($data3) !== 1", therefore my {else} command was executed instead. "else {echo '<p class="error">There was a problem accessing your profile.</p>';}" I have no idea what went wrong, and if you look at my attachment.jpg, there are 3 columns 1) overall_level_subject_id 2) tutor_id 3) subject_level_id The thing is that, there are similar tutor_id appearing in this table and it may not be in sequence, take for example... overall_level_subject_id: 10 tutor_id: T532uu subject_level_id: 11 overall_level_subject_id: 51 tutor_id: T532uu subject_level_id: 12 I'm not too sure if you guys understand what I am explaining. But I really need help in this area! Please advice! Code: [Select] <?php /*************************Teaching Subjects*************************/ $query3 = "SELECT subject_level_id FROM tutor_overall_level_subject WHERE tutor_id = '" . $_GET['tutor_id'] . "'"; $data3 = mysqli_query($dbc, $query3) or die(mysqli_error($dbc)); if (mysqli_num_rows($data3) == 1) { echo '<div id="panel4">'; echo'<table><tr>'; $count = 0; // Start your counter while($row3 = mysqli_fetch_array($data3)) { if ($count % 5 == 0) { echo "</tr><tr>"; $count = 0; } echo '<td class="label">' . $row3['subject_level_id'] . '</td><td>' . $row3['subject_level_id'] . '</td>'; $count++; } echo '</tr></table><br/>'; echo '</div>'; //End of panel 4 } //End of IF for $query and $data (Teaching Subjects) else { echo '<p class="error">There was a problem accessing your profile.</p>'; } ?> Similar TutorialsHi guys, I have an intention to allow user to select multiple district, however even though when they select more than 2 options in the district, it turns out my database is only able to capture the last value. For instance, I chose ID=1 ID=2, however the return value to my database will be only ID=2. Is there something which I have missed out? Your advice is greatly appreciated. Thank you <?php $district = $_POST['district']; if (isset($_POST['submit'])) { $dbc = mysqli_connect('localhost', '***', '***', '***') or die(mysqli_error()); $query2 = "INSERT INTO tutor_preferred_dlocation (district_id) VALUES ('$district')"; $result2 = mysqli_query($dbc, $query2) or die(mysqli_error()); } <input name="district" type="checkbox" id="1" value="1"> <label for="yishun">Yishun</label> <input name="district" type="checkbox" id="2" value="2"> <label for="angMoKio">Ang Mo Kio</label> <input name="district" type="checkbox" id="3" value="3"> <label for="yioChuKang">Yio Chu Kang</label> ?> I have been searching for a few weeks now and decided to get a little help on this on. I am after a database like that which I found for the UK postcode, but one for the USA but it needs to have the North and East references. Has anyone come across a site that offers a basic zipcode, state, Grid_N and Grid_E references ? if so please can you let me know what sites you have used. I have trouble calling timepicker with class and passing data-values to the script.
So what i have so far is one loop that for each entry it will create foreach($data as $value){ $min_hour = $value['minhour']; // returns value from DB like 7 to 12 echo '<td><input type="text" value="" class="schedule-timepicker" data-minhour="'.$min_hour.'" data-minminutes="30" data-maxhour="17" data-maxminutes="00"></td>'; }Then in js file I have $(document).ready(function(){ $('.schedule-timepicker').timepicker({ timeFormat: 'HH:mm:ss', minDate: new Date(1, 1, 1, $('.schedule-timepicker').data('minhour'), 00), maxDate: new Date(1, 1, 1, $('.schedule-timepicker').data('maxhour'), 00), }); });Problem is that the timepicker is called out and works but every input has the same minimum hours value as the first one. Please help how to resolve this. Thanks. Hello I am on to OOP now and I dont know how to write the syntax to print the results I want The scenario is I have the abstract class, its subclass and then the object that calls the subclass, all in different files. So: part of the subclass reads: Code: [Select] function __construct($v1, $v2, $v3) { $this->speed[] = $v1; // I dont like this either, it is not elegant. I tried to put an array as argument of the constructor and send the parameters $this->speed[] = $v2; // from the object being created, but it did not work, so I leave it like this for now, but I would have preferred to put that $this->speed[] = $v3; // array and then populate it by some looping. } // METHOD TO REPORT TABLE OF ACCELERATION public function acceleration() { return $this->acceleration1 = ($this->speed[1] - $this->speed[0])/5; // I actually need to return the other two speed differences from the other stages, but as you know, once the first return acts, it exits the function // so sure this "return" has to be abandoned and the results of the function have to be printed otherwise. That is the question. } =================================== And now from the Object file I am trying to call the function, but of course, I only get one value, even if I write 3 times return Code: [Select] $objeto = new Motorbike($v1, $v2, $v3); echo '<p>The speeds are ' . $objeto->acceleration() . '</p>'; // Yes, this call works, of course, but that is about it. I cant print any other result. Thanks a lot after cloasing connection of database i still got the values form database. Code: [Select] <?php session_start(); /* * To change this template, choose Tools | Templates * and open the template in the editor. */ require_once '../database/db_connecting.php'; $dbname="sahansevena";//set database name $con= setConnections();//make connections use implemented methode in db_connectiong.php mysql_select_db($dbname, $con); //update the time and date of the admin table $update_time="update admin set last_logged_date =CURDATE(), last_log_time=CURTIME() where username='$uname'limit 3,4"; //my admin table contain 5 colums they are id, username,password, last_logged_date, last_log_time $link= mysql_query($update_time); // mysql_select_db($dbname, $link); //$con=mysql_connect('localhost', 'root','ijts'); $result="select * from admin where username='a'"; $result=mysql_query($result); mysql_close($con); //here i just check after closing data baseconnection whether i do get reselts but i do, why? echo "after the cnnection was closed"; if(!$result){ echo "cont fetch data"; }else{ $row= mysql_fetch_array($result); echo "id".$row[0]."usrname".$row[1]."passwped".$row[2]."date".$row[3]."time".$row[4]; } // echo "<html>"; //echo "<table border='1' cellspacing='1' cellpadding='2' align='center'>"; // echo "<thead>"; // echo"<tr>"; // echo "<th>"; // echo ID; // echo"</th>"; // echo" <th>";echo Username; echo"</th>"; // echo"<th>";echo Password; echo"</th>"; // echo"<th>";echo Last_logged_date; echo "</th>"; // echo "<th>";echo Last_logged_time; echo "</th>"; // echo" </tr>"; // echo" </thead>"; // echo" <tbody>"; //while($row= mysql_fetch_array($result,MYSQL_BOTH)){ // echo "<tr>"; // echo "<td>"; // echo $row[0]; // echo "</td>"; // echo "<td>"; // echo $row[1]; // echo "</td>"; // echo "<td>"; // echo $row[2]; // echo "</td>"; // echo "<td>"; // echo $row[3]; // echo "</td>"; // echo "<td>"; // echo $row[4]; // echo "</td>"; // echo "</tr>"; // } // echo" </tbody>"; // echo "</table>"; // echo "</html>"; session_destroy(); session_commit(); echo "session and database are closed but i still get values from doatabase session is destroyed".$_SESSION['admin']; ?> session is destroyed but database connection is not closed. thanks This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=321957.0 this is my coding can anyone see what is wrong with it? $total = mysql_query("SELECT * FROM comments WHERE id=0"); $temp=0; while ($array=mysgl_fetch_assoc($total)) { $temp+=$array[clicks]; } echo "$total Clicks\n"; Code: [Select] <?php include("config.php"); $sql=mysql_query("SELECT * FROM uudised ORDER BY id DESC LIMIT 0,5") or die(mysql_error()); $x=0; while($row=mysql_fetch_array($sql)) { echo ($x+1).') '.$row['uudis'].'<br />'; $x++; } ?>Hey how should i get more data from uudised i want get date_added also but how i should do Trying to get a form to display checked and unchecked values based on what is in the database. Hard coded form works fine. I implode the array and it goes into the database as a comma delimited string. But I need to let users edit the checkbox values, so I need to create the form by exploding the string, iterating through the array, and outputting the checkbox form elements. Here's what I have... Code: [Select] <p>Specialization: <p> <?php //echo $session->userinfo['specialization']; THIS DISPLAYS THE STRING CORRECTLY $aSpecialization = array('Automotive', 'Aerospace', 'Biotech/Life Sciences', 'Chemicals', 'Damages Analysis', 'Electronics', 'Litigation', 'Manufacturing ', 'Materials', 'Medical Devices', 'Mobile Applications', 'Patent Prosecution', 'Physics', 'Renewable Energy', 'Semiconductors', 'Software', 'Telecommunications', 'Utilities'); //converting comma separated into array using explode function $dbspecialization= explode(',',$session->userinfo['specialization']); // echo $dbspecialization; THIS IS CONFIRMED AS AN array foreach ($aSpecialization as $specialization) { if(in_array($specialization,$dbspecialization)) { echo '<input name="specialization[]" type="checkbox" value="$specialization" CHECKED> $aSpecialization[] <br />'; } else { echo '<input name="specialization[]" type="checkbox" value="$specialization"> $aSpecialization[] <br />'; } } ?> But the output I get is... Code: [Select] <input name="specialization[]" type="checkbox" value="$specialization" CHECKED> $aSpecialization[] <br /> <input name="specialization[]" type="checkbox" value="$specialization"> $aSpecialization[] <br /> <input name="specialization[]" type="checkbox" value="$specialization"> $aSpecialization[] <br /> etc... What am I missing? Basically i made a form with checkbox using post.. here's the form Code: [Select] <?php echo '<form name="formupload" method="post" action="val3.php">'; echo '<input type="image" src="images/reject.png" name="test" width="170" height="35" border="0" value="reject">'; echo "<table border=\"5\" >"; echo "<tr><th>List of Instructor</th>"; if(mysql_num_rows($result)) { while($row = mysql_fetch_assoc($result)) { echo "<tr><td>"; echo "<input type='checkbox' name='list[]' value='".$row['fullname']."'>" .$row['fullname']."<br/></td>"; echo "</tr>"; } } else { echo "<tr><td>No one to Approve</td></tr>"; } echo '</form>'; ?> Then my val3.php will output the values of the checked checkbox. here's the code. Code: [Select] <?php foreach ($_REQUEST['list'] as $checkbox) { echo $checkbox; echo "<br/>"; } ?> Now i don't know how to insert those values to my database.. help pls. Hi guys, I am building a website with basic e-commerce functionality, using php and using xampp to test it. I am having issues when attempting to submit a quantity (into table orders) using a form and validating it against an existing value (from table products), giving a response on whether there is sufficient quantity in the second table. I am then, in another page (same one performing the validations), attempting to then show a result based on the initial quantity entered, with a summary of the order details and calculation of the quantity * price to display a total as well. This has all been built from scratch, however I may have taken the wrong approach for these two pages... any assistance or insight as to where I am going wrong would be greatly appreciated. Here is the page I have placed the products, existing quantity and a text field they are able to enter their desired quantity: Code: [Select] <?php session_start(); require_once "../database/db.php"; require_once "../includes/functions.php"; $page_title = 'Product Catalogue'; include_once "header.php"; $conn = mysqli_connect ($dbhost, $dbuser, $dbpassword, $dbname); $query = "SELECT * from products"; $result = mysqli_query($conn, $query); if (!$result) { include_once "header.php"; die ("Error, could not query the database"); } else { $rows = mysqli_num_rows($result); if ($rows>0) { while ($row = mysqli_fetch_array($result)) { ?> <form> <br /> <br /> <br /> <table> <tr> <td style="width: 200px">Product Code:</td> <td><?php echo $row['ProductCode']; ?></td> </tr> <tr> <td>Product Name:</td> <td><?php echo $row['ProductName']; ?></td> </tr> <tr> <td>Product Description:</td> <td><?php echo $row['ProductDescription']; ?></td> </tr> <tr> <td>Product Colour:</td> <td><?php echo $row['ProductColour']; ?></td> </tr> <tr> <td>Product Price:</td> <td>$<?php echo number_format($row['ProductPrice'],2); ?></td> </tr> <tr> <td>Product Image:</td> <td><img src="<?php echo $row['ProductImagePath']?>"/></td> </tr> <tr> <td>Quantity in Stock:</td> <td><?php echo $row['ProductQuantity']; ?></td> </tr> </table> </form> <form method="post"action="processQuantity.php"> <table> <tr> <td style="width: 200px">Quantity:</td> <td><input type="number" name="Quantity" id="Quantity" value="<?php if (isset ($quantity)) echo $quantity; ?>"size = "20" /></td> <td><input type="submit" name="Purchase" value= "Purchase" /></td> </tr> </table> </form> <hr /> <?php } include "footer.html"; } } ?> Here is the page that I am using to validate the data as well as show a result based on the entered amount: Code: [Select] <?php session_start(); require_once "../includes/functions.php"; require_once "../database/db.php"; $quantity = $_POST['Quantity']; $productquantity = $_POST['ProductQuantity']; $orderid = $_POST['orderid']; $productcode = $_POST['productcode']; $productprice = $_POST['productprice']; $total = $quantity * $productprice; $error_message = ''; if ($error_message != '') { include_once "displayCatalogue-PlaceOrder.php"; exit(); $conn = mysqli_connect ($dbhost, $dbuser, $dbpassword, $dbname); if (!$conn) { echo "Error"; } else { //sanitise date $scustomerid = sanitiseMySQL($customerid); $sproductcode = sanitiseMySQL($productcode); $squantity = sanitiseMySQL($quantity); $sproductprice = sanitiseMySQL($productprice); $sorderdate = sanitiseMySQL($orderdate); $query = "select productquantity from products where productcode = '$sproductcode'"; $result = msqli_query ($conn, $query); $productquantity = mysqli_num_rows($result); if ($quantity < $productquantity) { $error_message = "You cannot order more than what is currently instock"; include_once "displayCatalogue-PlaceOrder.php"; exit (); } else { $row = mysqli_fetch_row($result); $query = "INSERT into orders (customerid, productcode, quantity, productprice, orderdate) values ('$scustomerid', $sproductcode', '$squantity', '$sproductprice', '$sorderdate')"; $result = mysqli_query($conn, $query); $row = mysqli_affected_rows($conn); if ($row > 0) { include "header.php";?> <h3>Order Confirmation</h3> <p>Thank you, your order is now being processed.</p> <table> <tr> <td style="width: 200px">Order Number:</td> <td><?php echo $orderid; ?></td> </tr> <tr> <td>Product Code:</td> <td><?php echo $productcode; ?></td> </tr><tr> <td>Quantity:</td> <td><?php echo $quantity; ?></td> </tr> <tr> <td>Price:</td> <td><?php echo $productPrice; ?></td> </tr> <tr> <td>Total Cost of Order:</td> <td><?php echo $total; ?></td> </tr> </table> <?php include "footer.html"; } else { $error_message ="Error placing your order, please try again"; include "displayCatalogue-PlaceOrder.php"; exit(); } } } } //this is used to validate the quantity entered against what is available in the database ?> Hi everyone. I have a registration form on my website that returns errors if the form isnt filled out correctly. An example of the code that returns the errors is: // if first name is blank return error if (!$first_name) { echo "Please enter your first name!<br />"; } // if first name contains invalid charcters return error if (preg_match('/[^a-zA-Z\s]/', $first_name)) { echo "Your first name contains invalid charcters!<br />"; } // set first name maximum length if ($first_name && !preg_match('/[^a-zA-Z0-9\s]/', $first_name)) { if (strlen($first_name) >25) { echo "The maximum length for first name is 25 characters!<br />"; } } Iv wrote it like this so that i can get multiple error messages appearing at the same time. When it comes to writing the form data to the database im using the following: if ($first_name && !preg_match('/[^a-zA-Z\s]/', $first_name) && strlen($first_name) <26 && $last_name && !preg_match('/[^a-zA-Z\s]/', $last_name) && strlen($last_name) <26 && $dob_day != "Day" && $dob_month != "Month" && $dob_year != "Year" && $gender != "Select" && $email && filter_var($email, FILTER_VALIDATE_EMAIL) && $confirm_email && $email == $confirm_email && $email_count == 0 && $town && !preg_match('/[^a-zA-Z0-9\s]/', $town) && strlen($town) < 26 && $location != "Select" && $postcode && !preg_match('/[^a-zA-Z0-9\s]/', $postcode) && $username && !preg_match('/[^a-zA-Z\s]/', $username) && strlen($username) >2 && strlen($username) <25 && $username_count == 0 && $password && strlen($password) >5 && strlen($password) <26 && $confirm_password && $password == $confirm_password) { // code to write to database here } I was wondering if there was a better way to confirm that all the form data is ok, and if so write the data to the database? Im new to php and would love to learn a way to make this easier instead of typing out loads of lines of code. Thanks to anyone that can help me. Code: [Select] $product_id=$_GET['product']; $sql500="SELECT * FROM $tbl_name3 WHERE product_id='$product_id'"; $result500=mysql_query($sql500); $num_rows500=mysql_num_rows($result500); while($row500=mysql_fetch_array($result500)){ extract($row500); $review_product_rating_total=$review_product_rating; //What do I do here? } $average_rating=$review_product_rating_total/$num_rows500; I need a way to take a column of product ratings (0-5 in 1/2 increments), add them together, and divide by the number of rows taken from the database. I know how to get the number of rows with mysql_num_rows. But how would I add together the data from database? Hi guys, i have a select box which has been populated with values from the database however i would like to be able to select the value from the select box and change the qty. Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>stock manager</title> </head> <body> <?php $stockqty =&$_POST['stock_qty1']; ?> <center> <table> <td> <table> <td> <form action='stockview.php' method='POST'> Please Enter a Stock Name and Stock Value <table> <tr> <td> Stock Name: </td> <td> <input name="stock_name" type="text" /><BR /> </td> </tr> <tr> <td> Stock Qty: </td> <td> <input name="stock_qty" type="text" /> </td> </tr> </table> <input name="submit" type="submit" value="Add New Stock Items" /> </form> </td> </table> </td> <td> <table> <td> <form action='stockmanager.php' method='POST' enctype="multipart/form-data"> Please Select from the list the item you wish to update <table> <tr> <td> Stock Name: </td> <td> <?php $connect = mysql_connect("localhost","root", "") or die ("Couldn't Connect!"); mysql_select_db("stock", $connect) or die("Couldn't find db"); // select database $query=("SELECT id, stockname FROM stocks"); $result = mysql_query ($query); echo "<select name=stock value=''>Edit Stock QTY</option>"; while($nt=mysql_fetch_array($result)) { //Array or records stored in $nt echo "<option value=$nt[id]>$nt[stockname]</option>"; /* Option values are added by looping through the array */ } $queryreg = mysql_query("SELECT * FROM stocks WHERE stockqty='$stockqty'"); $numrows = mysql_num_rows($queryreg); $update = mysql_query("UPDATE stocks SET stockqty='$stockqty' WHERE stockname = '$stockname'"); echo("Its updated"); ?> </td> </tr> <tr> <td> Stock Qty: </td> <td> <input name="stock_qty1" type="text" /> </td> </tr> </table> <input name="submit" type="submit" value="Update stock items" /> </form> </td> </table> </td> </table> </center> </body> </html> Any help would be greatly appreciated... ive been working on this for a while and cant seem to find the answer. Thanks Lance Hi all, I've made a page the variables are being recieved and echo'd ok, however they are not being inserted into the database. below is the file with the insert statement. any help really appreciated. MsKazza Code: [Select] <?php // Database connect $con = mysql_connect("mysql1.myhost.ie","admin_book","root123"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("book_test", $con); $orderid=$_GET['orderid']; //Parse Values from Coupon.php Form $orderid = mysql_real_escape_string(trim($_POST['orderid'])); $design = mysql_real_escape_string(trim($_POST['design'])); $childname = mysql_real_escape_string(trim($_POST['childname'])); $address = mysql_real_escape_string(trim($_POST['address'])); echo $orderid; echo $design; echo $childname; echo $address; $sql="INSERT INTO details (orderid, design, childname, address) VALUES ('$orderid','$design','$childname','$address')"; ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Digital Scribe Books</title> <link href="style.css" rel="stylesheet" type="text/css" /> <script type="text/javascript"> function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; } function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } </script> </head> <body onload="MM_preloadImages('images/buttons/home_over.png','images/buttons/books_over.png','images/buttons/cards_over.png','images/buttons/letters_over.png')"> <div id="snow"> <div id="wrapper"> <div id="header"> <div id="logo"><img src="images/digital_scripe.png" width="218" height="91" /></div> <div id="menu"><a href="index.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Home','','images/buttons/home_over.png',1)"><img src="images/buttons/home_act.png" name="Home" width="131" height="132" border="0" id="Home" /></a><a href="books.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Books','','images/buttons/books_over.png',1)"><img src="images/buttons/books_act.png" name="Books" width="131" height="132" border="0" id="Books" /></a><a href="cards.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Cards','','images/buttons/cards_over.png',1)"><img src="images/buttons/cards_act.png" name="Cards" width="131" height="132" border="0" id="Cards" /></a><a href="letters.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Letters','','images/buttons/letters_over.png',1)"><img src="images/buttons/letters_act.png" name="Letters" width="131" height="132" border="0" id="Letters" /></a></div> </div> <div id="content"> <div id="info_bar"><br /><br /><br /> <p>Your personal order number is:</p><br /> <br /> <p>Please fill out the details of where you would like your order to be shipped to.</p> </div> <form action="card_paynow.php" method="POST" name="custdetails" id="custdetails"> <table width="60%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="19%">orderid</td> <td width="81%"><input name="orderid" type="hidden" value="<? echo $orderid; ?>"></td> </tr> <tr> <td>name</td> <td><input name="name" type="text" id="name"></td> </tr> <tr> <td>surname</td> <td><input name="surname" type="text" id="surname"></td> </tr> <tr> <td>address 1 </td> <td><input name="add1" type="text" id="add1"></td> </tr> <tr> <td>address 2 </td> <td><input name="add2" type="text" id="add2"></td> </tr> <tr> <td>town</td> <td><input name="town" type="text" id="town"></td> </tr> <tr> <td>county</td> <td><input name="county" type="text" id="county"></td> </tr> <tr> <td>postcode</td> <td><input name="postcode" type="text" id="postcode"></td> </tr> <tr> <td>number</td> <td><input name="phone" type="text" id="phone"></td> </tr> <tr> <td>email</td> <td><input name="email" type="text" id="email"></td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td><input type="submit" name="Submit" value="Continue..."></td> </tr> <tr> <td> </td> <td> </td> </tr> </table> </form> </div> <div id="footer" class="clear"><div id="sign"><div id="sign_text">Personalised<br /> Books</div> </div></div> </div></div> </body> </html> Ok so I have a website with two types of photo gallerys. Model Cars and Model Planes. The galleries are becoming so big that I need to add an archive link to the galleries, but it's messy to have the archive link there until we actually enable the archived photos. So what I want to do is show the DIV with the archive link in it if the page can find database a 1 in the model_pictures.car_gallery AND model_pictures.archive. How would I achieve this? The page is already connected to the database as it's pulling the images and information for the gallery. I need it to scan the entire 'archive' column in the database and also the 'car_gallery' and if it finds 1's in there AND the car_gallery then to show the link. What I would like to avoid, as I have two galleries, is having the archive link show on the car gallery when it finds a 1 in the archives column, but that archive is for a plane_gallery photo. Hence why I would like to have check both car_gallery + archive and then plane_gallery + archive. Any help would be greatly appreciated. Hi all, i want my list/menu field values to come from my database. how can i accomplish that? thanks i did Code: [Select] <select name="select"> <option value="0">--select below--</option> <option value="1">Me</option> <?php require_once '../konnect/konex.php'; $result = mysql_query("SELECT * FROM is_clients"); while($row = mysql_fetch_array($result)) { echo "<option value ='2'>".$row"['name']</option>"; echo "<br />"; } ?> </select> Hi all, I'm just wondering if there's an easier way of doing what accomplishing the following: I have a value in my database which represents a selection in a drop down menu, i want to read it from the database and have it automatically selected depending on the stored data. I have the following working but just wondered if there was an easier way to get the same result: Code: [Select] <?php //database connection $query = "SELECT id FROM `tablename` WHERE username='$username'"; $result = mysql_query($query); $row = mysql_fetch_object($result); $id = $row->id; $id = (int)$id; ?> <select name="id"> <option value="">Select your option...</option> <option value="1" <?php if (($id - 1) === 0) { echo 'selected="selected"'; }?>>Selection 1</option> <option value="2"<?php if (($id - 2) === 0) { echo 'selected="selected"'; }?>>Selection 2</option> </select> Sorry if it's not very clear, i'll explain best i can if anyone can help. Thanks Hi guys, Im developing a stock system and so far new stock and can be added with the quantity, however im trying to update the stock by using a select box and selecting the type of stock and inputting a new qty. the form and everything is set up and i can select files from the database, however i dont know how to update files from a select box The code i got so far is Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>stock manager</title> </head> <body> <?php $stockqty =&$_POST['stock_qty1']; ?> <center> <table> <td> <table> <td> <form action='stockview.php' method='POST'> Please Enter a Stock Name and Stock Value <table> <tr> <td> Stock Name: </td> <td> <input name="stock_name" type="text" /><BR /> </td> </tr> <tr> <td> Stock Qty: </td> <td> <input name="stock_qty" type="text" /> </td> </tr> </table> <input name="submit" type="submit" value="Add New Stock Items" /> </form> </td> </table> </td> <td> <table> <td> <form action='stockmanager.php' method='POST' enctype="multipart/form-data"> Please Select from the list the item you wish to update <table> <tr> <td> Stock Name: </td> <td> <?php $connect = mysql_connect("localhost","root", "") or die ("Couldn't Connect!"); mysql_select_db("stock", $connect) or die("Couldn't find db"); // select database $query=("SELECT id, stockname FROM stocks"); $result = mysql_query ($query); echo "<select name=stock value=''>Edit Stock QTY</option>"; while($nt=mysql_fetch_array($result)) { //Array or records stored in $nt echo "<option value=$nt[id]>$nt[stockname]</option>"; /* Option values are added by looping through the array */ } $queryreg = mysql_query("SELECT * FROM stocks WHERE stockqty='$stockqty'"); $numrows = mysql_num_rows($queryreg); $update = mysql_query("UPDATE stocks SET stockqty='$stockqty' WHERE stockname = '$stockname'"); echo("Its updated"); ?> </td> </tr> <tr> <td> Stock Qty: </td> <td> <input name="stock_qty1" type="text" /> </td> </tr> </table> <input name="submit" type="submit" value="Update stock items" /> </form> </td> </table> </td> </table> </center> </body> </html> Any help would be greatly appreciated. Thanks Lance I have made an autocomplete form... originally the values were static: $aUsers = array( "Adams, Egbert", "Altman, Alisha", "Archibald, Janna", ); Now I want the values from a database table DEVICES row name DeviceName: $sql = "SELECT DeviceName FROM DEVICES"; $res = mysql_query($sql); $aUsers = array(); while ($row = mysql_fetch_assoc($res)) { $aUsers[] = $row; } It will not display the values in my autocomplete form when text is entered.... but with static data it will. Im confused! Thank you |