Search the Community
Showing results for tags 'sql'.
-
I have two arrays and all I want from them is the differences to show and any item that existed in both not to show. Please find my workings below mysql_select_db($database_dbconnect, $dbconnect);$query_Asset = "SELECT idAsset, AssetName FROM Asset WHERE idLocation = '1'";$AssetUp = mysql_query($query_Asset, $dbconnect) or die(mysql_error()); $array1 = array(); while ($f = mysql_fetch_assoc($AssetUp)) {$array1[] = $f;} mysql_select_db($database_dbconnect, $dbconnect);$query_DocUp = "SELECT Asset.idAsset, Asset.AssetName FROM AssetDocStand INNER JOIN Asset ON AssetDocStand.idAsset = Asset.idAssetWHERE AssetDocStand.idDocumentStandards = '2' AND Asset.idLocation ='1'";$DocUp = mysql_query($query_DocUp, $dbconnect) or die(mysql_error());$array2 = array(); while ($f = mysql_fetch_assoc($DocUp)) {$array2[] = $f;} print_r($array1); echo "<br><br><br>"; print_r($array2); shows the following when the page is loaded. Array ( [0] => Array ( [idAsset] => 10000005 [AssetName] => HP ) [1] => Array ( [idAsset] => 10000006 [AssetName] => HP Server ) [2] => Array ( [idAsset] => 10000009 [AssetName] => HP Laptop ) [3] => Array ( [idAsset] => 10000010 [AssetName] => Office Printer ) [4] => Array ( [idAsset] => 10000023 [AssetName] => test ) ) Array ( [0] => Array ( [idAsset] => 10000023 [AssetName] => test ) ) Now when i type $array3 = array_diff($array1, $array2 ); print_r($array3); I get Array ( ) Ive also tried array_diff_key() which also produces nothing. All I want to be left with is Array ( [0] => Array ( [idAsset] => 10000005 [AssetName] => HP ) [1] => Array ( [idAsset] => 10000006 [AssetName] => HP Server ) [2] => Array ( [idAsset] => 10000009 [AssetName] => HP Laptop ) [3] => Array ( [idAsset] => 10000010 [AssetName] => Office Printer ))
-
Hi Guys I have written this function which basically finds all assets that have a certain document associated with them in a certain location. It works great however I need the opposite. I need all the assets that don't have this document but i cant get my head around the query can anyone help me please? function GetUploadedDocsNoAsset($doctype,$archive, $location){ $colname_DocUp = "-1";if (isset($doctype)) { $colname_DocUp = $doctype;} $colname_Archive = "-1";if (isset($archive)) { $colname_Archive = $archive;}$colname_Location = "-1";if (isset($location)) { $colname_Location = $location;} $query_DocUp = sprintf("SELECT idAssetDocStand FROM AssetDocStand INNER JOINAsset ON AssetDocStand.idAsset = Asset.idAssetWHERE AssetDocStand.idDocumentStandards = %s AND AssetDocStand.Archive=%s AND Asset.idLocation = %s", GetSQLValueString($colname_DocUp, "int"), GetSQLValueString($colname_Archive, "text"), GetSQLValueString($colname_Location, "int"));$DocUp = mysql_query($query_DocUp);$totalRows_DocUp = mysql_num_rows($DocUp);return $totalRows_DocUp;}
-
hello I am looking for help on a sql problem. Not sure if I have a statement mixed up or not but the table simply won't render. Any help would be greatly appreciated. Database name = test I have two tables table 1 = parts table 2 = parts_pricing The main recordset name is RSparts Please see my current php code - $maxRows_RSparts = 10; $pageNum_RSparts = 0; if (isset($_GET['pageNum_RSparts'])) { $pageNum_RSparts = $_GET['pageNum_RSparts']; } $startRow_RSparts = $pageNum_RSparts * $maxRows_RSparts; $colname1_RSparts = "-1"; if (isset($_GET['figno'])) { $colname1_RSparts = $_GET['figno']; } $colname2_RSparts = "-1"; if (isset($_GET['modelno'])) { $colname2_RSparts = $_GET['modelno']; } mysql_select_db($database_test, $test); $query_RSparts = sprintf("SELECT * FROM parts INNER JOIN partspricing ON partspricing.sellingprice=parts.partID WHERE figno = %s AND modelno = %s ORDERBY ACS ", GetSQLValueString($colname1_RSparts, "text"),GetSQLValueString($colname2_RSparts, "text")); $query_limit_RSparts = sprintf("%s LIMIT %d, %d", $query_RSparts, $startRow_RSparts, $maxRows_RSparts); $RSparts = mysql_query($query_limit_RSRSparts, $test) or die(mysql_error()); $row_RSparts = mysql_fetch_assoc($RSparts; if (isset($_GET['totalRows_RSparts'])) { $totalRows_RSparts = $_GET['totalRows_RSparts']; } else { $all_RSparts = mysql_query($query_RSparts, $test); $totalRows_RSRSparts = mysql_num_rows($all_RSparts); } $totalPages_RSparts = ceil($totalRows_RSparts/$maxRows_RSparts)-1; Table setup; <table> <tr> <td>Key No.</td> <td>Part Number</td> <td>Description</td> <td>QTY</td> <td>S/N Break</td> <td>Availabilty</td> <td>Price</td> </tr> <?php do { ?> <tr> <td><?php echo $row_RSparts['keyno']; ?></td> <td><?php echo $row_RSparts['partno']; ?></td> <td><?php echo $row_RSparts['description']; ?></td> <td><?php echo $row_RSparts['qty']; ?></td> <td><?php echo $row_RSparts['snbreak']; ?></td> <td><?php echo $row_RSparts['availability']; ?></td> <td><?php echo $row_RSparts['sellingprice']; ?></td> </tr> <?php } while ($row_RSparts = mysql_fetch_assoc($RSparts)); ?> If I leave out parts INNER JOIN partspricing ON partspricing.sellingprice=parts.partID the table works and renders fine or if I leave out WHERE figno = %s AND modelno = %s ORDERBY ACS the table renders fine. I am missing something here. If I leave it as is the table will not render at all. Hopefully this is something simple any help would be greatly appreciated!
- 1 reply
-
- inner join
- where statements
-
(and 2 more)
Tagged with:
-
I have a <a>, on click delete a product from database that is on server, I want to delete the product and the same time delete the image of that product. I using unlink() my code delete the product but don't delete the image and I don't no why someone can tell me what is missing ? if((isset($_GET["remove"])) && ($_GET["remove"] != "")){ $idproduct = $_GET["remove"]; $sql ="DELETE FROM product WHERE idproduct = '".$idproduct."'"; if(mysqli_query($connect, $sql) or die ("Erro")){ //the part that don't work $file = $frontpage_url."/images/".$_FILES["imagem"]["name"]; unlink($file); echo "success"; } }
-
Hi can i find out if it is possible to retrieve rows from my tables in the database but display them as hyperlinks which can lead to a page (can it be just 1 page that allows values to be inserted into?) that allows charts (using highcharts) or so to be created based on the values passed from the database? Sorry if this is a stupid question. I'm new to this and I'm exploring ways to present my data. Thanks!
-
I've run into a few problems as I was following this guys tutorial to setup a registration, log-in, etc. into my website. - for references here is the tutorial that I was going through and the problem that I have encountered has occurred during the process at: http://youtu.be/740kEwoRPKk?t=15m20s As you can see in the 3rd image attached each one of my .php documents also have a notification bar on the top of the coding which entitles, "Dynamically-related files could not be resolved because the site definition is not correct for the server. Retry | Setup" I have my php files setup exactly as he has it only thing different then his is that I had to change my localhost to localhost:8080 due to a bump in the road that happened due to the fact that I have Skype on my computer which encounters a problem with the testing-server service I am using which is PhPMyAdmin The error that I am getting when I try to connect my database to my testing server is in the image attached. Please reply to this post as soon as possible so I can get this problem resolved asap! Take note that I am working on everything from Dreamweaver CC!! Also I have tried several variables for setting up the database 'MySQL server:' such as 'localhost' , 'localhost:8080' , 'localhost8080' , 'localhost' , etc. If you have any further questions you can reply to me on here or you can add me on skype as well! My skype name is: lowheartrate Thank you to all in advance!! ~Codi Bezouka-Smith 'PHP-Beginner' - screenshots of the other images that weren't uploaded - - http://prntscr.com/302xut - http://prntscr.com/302xz8 - http://prntscr.com/302y3f
- 6 replies
-
- testing server
- testing
-
(and 3 more)
Tagged with:
-
Hi all, having some trouble working out whats going wrong here, don't get no errors to work from so I am stuck! Why is this NOT storing in the table? I have other code using the execution function and working, but this is failing but no errors. Please help! SQL Passing SQLExecute(" INSERT INTO `dbleads`.`offer` (`Username`, `Password`, `PWSalt`, `FullName`, `Email`, `Phone`, `Mobile`, `CompanyName`, `CompanyABN`, `Street`, `Suburb`, `State`, `Postcode`, `BStreet`, `BSuburb`, `BState`, `BPostcode`, `Comment`, `AgreeTC`, `TimeStamp`) VALUES (`$unop`, `$pwop`, `$salted`, `$fnop`, `$emailop`, `$phoneop`, `$mbop`, `$cnameop`, `$cabnop`, `$streetop`, `$suburbop`, `$stateop`, `$postcodeop`, `$Bstreetop`, `$Bsuburbop`, `$Bstateop`, `$Bpostcodeop`, `$commentop`, `$AgreeTC`, `$Timestamp`); "); Connection: function SQLExecute($sqlstring){ // CONNECTION $mysqli = new mysqli(HOST, USER, PASSWORD, DATABASE); if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } $mysqli->query($sqlstring); /* close connection */ $mysqli->close(); }
-
In my first page I have I have a query that returns tournaments names in a table in this format echo "<td><a href='tournament.php'>" . $info['tournament'] . "</a></td>"; $info['tournament'] has the tournament name which when clicked takes me to the page tournament.php where I have this code $data = mysql_query("SELECT team1,score1,team2,score2 FROM smite where tournament='';") or die(mysql_error()); what i want is to have the value clicked in the previous page that linked to this one, in tournament='HERE' so that the query retrieve the data for that tournament i have tried echo "<td><a href='tournament.php?tournament=".$info['tournament']."'>" . $info['tournament'] . "</a></td>"; and $tournamentName = $_GET['tournament']; $data = mysql_query("SELECT team1,score1,team2,score2 FROM smite where tournament='$tournamentName';") or die(mysql_error()); the query returns empty and when i print $tournamentName i get for example (Golden Cup) which should be (Golden Cup #1) the $_GET removed #1 which is why the query returns NULL and if i do partial match to $tournamentName i will get all the Golden Cup tournaments not just the one i clicked can anyone help me solve this problem ? Thank you
-
Hi, you all know that from phpmyadmin you can run an SQL Query for example "select * from table where code like '0011'" now my question is can I add a query box like this directly into my website, so I can run a query without login into phpmyadmin? your help is very appreciated since I cannot make this happen. thanks
-
Hi guys, I was wondering if i could have some help on a piece of functionality I am trying to implement onto a website I am currently developing. The Scenario is as follows : I have a table residing on a MySql data base called Bookings. The Bookings table consists of a composite primary key based upon the following 2 fields: BookingDate & Booking Slot. On my website, I have built a bookings page which will consist of a a simple HTML Form, which has a Date Field and a Radio-Button group which has 3 different time slots (eg: 9am, 2pm and 4pm). Firstly, the User will select a Date they would wish to place a booking on and then click a submit button called "Check Availablity". Once this button is clicked, Ideally, I would like a script to check an see what free slots are available for that Date and then disable the radio buttons related the slots which are already booked. Here is a simple scenario to help explain the functionality i am trying to implement : The User comes to the Bookings page, and selects the Date 14/03/2011. Then clicks the "Check Availablity" button. In this scenario, the 9am slot is already booked for this date (eg: this booking already exists on the MySql database table), so the 9am radio button on the page is then disabled, not allowing the user to try an attempt to book this timeslot on this date. Below is the a simplified version of the php script which I wrote to implement the this functionality. <?php function checkSlot() { // Get data $test_date = $_GET["bookingDate"]; // Database connection $conn = mysqli_connect("localhost","root","","wordpress"); if(!$conn) { die('Problem in database connection: ' . mysql_error()); } // Attempt to find Duplicate Primary Keys $query = "SELECT Count(*) AS 'total' FROM Bookings WHERE booking_date ='{$booking_date}' AND booking_slot = '9am'"; $result = mysqli_query($conn, $query) or die(mysqli_error($conn)); $num = $result->fetch_assoc(); If ($num['total'] == 0) { echo "<script> document.getElementById('9amTimeSlotRadioButton').disabled = false; </script>"; } else if($num['total'] > 0) { echo "<script> document.getElementById('9amTimeSlotRadioButton').disabled = true; </script>"; } } ?> My problem is that I cant get the Javascript line within the if statement to execute and disable/enable the related 9am radio button. Upon research into this, I have recently found out that it is not possible to do this with just Php and JavaScript, as php runs serverside and javascript runs client-side and Ajax would be needed here. So, im in a spot of bother now as one of the main selling points of this project was to be able to get this functionality working. I have a massive favour to ask of you guys, could you chime in and guide me on how to implement this functionality by using Ajax? I have zero experience in the language so I really dont know where to start. Any input at all on this topic would be much appreciated. Thanks in advance guys, Dave Ireland.
-
i'm wondering what is this problems. i copy paste it to other page. it works fine. but only this page have the error. spend most of time searching solution and i google for other solution still not working. the dreamweaver said there is no syntax error but when running it on localhost. then this appear "Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\fpdf\form3_final_dead.php on line 14" 2nd, i'm creating a form.. it should be look like this : http://prntscr.com/2xfd0g but when run on localhost, this happen : http://prntscr.com/2xfd48 //note that, there is a missing column in the page. the code also contain this
-
I'm using sql with php and mysql_fetch_assoc is returning null even though mysql_num_rows returns 1. I've echoed the query statement I'm using and entered the output manually and sql does return a value. I'm not sure why the code is returning a null. Basically I have $rv = mysql_query("SELECT (blah) from my_table WHERE my_key = " . $value . ";", $mysql_link); echo "" . mysql_num_rows($rv); if(!$rv) { echo 'There was a problem with your order. '; die('Could not connect: ' . mysql_error($mysql_link)); }else { if ($row = mysql_fetch_assoc($sql)) { //code }else { echo 'There was a problem setting up your order. '; die('Missing fields: ' . mysql_error($mysql_link)); } } And the missing fields is printing out even though echo "" . mysql_num_rows($rv); shows 1.
-
Hii.. I had made a table in the database. And also had printed out the data... There are 20 episodes in a movie... And I had fetch and printed all the 20 episodes. Now I want to make those 20 lines clickable link and when user clicks on that link than it should perform some operation like in the thenewboston.org website when you click on Video & Tutorials Tab from the nav bar than it opens up all the topics. and when we click on for e.g. PHP VIDEOS than it takes to the particular page and than in the PHP Tutorials it shows a list of 200 videos and than when you click on any of the page than it fetch the data from database and than print the related data. So how should I make the dynamic links like http://thenewboston.org/watch.php?cat=11&number=21 ... And how should I write the operation in my php page which than performs the query and display it on that page... Any link referring to tutorial will work... Any Help would be appreciated.
- 6 replies
-
- sql
- dyanmic link
-
(and 3 more)
Tagged with:
-
I am wanting to echo a table if a field = x and if not echo another table. Can this be done easily? I have tried but not having much luck. Any help would be appreciated by this "on the fly" learner. Something like... IF AdviserCode=X then <table width="610" border="0" align="center" cellpadding="4" cellspacing="0"> <tr class="text-sectionheading"> <td width="100">Date </td> <td width="85">RCTI</td> <td width="85">Detail 1</td> <td width="85">Detail 2</td> <td width="85">Detail 3</td> <td width="85">Detail 4</td> <td width="85">Detail 5</td> </tr> <?php include("../edb.php"); $result=mysql_query("SELECT * FROM `afddocs_adviser_comm` WHERE AdviserCode =".$_SESSION['uid']." order by DateUploaded DESC"); while($test = mysql_fetch_array($result)) { $id = $test['id']; echo"<tr>"; echo"<td class='text-questions'>".$test['DateUploaded']."</td>"; echo"<td><a class='".$test['RCTIcssclass']."'href =".$test['RCTIURL'].">".$test['RCTIImageType']."</a>"; echo"<td><a class='".$test['Detail1cssclass']."'href =".$test['Detail1URL'].">".$test['Detail1ImageType']."</a>"; echo"<td><a class='".$test['Detail2cssclass']."'href =".$test['Detail2URL'].">".$test['Detail2ImageType']."</a>"; echo"<td><a class='".$test['Detail3cssclass']."'href =".$test['Detail3URL'].">".$test['Detail3ImageType']."</a>"; echo"<td><a class='".$test['Detail4cssclass']."'href =".$test['Detail4URL'].">".$test['Detail4ImageType']."</a>"; echo"<td><a class='".$test['Detail5cssclass']."'href =".$test['Detail5URL'].">".$test['Detail5ImageType']."</a>"; echo "</tr>"; } mysql_close($conn); ?> OR (same table as above minus a couple of colums)
-
Need help badly! Setting up a new website with user logins. Pretty simple kind of stuff. Started working on letting the user upload a profile photo for their account, managed to get the user to be able to upload the photo in to a file on the site (upload/) and the image name entered in to their user details in SQL database. Worked fine. Only problem is when I try to recall the information, i've only been able to recall everybody's information and not just the logged in user. Here is the code I'm using. Bare in mind, I'm no pro with PHP and SQL so please help with as many details as possible. Thanks! ---------------------------------------------------------- <?php // Connects to your Database mysql_connect("localhost", "username", "password") or die(mysql_error()) ; mysql_select_db("database name") or die(mysql_error()) ; //Retrieves data from MySQL $data = mysql_query("SELECT * FROM users") or die(mysql_error()); //Puts it into an array while($info = mysql_fetch_array( $data )) { //Outputs the image and other data Echo "<img src=http://www.mysite/users/upload/".$info['photo'] ."> <br>"; Echo "<b>Name:</b> ".$info['name'] . "<br> "; } ?> ---------------------------------- This seems to recall everyones info. I only want the display photo to be shown for the logged in user. I have tried a lot of changes and either the image doesn't show or nothing shows.
-
Ok, so I created a test database on my server, created 1 table with 1 row in it and the row is populated with values. I can connect to the database without error, but when I try to put in a while loop to print the results I get nothing but a blank screen. I tried placing some debug code in the while loop to see where its getting hung up but the while loop doesn't want to run at all. I placed an echo directly outside of the loop and the debug text is displayed fine but anything I put in the loop doesn't work. Can anyone help me out? Here is my code: <!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> </head> <body> <?php $dbuser = "webestat_testdb"; $dbpass = "password"; $dbname = "webestat_testdb"; $server = "localhost"; $conn = mysql_connect($server, $dbuser, $dbpass); if (!$conn) { echo "Failed to connect to db" . mysql_error(); } $selectdb = mysql_select_db('webestat_testdb', $conn); $sql = "SELECT * FROM 4000Series"; $results = mysql_query($conn, $sql); while($row = mysql_fetch_assoc($results)) { echo "test"; echo $row['gpu']. " " .$row['khs']. " " .$row['usd']; echo "<br>"; } mysql_close($conn); ?> </body> </html>
-
Can anyone help me please? I am trying to populate my page with data that is filtered from the dropdown box. It can either be "onchange" or clicking a button, not too fussed on this. I have tried so many ways but getting more and more lost an confused and ended up with nothing at all. I have stripped the coding back to where it last worked so any help is appreciated. <body> <table width="680" border="0" align="center" cellpadding="4" cellspacing="0"> <tr> <td> </td> </tr> <tr><td class="text-heading"><p>Financial Services Guides and Adviser Profiles</p><p class="Text_Heading_Black1">PAGE STILL IN DEVELOPMENT</p> <form id="form1" name="form1" method="post" action=""> <span class="text-questions">Adviser: </span> <select name="advselect" id="advselect"> <option value=" " selected="selected"> </option> <?php require ('../edb.php'); if (!$con) { die("MySQL could not connect!"); } $result= mysql_query("SELECT id, LastName, FirstName, UserType FROM `eusers` WHERE UserType='ADV' or UserType='STF' ORDER by LastName ASC"); while ($row = mysql_fetch_array($result)){ echo '<option value="'. $row['id'] .'">'. $row['LastName'] .', '. $row['FirstName'] .'</option>'; } ?> </select> <input type="submit" name="advselect" id="advselect" value="Filter / View" /> </form></td> </tr> <tr><td><p class="Text_SubHeading">Current Version </p> <table width="650" border="0" align="center" cellpadding="4" cellspacing="0"> <tr class="text-sectionheading"> <td width="100">Date </td> <td width="150">Adviser</td> <td width="200">Document</td> <td width="100">Version</td> <td width="50">Current</td> <td width="50">View</td> </tr> <?php include("../edb.php"); $data=mysql_query("SELECT * FROM `adocs_fsg_profile` INNER JOIN `eusers` ON eusers.id = adocs_fsg_profile.AdviserCode WHERE Current='Y' and ORDER BY LastName ASC, FirstName ASC, DocName ASC, DateUploaded DESC"); while($test = mysql_fetch_array($data)) { $id = $test['id']; echo"<tr>"; echo"<td class='text-questions'>".$test['DateUploaded']."</td>"; echo"<td class='text-questions'>".$test['LastName'].", ".$test['FirstName']."</td>"; echo"<td class='text-questions'>".$test['DocName']."</td>"; echo"<td class='text-questions'>".$test['Version']."</td>"; echo"<td class='text-questions'>".$test['Current']."</td>"; echo"<td><a class='".$test['cssclass']."'href =".$test['URL'].">".$test['ImageType']."</a>"; echo "</tr>"; } mysql_close($conn); ?> </table> <p class="Text_SubHeading">Previous Versions </p> <table width="650" border="0" align="center" cellpadding="4" cellspacing="0"> <tr class="text-sectionheading"> <td width="100">Date </td> <td width="150">Adviser</td> <td width="200">Document</td> <td width="100">Version</td> <td width="50">Current</td> <td width="50">View</td> </tr> <?php include("../edb.php"); $data=mysql_query("SELECT * FROM `adocs_fsg_profile` INNER JOIN `eusers` ON eusers.id = adocs_fsg_profile.AdviserCode WHERE Current='N' ORDER BY LastName ASC, FirstName ASC, DocName ASC, DateUploaded DESC"); while($test = mysql_fetch_array($data)) { $id = $test['id']; echo"<tr>"; echo"<td class='text-questions'>".$test['DateUploaded']."</td>"; echo"<td class='text-questions'>".$test['LastName'].", ".$test['FirstName']."</td>"; echo"<td class='text-questions'>".$test['DocName']."</td>"; echo"<td class='text-questions'>".$test['Version']."</td>"; echo"<td class='text-questions'>".$test['Current']."</td>"; echo"<td><a class='".$test['cssclass']."'href =".$test['URL'].">".$test['ImageType']."</a>"; echo "</tr>"; } mysql_close($conn); ?> </table></td> </tr> </table> </body>
-
Hi how can i get this sql query to work in php ? this query worked in navicat /* API */ INSERT IGNORE INTO ps_search_index (id_product, id_word, weight) SELECT DISTINCT Product_ID, Product_ID + 5000 'id_word', '1' FROM ps_product_part_number WHERE API != '' AND API IS NOT NULL; INSERT IGNORE INTO ps_search_word (id_word, id_shop, id_lang, word) SELECT DISTINCT Product_ID + 5000 'id_word', '1', '1', API FROM ps_product_part_number WHERE API != '' AND API IS NOT NULL; I GOT THIS FAR "INSERT INTO ps_search_index (id_product, id_word, weight) SELECT DISTINCT Product_ID, Product_ID + 5000 AS id_word , '1' FROM ps_product_part_number WHERE API != '' AND API IS NOT NULL" "INSERT INTO ps_search_index (id_product, id_word, weight) SELECT DISTINCT Product_ID, Product_ID + 5000, '1' FROM ps_product_part_number WHERE API != '' AND API IS NOT NULL"
-
Hi, I'm not sure if this is possible and it might be a bit of a wired question but basically. Is there a away to select a column from a name stored in a row. So for example: I have these to tables: TABLE 1 | ID | USER | Column Needed | | 1 | Bob | i2 | | 2 | Jim | i4 | TABLE 2 | i1 | i2 | i3 | i4 | i5| | 0 | 9 | 1 | 0 | 2 | And I want to select Bob and the column from TABLE 2 that is needed is i2. I then also want to select Jim and the column from TABLE 2 that is needed is i4. I want to do this all in one SQL query. And the column name that they need for each row is stores in TABLE 1 under column needed. Thanks for any help!!!!
-
how to make a stored procedure in sql and use it on php?? i wanna make a stored procedure of my queries below and use it on my php program. can anyone help me? Please //query 1 INSERT INTO afnup_worksheet (faic,fnl_name,ftotal) SELECT DISTINCT atic ,atname ,(SELECT SUM(inttotal) FROM app_interview t2 WHERE t2.atic = t.atic)/7 FROM app_interview t GROUP BY atname HAVING COUNT(DISTINCT atic) //query 2 SELECT count(t.atic) as total,t2.name FROM app_interview as t, tb_applicants as t2 WHERE t.atic = t2.aic GROUP BY t.atic;
-
<?php include("../../connect.php"); $burger=$row['event_name']; $query=mysql_query("CREATE TABLE $burger (id int(10) AUTO_INCREMENT,event_id char(50), name char(100))")or die (mysql_error()); ?> error : Incorrect table definition; there can be only one auto column and it must be defined as a key
-
I am having a minor problem with my code if any one can help. I have a form where the user can add a new article however on submit this error is displayed: Warning: mysqli_query() expects parameter 1 to be mysqli, object given in //public_html/admin/includes/addnews.php on line 12. This is the code: $auth = $_POST['auth']; $tit = $_POST['tit']; $stat = $_POST['stat']; $shrt = $_POST['short']; $art = $_POST['art']; $conn = mysqli_connect("localhost","db","password","db") or die ("Could not connect to database"); $query = $conn->prepare ("INSERT INTO newsitem (author,title,shortdesc,article,newsdate,status) VALUES ('$auth','$tit','$shrt','$art',CURDATE(),'$stat')"); $result = mysqli_query($query,$conn); if($result){ echo "successful"; echo "<BR>"; echo "<a href='news.php'>Back to News </a>"; } else { echo "error could not upload article"; } mysqli_close($conn); ?> I have been looking at this for the last two hours with no hope, is there anyone who can point me in the right direction please?
-
Hi Guys I am wanting to create a menu page which displays menu's based on if the menu field in the sql database has a yes or no in the contents by using an if statement. I have not had much success and would like some help to point me in the right direction. <?php include("../edb.php"); $id =$_REQUEST['id']; $result=mysql_query("SELECT * FROM `eusers` WHERE id='".$_SESSION['uid']."'"); if($MENUAdviser="Y") echo '<script type="text/javascript" src="ExtranetMenu.js"></script>'; if($MENUPAS="Y") echo '<script type="text/javascript" src="PASMenu.js"></script>'; if($MENUStaff="Y") echo '<script type="text/javascript" src="IntranetMenu.js"></script>'; if($MENUWebAdmin="Y") echo '<script type="text/javascript" src="WebAdminMenu.js"></script>'; ?>
-
Sooo, I could use some help. The code is needed to populate a database from the form, unfortunately, it is not populating the database. When I click submit, a white page appears <?php $a = $_POST['auth']; $t = $_POST['tit']; $st = $_POST['stat']; $sn = $_POST['short']; $c = $_POST['art']; $conn = mysqli_connect(""); if(!is_uploaded_file($_FILES['file']['tmp_name'])) { $query = "INSERT INTO newsitem (author,title,shortdesc,article,newsdate,status) VALUES ('$a','$t','$sn','$c',CURDATE(),'$st')"; } else { if ($_FILES['file']['type'] != "image/gif" && $_FILES['file']['type'] != "image/jpeg" && $_FILES['file']['type'] != "image/jpg" && $_FILES['file']['type'] != "image/x-png" && $_FILES['file']['type'] != "image/png") { $query = "INSERT INTO newsitem (author,title,shortdesc,article,newsdate,status) VALUES ('$a','$t','$sn','$c',CURDATE(),'$st')"; } else { $finame = $_FILES["file"]["name"]; $result = move_uploaded_file($_FILES['file']['tmp_name'], "../news/$finame"); if ($result == 1) { $query = "INSERT INTO newsitem (author,title,shortdesc,article,newsdate,status) VALUES ('$a','$t','$sn','$c',CURDATE(),'$st','$finame')"; } else { $query = "INSERT INTO newsitem (author,title,shortdesc,article,newsdate,status) VALUES ('$a','$t','$sn','$c',CURDATE(),'$st')"; } } } $conn->close(); ?> I cannot for the life of me see what it wrong with it, When I run the debugger it cuts off at conn with the Call to undefined function mysqli_connect() error message. If anyone could help point me in the right direction that would be great
-
I'm currently working on a WordPress website project and I am hoping someone can help me out on this. In the registration page, the data entered is stored into the WordPress database. I've also build a connection to store those data into an external database as well. So basically, If a visitor registers on the site, their data info is stored in the WP and external DB. My question is since the external DB relies on checking to see if the submit button has been pressed, do those data input values need to be escaped to prevent sql injection into the external DB since the data submitted to WordPress has already been sql escaped? Thanks for helping.