Search the Community
Showing results for tags '#php'.
-
Hi everyone! I'm new here. I have a problem. I created an application with PHP, MySQL and now i want to link that application with facebook and all users that will use my application, their data have to go into my database. Please can someone tell me step by step what i should do because i never did this before. Sorry if this question isn't for this forum or for this part of forum.
-
Hey! I'm fetching data frmo my database and displaying it in a table. Now I want to be able to display that data but sorted in different ways. Right now it's sorted by id ASC. I want to make the <th> links, so when i press one of them, the page will sort the data in that way. How can I make this without writing a lot of new querys? I want to use the one query i already have made. Here is my code: <?php if(isset($_GET['hpid'])) { $hpid = (int)$_GET['hpid']; $test = mysql_query("SELECT * FROM `project`, `users`, `projectStatus` WHERE `projectHuvudId` = $hpid AND project.projectCreatorId = users.user_Id AND project.projectStatusId = projectStatus.statusId"); $test2 = mysql_query("SELECT p.projektName , p.projectId , s1.statusName , u1.username as creatorName , u2.username as ansvarig , p.projectDescription , p.projectCreateDate , p.projectStartDate , p.projectEndDate FROM project p INNER JOIN users u1 ON p.projectCreatorId = u1.user_Id INNER JOIN users u2 ON p.projectAnsvarig = u2.user_Id INNER JOIN projectStatus s1 ON p.projectStatusId = s1.statusId WHERE `projectHuvudId` = $hpid ORDER BY p.projectId ASC"); ?> <table class="display"> <th>ID</th> <th>Skapat</th> <th>Namn</th> <th>Start</th> <th>Slut</th> <th>Skapare</th> <th>Ansvarig</th> <th>Status</th> <?php while($row = mysql_fetch_assoc($test2)) { ?> <tr> <td><?php echo "<a href='project.php?pid=" . $row['projectId'] . "'>" . $row['projectId'] . "</a>"; ?></td> <td><?php echo $row['projectCreateDate'] ?></td> <td><?php echo $row['projektName'] ?></td> <td><?php echo $row['projectStartDate'] ?></td> <td><?php echo $row['projectEndDate'] ?></td> <td><?php echo $row['creatorName'] ?></td> <td><?php echo $row['ansvarig'] ?></td> <td><?php echo $row['statusName'] ?></td> </tr> <?php } ?> </table><?php } ?>
-
Hey! Im trying to do a chained select dropdown. 1 dropdown decides what should be shown in the second one...i think you all are familiar with this. Anyway..im following this guide: http://www.yourinspirationweb.com/en/how-to-create-chained-select-with-php-and-jquery/ But something is wrong, i cant get it to work properly. My first dropdown is populating correct, but the second one is not working. If i choose something in the first dropdown, the second one just stops at "wait...". I think the problem is somewhere in add_project.php, but im not sure. Here is my code: add_project.php: <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.1.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("select#category").change(function(){ var id = $("select#category option:selected").attr('value'); $.post("select_type.php", {id:id}, function(data){ $("select#type").html(data); }); }); }); </script> <?php include "select.class.php"; ?> <form id="select_form"> Choose a category:<br /> <select id="category"> <?php echo $opt->ShowCategory(); ?> </select> <br /><br /> choose a type:<br /> <select id="type"> <option value="0">choose...</option> </select> <br /><br /> <input type="submit" value="confirm" /> </form> <div id="result"></div> select.class.php: <?php class SelectList { public function ShowCategory() { $sql = mysql_query("SELECT * FROM `projectCategory`"); // $res = mysql_query($sql,$this->conn); $category = '<option value="0">choose...</option>'; while($row = mysql_fetch_array($sql)) { $category .= '<option value="' . $row['categoryId'] . '">' . $row['categoryName'] . '</option>'; } return $category; } public function ShowType() { $query = mysql_query("SELECT huvudProjectId, huvudProjectName FROM `huvudProject` WHERE `categoryProject` = categoryId=$_POST[id]"); $type = '<option value="0">choose...</option>'; while($row = mysql_fetch_array($query)) { $type .= '<option value="' . $row['huvudProjectId'] . '">' . $row['huvudProjectName'] . '</option>'; } return $type; } } $opt = new SelectList(); ?> select_type.php: <?php include "select.class.php"; echo $opt->ShowType(); ?> Hope someone can help me with this! I've tried SO many hours but I cant find the problem.
-
the issue is, i was trying to use a manual database connection. i design a form and i create a new file for the php/mysql codding. when i run the form using(dreamweaver and dispaly it in chrome)and fill in every fields and click button submit it will display the php/mysql codding the same way i coded it. how can i resolve that.
-
Hey guys i have got some PHP Code that i use its for an order page. When i place an order on my form it gets the Customer Information. But when i try to put an order in for the checkbox items it only gets the 1st item that is clicked in the checkbox and does not get the quantity. Is there anything that i am doing wrong in my code? form action="localhost" method="post"> <tr> <th>Shirts</th> <th>Quantity</th> </tr> <tr> <td> <br /> <input type="checkbox" name="items" value="SH01" /><label for="rd1">Obey T-Shirt: $9.99</label></div> <br /> <input type="checkbox" name="items" value="SH02" /><label for="rd1">Obey Professor: $9.99</label></div> <br /> <input type="checkbox" name="items" value="SH03" /><label for="rd1">Hustle T-Shirt: $9.99</label></div> <br /> <input type="checkbox" name="items" value="SH04" /><label for="rd1">Hip-Hop Support: $9.99</label></div> <br /> <input type="checkbox" name="items" value="SH05" /><label for="rd1">90's Shirt: $9.99</label></div> <br /> <input type="checkbox" name="items" value="SH06" /><label for="rd1">DOPE Shirt: $9.99</label></div> <br /> <br /> </td> <td> <br /> <input type="text" name="qty[SH01]" size ="2"/><br/> <input type="text" name="qty[SH02]" size="2"/><br/> <input type="text" name="qty[SH03]" size="2"/><br/> <input type="text" name="qty[SH04]" size="2"/><br/> <input type="text" name="qty[SH05]" size="2"/><br/> <input type="text" name="qty[SH06]" size="2"/><br/> <br /> </td> </tr> <tr> <td> <br /> <input type="checkbox" name="items" value="SO1" /><label for="rd1">Shoe - Red Lace: $19.99</label></div><br /> <input type="checkbox" name="items" value="SO2" /><label for="rd1">Shoe - Red High Top: $19.99</label></div><br /> <input type="checkbox" name="items" value="SO3" /><label for="rd1">Shoe - White: $19.99</label></div><br /> <input type="checkbox" name="items" value="SO4" /><label for="rd1">Shoe - Black: $19.99</label></div><br /> <input type="checkbox" name="items" value="SO5" /><label for="rd1">Shoe - Black High Top: $19.99</label></div><br /> <input type="checkbox" name="items" value="SO6" /> <label for="rd1">Red Basketball: $19.99</label></div><br /> <br /> </td> <td> <br /> <input type="text" name="qty[SO1]" size ="2"/><br/> <input type="text" name="qty[SO2]" size="2"/><br/> <input type="text" name="qty[SO3]" size="2"/><br/> <input type="text" name="qty[SO4]" size="2"/><br/> <input type="text" name="qty[SO5]" size="2"/><br/> <input type="text" name="qty[SO6]" size="2"/><br/> <br /> </td> </tr> <tr> <td> <br /> <input type="checkbox" name="items" value="SN1" /> <label for="rd1">Snapback Bullets: $29.99</label></div><br /> <input type="checkbox" name="items" value="SN2" /><label for="rd1">Snapback Grey: $29.99</label></div><br /> <input type="checkbox" name="items" value="SN3" /><label for="rd1">Snapback Bulls: $29.99</label></div><br /> <input type="checkbox" name="items" value="SN4" /><label for="rd1">Snapback Miami: $29.99</label></div><br /> <input type="checkbox" name="items" value="SN5" /><label for="rd1">Snapback Nets: $29.99</label></div><br /> <input type="checkbox" name="items" value="SN6" /><label for="rd1">Snapback Obey: $29.99</label></div><br /> <br /> </td> <td> <br /> <input type="text" name="qty[SN1]" size ="2"/><br/> <input type="text" name="qty[SN2]" size="2"/><br/> <input type="text" name="qty[SN3]" size="2"/><br/> <input type="text" name="qty[SN4]" size="2"/><br/> <input type="text" name="qty[SN5]" size="2"/><br/> <input type="text" name="qty[SN6]" size="2"/><br/> <br /> </td> </tr> </tr> </table> <br /> <h3 class="c4">Please Enter Customer Details</h3> <p class="normal"> <label><input type = "text" name = "custName" />Name (last name, first name, middle initial)</label><br /> <label><input type = "text" name = "phone" />Phone number (ddd-ddd-dddd)</label><br /> <label><input type = "text" name = "custEmail" />Insert E-Mail Address<br /></label> </p> <script type="text/javascript" src="validatorr.js"></script> <input type="submit" name="submit"> </form> <?php if (isset($_POST['submit'])) { $con = mysql_connect('localhost','username','password'); if (!$con) { die("Could Not Connect: " . mysql_error()); } mysql_select_db("$$", $con); $sql = "INSERT INTO Order_Information(Order_ID,Order_Items,Order_Quantity) VALUES (null,'$_POST[items]','$_POST[qty]')"; mysql_query($sql,$con); $sql = "INSERT INTO Customer_Information(Cust_ID,Cust_Name,Cust_Phone,Cust_Email) VALUES (null, '$_POST[custName]','$_POST[phone]','$_POST[custEmail]')"; mysql_query($sql,$con); mysql_close($con); } ?>