Gideon_1 15 Junior Poster

Any idea of?

Gideon_1 15 Junior Poster

Eish sorry was an error.

Gideon_1 15 Junior Poster

I want to ask if you are passing only one specific value?

If YES

As ryantroop was saying your js function must accept a parameter or an argument.

Your PHP codes will be

while ($row = mysql_fetch_array($res)) {                       
    echo "<tr>".
    "<td> <p><button onClick=\"func({$row[0]})\" >View</button></p>  </td>" 
    ."</tr>";
}

Then in your JS

<script>
    function func(param = <?php echo json_encode($row[0]); ?>) {
         var jsvar = param;
        window.open("window.php"+jsvar,'Eployee Details','width=545,height=326,resizable=yes,scrollbars=yes,status=yes');
    }
</script>

Hope it went well

Gideon_1 15 Junior Poster

I totally agree with jkon, OOP is OOP in your style. But there are a few things you should also know which will help in your life of programming. This include errors you made in both PHP and HTML. (NOTE: reference XHTML, PHP5 and My Personal Interests).

  1. The inclusion of the class in the same file as other php and html codes does not encourage the idea of OOP. Usually create a file to contain only the Class or group of classes, then you include them on the page they will be needed. You can also use spl_autoload to load your classes without having to include them one by one.

  2. In your if statement, the codes should have been in parenthesis which shows that if the condition is correct run this specific codes.

  3. HTML attributes should have their values placed in double quotation marks. You did some right and left a massive number of them. I recommend you to do that if you want your projects to be of the W3C standards.

  4. You could have made your codes shorter and more readable by making the width and length arguments or parameters of the methods of the class. (Personal Preference).

  5. Indenting of codes is a good practice if you want to become an elite programmer. Always indent your codes to produce neat work.

  6. I don't know how you understand labels and their ids. The label id must be equal to the input field's id. (The field you want to address the …

Gideon_1 15 Junior Poster

I also agree on the ajax concept but let me throw light on this point.
You can change the input type="submit" to input type="button" and give the form no action and method.

So on the button you use the event handler, onClick then ajax.

If the data is sensitive then its advisable to make the asynchronous connection in a post form not a get.

Example
xml.http ('POST', 'your_form_file.php', true);

I hope it helped.

Gideon_1 15 Junior Poster

Yes, I agree with pritaes, when executing sql in phpmyadmin and when there is an error it shows the place where the error is occuring.

Example

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '13' at line 1
Gideon_1 15 Junior Poster

@ribrahim include the invoice->additem in the foreach or while loop

Gideon_1 15 Junior Poster

@ribrahim, your codes are correct is just that you must include the results in a foreach statement. So here goes the codes;

   while ( $rows = mysqli_fetch_assoc($result)){
                        $description = $rows['ChargesTitle'];
                        $quantity = $rows['itemqty'];
                        $Official = $rows['itemAmountO'];
                        $Professional = $rows['itemAmountP'];
                        $discountAmount = $rows['discountAmount'];
                        $discount = number_format($Professional, 2, '.', '') * $quantity *(($discountAmount)/100);
                        $itemAmount = number_format($Official, 2, '.', '') + number_format($Professional, 2, '.', '');
                        $lineTotal = ($itemAmount * $quantity) - ($discount);
}

Or

   foreach (mysqli_fetch_assoc($result) as $rows){
                        $description = $rows['ChargesTitle'];
                        $quantity = $rows['itemqty'];
                        $Official = $rows['itemAmountO'];
                        $Professional = $rows['itemAmountP'];
                        $discountAmount = $rows['discountAmount'];
                        $discount = number_format($Professional, 2, '.', '') * $quantity *(($discountAmount)/100);
                        $itemAmount = number_format($Official, 2, '.', '') + number_format($Professional, 2, '.', '');
                        $lineTotal = ($itemAmount * $quantity) - ($discount);
}
Gideon_1 15 Junior Poster

To send a mail with attachment, I will recommend the use of PHPMailer which is more simple and easier to configure than using the default mail function.

Gideon_1 15 Junior Poster

Can you show us the codes you have so far.

Gideon_1 15 Junior Poster

At the admin panel you can add pages; album, then individual pages for your respective albums. So on the main album page you insert images (cover pics for the respective albums) which are links to their respective pages.

So on the individual pages you insert all the photos belonging to that album. You can style this with css or add more advanced features with javascript such as lightbox.

Gideon_1 15 Junior Poster

Kind of wierd codes here. Can you please clearify your codes? We are always here to help but can't help if we don't understand what we are seeing.

Gideon_1 15 Junior Poster

Yh, also using WYSIWYG won't help you when it comes to maintaining your codes and debugging.

Gideon_1 15 Junior Poster

what took you so long to post this. You are great!

Gideon_1 15 Junior Poster

thanks man, i got to look at this

Gideon_1 15 Junior Poster

Awesome, your tutorials are very understandable.

Gideon_1 15 Junior Poster

Thumbs up, very very awesome, you just pin pointed my most hated thing in PHP, spaghetti codes.

Gideon_1 15 Junior Poster

Not all that understandable but thanks for your time.

Gideon_1 15 Junior Poster

Awesome, its really cool.

Gideon_1 15 Junior Poster

@hrushi9, if you want a simple album which onclick opens a page which contains all the photos in it, then you can create a new page from your admin panel. Maybe you will name it albums. Then choose cover pics for your different albums.

You then place the cover pics as links in the albums page which when click open different pages containing the album photos. But make sure each individual album cover pic is link to another page which will contain all the particular photos.

This seems a little complicated but its simple when understood.

Gideon_1 15 Junior Poster

Welcome, to the coolest place to interact with seasoned programmers. Daniweb.

Gideon_1 15 Junior Poster

Hmm, you are not asking for help though, but I think there are more than enough wordpress plugins to solve your photo album problem. You check WordPress Photo Gallery Plugins

Gideon_1 15 Junior Poster

Provided that your insert query is

"INSERT INTO `users` (`username`) VALUES ({$str})"

Make this just a literal by putting the variable $str into single quotation marks. So use

"INSERT INTO `users` (`username`) VALUES ('{$str}')"

I hope this solves your problem, or if not show your insert and select queries

Gideon_1 15 Junior Poster

Its my passion. I love to program for hours and burn candles at night for nothing but just pleasure. I love programming.

Gideon_1 15 Junior Poster

Hi, my name is Appoh Gideon an eighteen year old coder, mastering in HTML5, CSS3, SASS, JS, AJAX, PHP and MySQL. I didn't realise this earlier but I needed to introduce myself.

And I love daniweb.

Gideon_1 15 Junior Poster

First of all, why are you using two database connection layers in one script; mysql and mysqli. Please, I encorage you to use mysqli since mysql is deprecated.

Also I think you should be precise of the form method you are using so that you don't just use $_GET or $_POST.

But to your question, it seems you are updating the table against a field called req_code. I will advise you to update your database tables using primary keys (usually id's are used as primary keys in the database).

In your example, it can be possible that, that req_code is the same across all fields in the database. But for id's (primary key), it can never be the same.

So if you don't have an id or primary key field, you go ahead and create one and then update your rows where id = userid.

Gideon_1 15 Junior Poster

Yh I agree with todyITguy, learning it will be of great help but if you are in need seriously you can use these ajax codes;

        <script type="text/javascript">
            function load () {
                var xmlhttp = new XMLHttpRequest ();

                xmlhttp.onreadystatechange = function () {
                    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                        document.getElementById('ajax').innerHTML = xmlhttp.responseText;
                    }
                }

                xmlhttp.open ('GET', 'your_php_file.php', true);
                xmlhttp.send ();
            }
        </script>

Here, you can change the php file url to a get method by getting the values of the input fields you will use for the query. Here you will use something like

`'your_php_file.php?value1='.document.getElementById('input_field1_id').value.'&value2='.document.getElementById('input_field2_id').value`

So the onchange event will send the input fields asynchronously to the php file which will perform the query and send it back to the current page.

So don't forget to create an empty div with the id ajax or anything but i prefer using ajax.

so on the php file you get the values with the $_GET superglobal

so

    $value1 = $_GET['value1'];
    $value2 = $_GET['value2'];

and then you do your query. Everything you echo out or display will be displayed in the ajax div on the current page.

Gideon_1 15 Junior Poster

To clarify things when you were encrypting the password during registration, I hope you stored the salt which was added to the password during the encryption in the database.

Gideon_1 15 Junior Poster

Yh, but you must use ajax. Here you setup a new php file which will process the form and then ajax will make the asynchronous / background work for you.

Gideon_1 15 Junior Poster

yh, and assigning all these html to one variable is a really bad practise

tobyITguy commented: yeah true. +0
Gideon_1 15 Junior Poster

Paul-lucas, I don't know which framework or cms you are using, but I think the get results method only selects information from the database.

Reason
Updating the database only affects rows but does not output any results.

So kindly look into your framework's or cms' docs and get the method/function used for updating the database.

Gideon_1 15 Junior Poster

Yh, your php script that you want to get the months.

Gideon_1 15 Junior Poster

I don't get what you are trying to express. Your first script has no relation to the second one. Can you express yourself vividly?

Gideon_1 15 Junior Poster

Hello everyone, I have been using xampp for my web app developments for quite a while now. Usually after the app development is done, I upload my files to paid hosting.

Now, this is the case I'm designing a school's accounts managements software which will be used on an intranet. The school has no server or precisely production server.

My question is, can I use Xampp as the server on the intranet using virtual hosts, or if there is a better way, can you please outline it for me.

Regards,
Gideon.

Gideon_1 15 Junior Poster

Provided your menus open new php files or pages. You can use conditional statements and a class in css to produce te editing.

So if for example
Home opens index.php
Contact opens contact.php
About Us opens about.php

You first create a class let me say select in css

.selected {
    //and your styles go here
}

Then on the <li> tags you use the conditional statement and the $_SERVER['PHP_SELF'] superGlobal.

so on the li

<li <?php if ($_SERVER['PHP_SELF'] == '/index.php') { echo 'class="selected"'; } ?>>Home<a href="index.php"></li>
<li <?php if ($_SERVER['PHP_SELF'] == '/contact.php') { echo 'class="selected"'; } ?>>Contact<a href="contact.php"></li>
<li <?php if ($_SERVER['PHP_SELF'] == '/about.php') { echo 'class="selected"'; } ?>>About Us<a href="about.php"></li>
Gideon_1 15 Junior Poster

Yh, I will contribute to diafol's contribution. One thing you must keep in mind that storing music tracks directly in the database is a bad practice. This can slow down you server and make the SQL datables unnecessary large in terms of file size.

Gideon_1 15 Junior Poster

Since you are using a plugin, it has predefined functions upon which your application is built.

  1. Your database structure is correct to achieve this results.

  2. Why your results are not being displayed, I can't actually tell, because I don't know if the leftjoin and process methods used by your plugin are defined to output your information.

  3. Since this is a plugin you can read more about it on its forum or website. But if I can help in actual php codes This will be something like you select the fields you want to display from the two tables but make sure you use their, let me say compound name.

Example
table1.name, table1.contact, table2.service

FROM the first table or second (which depends on the main table you have)
LEFT JOIN the second or let me say slave table.
ON "here you provide you condition"

Example
saying table2's customer id is equal to table1's id.

table2.customerid = table1.id

Hope you understand everything.

Gideon_1 15 Junior Poster

@stephano, try echoing out the $phone value and see if there is an output. If yes, then in the database check the datatype of the phone column. And the coulumn name if it matches the exact one provided in the sql query

Gideon_1 15 Junior Poster

Proposed your users click on a button to make a payment, you can add an event handler to that button such as onsubmit or onmousemove which will load the function without the users consent.

Gideon_1 15 Junior Poster

Please first of all mysql database connection layer is deprecated, so try to use mysqli or PDO for database connections.

And, I don't actually get what you are trying to say. Can you please ellaborate your question further.

Gideon_1 15 Junior Poster

I don't know exactly what you are looking for, but i think jsPDF will help. Check this

http://stackoverflow.com/questions/17293135/download-a-div-in-a-html-page-as-pdf-using-javascript

Gideon_1 15 Junior Poster

@Stephano: not working in what sense. Is the form still submitting only three fields or not working at all.

Stephano commented: yes it is still submitting 3. iam realy not sure why at this point. +0
Gideon_1 15 Junior Poster

in the $SQL you just gave only four fields to be INSERTED so its either

  1. You delete the NULL from the VALUES so

    $SQL = "INSERT INTO safaris8_wo5946.wp_vkfj_users (user_login, user_pass, user_email, user_phone)
    VALUES ('$username', '$password', '$email','$phone')"

  2. Or you add the id field to the fiedls to be updated so

    $SQL = "INSERT INTO safaris8_wo5946.wp_vkfj_users (id, user_login, user_pass, user_email, user_phone)
    VALUES ('$username', '$password', '$email','$phone')"

Stephano commented: not working, still. i replaced this with what i had but still not working. this form is in a wordpress website. +0
Gideon_1 15 Junior Poster

In my applications I use the real ajax language i.e. new XMLHttpRequest () with the xmlhttp.onreadystatechange.

so in the the xmlhttp.send () I send the necessary parameters for the database queries to a php file through get. Example;

<script type="text/javascript">
    function load () {
        var xmlhttp = new XMLHttpRequest ();

        xmlhttp.onreadystatechange = function () {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                document.getElementById('ajax').innerHTML = xmlhttp.responseText;
            }
        }

        xmlhttp.open ('GET', 'ajax/debtors.php?id='+document.getElementById('id').value+'&table='+document.getElementById('year').value, true);
        xmlhttp.send ();
    }
