Jump to content

Ch0cu3r

Staff Alumni
  • Posts

    3,404
  • Joined

  • Last visited

  • Days Won

    55

Everything posted by Ch0cu3r

  1. Have a look at this example http://jsfiddle.net/VuH6P/2/ For idea of the HTML markup and CSS required.
  2. How the text is displayed is down to CSS. With CSS you can apply various styles to a html element to transform it. All what you want PHP to do is to output the required HTML markup for creating the boxes with the info from the database. If you right click > view source you should be able to see the HTML mark-up for those boxes and then browse to see what CSS they are applying.
  3. By option do you mean the <select></select> menu's? Then hitmans solution is still right, except you want to to apply the option menus instead As demonstrated here http://jsfiddle.net/4fgW8/1/
  4. Have you changed my code? As I have tested it and it updates all records.
  5. Don't move anything from the PHP install folder. Instead add the install folder to the Windows PATH variable. Go to Control Panel > System and Security > System > Advanced System Settings > Environment Variables > Select PATH from System Variables and click Edit. Press the End Key and type in C:\PHP; Press Ok to all open windows and restart Windows. PHP should now be able search for libraries within in its own install folder. Just edit the php.ini and enable the required extensions you need to use. Make sure you restart Apache after modifiing the php.ini PHP5.3+ no longer comes with libmysql.dll it is built in to PHP. All you need to do is enable the mysql (or mysqi) extension(s).
  6. Let MySQL tell you how many users are online $resultcont = mysql_query("SELECT id, name FROM userdb WHERE status='online' ORDER BY id"); // get all users where status is online $usersOnline = mysql_num_rows($resultcont); // how many results where returned from the query // if there are users online if($usersOnline > 0) { echo "<p>There are $usersOnline:</p>"; // display how many users are online // then list the users while(list($id, $name) = mysql_fetch_row($resultcont)) { echo "<a href=http://www.sentuamessage.com/profile?who=$id>$name</a>"; } } // no users online else { echo "<p align=center>There Are No Users Currently Online</p>"; }
  7. You left off a quote before $phone_dist in the query $sql="INSERT INTO `distributors` (name_dist,address_dist,city_dist,state_dist,zip_dist,phone_dist,ffl_dist,dob_dist,dateAdded_dist) VALUES ('$name_dist','$address_dist','$city_dist','$state_dist','$zip_dist','$phone_dist','$ffl_dist','$dob_dist',now())"; ^ missing quote
  8. That error is coming from your web server. 404 errors usually means you have requested for a file but the server couldn't find it. When the form is submitted the file that is requested is called insertform.php. Do you have this file spelled correctly? and is it in the same path as the html form?
  9. The code you posted is fine. The issue might a few lines before 491
  10. You should be using $mysql2 variable here not $mysql $_SESSION['fname'] = $mysql['first_name']; $_SESSION['lname'] = $mysql['last_name']; $_SESSION['add1'] = $mysql['address_1']; $_SESSION['add2'] = $mysql['address_2']; $_SESSION['county'] = $mysql['county']; $_SESSION['postcode'] = $mysql['postcode']; $_SESSION['tel'] = $mysql['tel_no']; $_SESSION['mobile'] = $mysql['mobile_no']; $_SESSION['team'] = $mysql['team']; $_SESSION['ismanager'] = $mysql['is_manager']; $_SESSION['isadmin'] = $mysql['is_admin']; $_SESSION['sysadmin'] = $mysql['is_sysadmin'];
  11. And that is with selecting English or German before clicking the button? If so then for some reason when the form is submitted the post data is not being sent. So is there more code to this?
  12. It is code I gave you so I can see the what is in $_POST when the form is submitted.
  13. What is the output of printf('<pre>%s</pre>', print_r($_POST, true)); When selecting a language and then submitting the form?
  14. It Displays the correct language based on the selection I make, and nothing if I didn't chose a language.
  15. Remove intval(). This converts a value into integer. The if/elseif is comparing strings not integers. The comparison should only be performed if $_POST['lang'] exists. if(isset($_POST['lang'])) { $myRadio = $_POST['lang']; if ($myRadio == "English") { print"<h1>English</h1>"; } elseif ($myRadio == "German") { print"<h1>German</h1>"; } }
  16. So you are listings all the departments the user belongs to? And want the Department and Descritions to be aligned? Then try echo "<table border='1'> <tr> <td width='90'><font size='2pt'>TeamName</td> <td ALIGN='left'><font size='2pt'>UserID</td> <td><font size='2pt'>Departments</td> <td><font size='2pt'>Description</td> <td><a href='csv.php'>Save to CSV file</a></td> </tr>"; $row = sqlsrv_fetch_array($stmt); // get first result echo "<tr> <td>$TeamName</td> <td>$UserID</td> <td>".$row['Department']."</td> <td>".$row['Description']."</td> <td></td> </tr>"; // if there is more than one result then list the remaining Department and Descriptions rows if(sqlsrv_num_rows( $stmt ) > 1 ) { while($row = sqlsrv_fetch_array($stmt)) { echo " <tr> <td colspan='2'></td> <td>".$row['Department']."</td> <td>".$row['Description']."</td> <td></td> </tr>"; } }
  17. Your PHP code echo's a html table which first outputs 1 row with 5 columns. Then a new row with three columns, which in the third column you are outputting a table of results. I think your code should be echo "<table border='1'> <tr> <td width='90'><font size='2pt'>TeamName</td> <td ALIGN='left'><font size='2pt'>UserID</td> <td><font size='2pt'>Departments</td> <td><font size='2pt'>Description</td> <td><a href='csv.php'>Save to CSV file</a></td> </tr>"; while($row = sqlsrv_fetch_array($stmt)) { echo " <tr> <td>".$row['TeamName']."</td> <td>".$row['UserID']."</td> <td>".$row['Department']."</td> <td>".$row['Description']."</td> <td></td> </tr>"; } echo "</table>";
  18. Before coding the PHP create a static html webpage to the design of your website that you like, add dummy text such as loreum ipsum to fill out the page with fake content. When you are happy with the design then start replacing the dummy content with PHP code.
  19. If you are allowing for multiple records to be edited at the same time then name the fields the same but add square brackets to it so the form is submitted as an array. Then loop over the $_POST data and update the records individually. This is how I'd setup the edit form foreach ($arrValues as $row) { $id = $row['employee_id']; echo <<<FORM_FIELDS <tr> <td><input type="text" name="record[$id][firstName]" value="{$row['first_name']}" /></td> <td><input type="text" name="record[$id][lastName]" value="{$row['last_name']}" /></td> <td><input type="text" name="record[$id][height]" value="{$row['height']}" /></td> <td><input type="text" name="record[$id][cap]" value="{$row['cap']}" /></ d> <td><input type="text" name="record[$id][color]" value="{$row['colors']}" /></td> <td><input type="submit" name="update" value="Update" /></td> </tr> FORM_FIELDS; } I am setting up form to be handled as an array when it is submitted, This will cause $_POST['record'] to become a multidimensional array, the employee_id field is used as the key. Here is an example of how the $_POST will be constructed To update the records we'll loop over the $_POST['record'] array, updating each record individually. if(isset($_POST['update'])) { $updatedQuery = "UPDATE fac_detail SET first_name=:fname, last_name=:lname, height=:height, cap=:cap,colors=:color WHERE employee_id=:id"; $stmt = $dbh->prepare($updatedQuery); // loop over each record in $_POST['record'] // getting the employee_id and each fields value foreach($_POST['record'] as $employee_id => $field) { $stmt->bindParam(':fname', $field['firstName'], PDO::PARAM_STR); $stmt->bindParam(':lname', $field['lastName'], PDO::PARAM_STR); $stmt->bindParam(':height', $field['height'], PDO::PARAM_STR); $stmt->bindParam(':cap', $field['cap'], PDO::PARAM_STR); $stmt->bindParam(':color', $field['color'], PDO::PARAM_STR); $stmt->bindParam(':id', $employee_id, PDO::PARAM_INT); $stmt->execute(); } }
  20. Edit, double post Use urlencode on $source The use urldecode when you use $_GET['from']
  21. You are setting $id as a global variable within the databaseContainsUserid function. $GLOBALS['id'] = $row['id'];
  22. Wrap the html within CDATA sections. <?xml version="1.0" encoding="UTF-8"?> <your_card> <your_message> <![CDATA[ your html here ]]> </your_message> </your_card>
  23. Because you are running the insert query twice for the complaint table ($query2). This is will cause two entries. mysql_query($query2); $the_auto_id_that_was_just_created = mysql_insert_id(); if (mysql_query($query2)) { echo "<script>alert('Complaint Added Successful')</script>"; }
  24. Change implode(',', $_SESSION to end($_SESSION
  25. Separate your form into another file, then include it when you need it. Add your form code to a new file called update_form.php <div class="data"> <form method="POST" action="stdupdate-validation.php"> <?php echo $stdaddress; ?> <table class="update" border="1px" align="center"> <tr><td>Student Name</td><td><input type="text"value="<?php echo $stdname; ?>" name="stdname"></td></tr> <tr> <td> Roll No</td> <td><input type="text" value="<?php echo$stdrollno; ?>" name="stdrollno" > </td></tr> <tr> <td> Father Name</td> <td><input type="text" value="<?php echo$stdfname; ?>" name="stdfname"> </td></tr> <tr> <td>Class </td> <td> <select name="stdclass"> <option value="0">No Class</option> <?php // now we need list of all classes to display in dropdown $classes_result = mysql_query("select * from classes") or die(mysql_error()); // check if classes are available if(mysql_num_rows($classes_result)) { // because we may have more then one class in query result // so now we need LOOP while ($class = mysql_fetch_assoc($classes_result)) { // now we have to check the class ID in classes while loading the list into dropdown $selected = ($class_id == $class['id']) ? 'selected="selected" ' : ""; echo '<option value="'.$class['id'].'" '.$selected.' >'.$class['name'].'</option>'; } } ?> </select> </td> </tr> <tr> <td>Cell No</td> <td><input type="text" value="<?php echo$stdcell; ?>" name="stdcell"> </td></tr> <tr><td>Date OF Birth</td> <td> <input type="text" value="<?php echo$stddob; ?>" name="stddob"> </td></tr> <input type="hidden" value="<?php echo$class_id; ?>" name="class_id"> <tr><td>Address</td><td> <textarea cols="30" rows="6" value="<?php echo $stdaddress; ?>" name="stdaddress"> </textarea> </td></tr> <tr><td>Ammount Of Fee</td><td> <input type="text" value="<?php echo$stdfee; ?>" name="stdfee"> </td></tr> <tr> <td colspan="2" align="center"><input type="submit" value="submit" name="submit"></td></tr> <input type="hidden" value="<?php echo $id ; ?>" name="id"> </table> </form> Change the redirect here in update-validation.php header('location:std_update.php?'.$msg); to include 'update_form.php'; // include the update form Change std_update.php to <?php include('header.php'); include('config.php'); include('navigation.php'); // get only integer value from request $id = intval(@$_REQUEST['student_id']); // we are going to show only one student so we need to // restrict the query to find one record only $query="select *from students where id='$id' limit 1"; $result=mysql_query($query); // check if record not found then no need to open the page if (!$result) { // this check is implement, just because of we are on update page // if id is invalid it's mean no record or invalid record // in this case no need to stay on this page. header("Location: students.php"); exit(); // if header generate warning exit will stop page rendering. } // we have only one record we know, because we set the LIMIT 1 // so no need for while loop. While loop is use when records are more then one. // Here we have one only $data = mysql_fetch_assoc($result); $stdname = $data['stdname'] ; $stdrollno = $data['stdrollno'] ; $stdfname = $data['stdfname'] ; $stdclass = $data['stdclass'] ; $stdcell = $data['stdcell'] ; $stddob = $data['stddob'] ; $stdaddress = $data['stdaddress'] ; $stdfee = $data['stdfee'] ; $class_id = $data['class_id']; // here we have class_id include 'update_form.php'; // include the update form ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.