</script>

so in the php file you grab the necessary values and the process the query. Don't forget to output the query results in the php file.

Also on the active page don't forget to add a div with id with which the ajax results will be displayed.

Gideon_1 15 Junior Poster

I will use ajax and php with to asynchronously to display the username if there is a match in my database

Gideon_1 15 Junior Poster

Then Fetching is your friend

Gideon_1 15 Junior Poster

Naa, you must output it, with echo in PHP, document.write in Js

Gideon_1 15 Junior Poster

To autoload classes, the standard php library which is already built in php can do this in just three lines.

You have to place it in your core.inc.php or any php file that you will always include in your pages. And after this you will not touch the code anymore. It codes like:

spl_autoload_register (
    function ($class) {
        require_once 'classes/'.$class.'.php';
    }
);

That is all, you dont need to place any class name of anything into the function

But Note:
That the class name must correspond to the class created. Maybe the class file is stored as DB.php, the class in DB.php must be class DB {}

Gideon_1 15 Junior Poster

To do this, you cannot use just one form to do this. Maybe you can set up input buttons and on event such as onclick AJAX process the sql you wanna deal with.

But I think if you do something very similar to login and register then sessions will be of great help

Gideon_1 15 Junior Poster

I think fetchAll() is better since you get everything your sql returns in a single dump. Catch ya.