Menster 38 Junior Poster

Hi there,
What you need is a little javascript to make this work, the following is an example:

var value1 = document.getElementById('list1').options[document.getElementById('list1').options.selectedIndex].value;
var value2 = document.getElementById('list2').options[document.getElementById('list2').options.selectedIndex].value;
var value3 = value1 + '--' + value2 + '-';
document.getElementById('text_box).value = value3;

Just put this code between some script tags at the top of your page, correct the element ID's to match your html and call the function from your second "select" element's onchange attribute.

Menster 38 Junior Poster

Hi there,
Enclose the phrase post_text in single quotes, like this:

echo $rows['post_text'];

That should sort out your error :)

Menster 38 Junior Poster

In where i live in florida, rents are really cheap, i pay 464 dolars per month for a single bedroom apartment. move to usa man!

Dude, in South Africa, I share a 3 bedroom house with some people from work, rent per month is ZAR 5300 per month (for the entire house, not per person) , which is by todays exchange rate: USD 688.89. You can't just say it's cheap to live somewhere because the rent is cheaper, the costs of living vary greatly for various reasons all over the world.

Menster 38 Junior Poster

Hi there, in order to set the action of the form in response to a user selecting something from the drop down list, you will need to use javascript, try this :

$sql = "SELECT prodMFG FROM productDetail WHERE prodMFG != '' GROUP BY prodMFG"; // (1)
$result = mysql_query($sql);
echo "<form action='' id='myForm'method='POST'>"; // (2)
echo "<select name='category' onchange='setFormAction(this)'>"; // (3)
while($nt=mysql_fetch_array($result)) 
{
echo "<option value=$nt[prodMFG]>$nt[prodMFG]</option>";
}
echo "</select>";

And now the javascript to manage the onchange event:

<script>
function setFormAction(object)
{
//Get the selected value
    var get_param = object.options[object.oprions.selectedIndex].value;
var form = document.getElementById('myForm');
//set the form's attribute
form.action = 'search.html?var='+get_param+'';
}
</script>
Menster 38 Junior Poster

Hi there, you could use a regular for loop like this:

$max = ceil(count($Forms,$sharedForms);
for ($i = 0; $i < $max; $i++)
{
$outstring1.= " $(\"#shareform".$Forms[$i]['Form']['id']."\").hide();
         $(\".Share".$Forms[$i]['Form']['id']."\").click(function(){
         $(\"#shareform".$Forms[$i]['Form']['id']."\").toggle(\"show\");
    });";

$outstring2.= " $(\"#shareform".$sharedForms[$i]['Form']['id']."\").hide();
        $(\".Share".$sharedForms[$i]['Form']['id']."\").click(function(){
                $(\"#shareform".$sharedForms[$i]['Form']['id']."\").toggle(\"show\");
         });";
}

echo $outstring1;
echo $outstring2;
Menster 38 Junior Poster

Hi there, it can't be done solely with php, you need javascript to pull the actual resolution initially, but after that you can store it in a cookie and use php to access it
Put this script on your home page

<script language="javascript">
window.location.href = "resolution.php?width=" + screen.width + "&height=" + screen.height;
</script>

And put this script into a file called resolution.php

<?php
$width = $_get['width'];
$height = $_get['height'];

echo "You are using a $width x $height screen resolution";
// And set them into cookies as well.
//And then redirect to the page of the correct resolution
?>
Menster 38 Junior Poster

I think I know the anger of which you speak, I too get furious over trivial things especially people who don't understand why their e-mail isn't working when their mailbox is full, and many other similar examples of not only ignorance but complete lack of a will to learn (this becomes apparent the 4th or 5th time the same person calls in with the exact same problem)

Menster 38 Junior Poster

Hi there, I'm not sure if what you're asking for is possible. The way I understand it to work is if you take a page (index.html) and reload it, it also reloads all of it's child elements including the iframe and the page to which the iframe is linked.

A workaround for this would be putting your music player in the top-level page, and then making your users work inside an iframe in that page, because when the go to the next page from the iframe, only the iframe will reload and your top-level page will stay the same (ie keep on playing the song).

Menster 38 Junior Poster

Hi there, can you post your upload.php file so that we could take a look at it?

Menster 38 Junior Poster

Hi there,
The error that you are getting indicates that your query is either invalid or the result set that it returns is empty. Just double check that your SQL statement run correctly on your phpMyAdmin or other SQL command panel, and that there is data in the database.

Additionally,

echo $row = mysql_fetch_array($result);

Will always print "array()", since $row is always an array object.
Use the following instead:

$row = mysql_fetch_array($result);
echo "<pre>";
print_r($row);
echo "</pre>";
Menster 38 Junior Poster

Try it like this:

<?php
for ($i =0; $i < $ValuenumtableChildren; $i++)
{
      $str1 = substr($Valuechild[$i],0,7);
      $str2 = substr($Valuechild[$i],8);
      $final_str = $str1."<br/>".$str2;	
echo "<a href=\"view.php?name=$Valuechild[$i]\">$final_str</a>";
    }
?>
Menster 38 Junior Poster

Hi there,
I assume your code snippet is from the fruit.php file, if thats the case then it is quite simple to do what (I think) you need, in fact you have already given it yourself: basename($_SERVER) will give the url sent to the server minus all of the folder names preceding the srcipt name.

For example, if my url sent was "www.website.com/folder/file.php?param=value" then basename($_SERVER) will give me "file.php?param=value", or in your case "fruit.php?type=X".

Hope this helped

Menster 38 Junior Poster

Hi again,
To do that you would need to but a "<br/>" between Science and Matter. This is quite simple:

$str1 = substr($Valuechild[$i],0,7);
$str2 = substr($Valuechild[$i],8);
$final_str = $str1."<br/>".$str2;

However, it'll be a lot trickier when the lengths of your words vary.

Menster 38 Junior Poster

Hi there,
In an associative array the symbol '=>' indicates a key-value pair, ie:
'key' => 'value', this means that you can access an element of the array with it's named key like: $array will return the value of 'value'

Menster 38 Junior Poster

No worries, that's what forums are for. P.s. If this thread is done please mark it as solved.

Menster 38 Junior Poster

I would only advise that as a last resort, teachers don't really like to get told how it is. But if you've exhausted all other options and you are sure that nothing is being left out or accidentally added in, then go for it. I'm pretty sure she won't fail you for it. And if she does, at least she might tell you where you went wrong.

Menster 38 Junior Poster

I would recommend using XAMPP, however, it uses MySQL not MS SQL. Im not even sure if you can get apache and php to work with MS SQL (well, you probably can but I'll guarantee it's more effort than it is worth).

XAMPP is an all-in-one wunderkind php development kit. (without an IDE unfortunately)

Menster 38 Junior Poster

Heres what I meant (in code)

$grade = 0;
$grade_out_of = 0;
if ($_POST['Quiz1'] >= 0 && $_POST['Quiz1'] <= 100)
{
    $grade = $grade + $_POST['Quiz1'] * 0.05;
    $grade_out_of = $grade_out_of + 0.05;
}
if ($_POST['Mid-Term'] >= 0 && ($_POST['Mid-Term'] <= 100))
{
    $grade = $grade + $_POST['Mid-Term'] * 0.30;
    $grade_out_of = $grade_out_of + 0.30;
}
if ($_POST['Quiz2'] >= 0 && ($_POST['Quiz2'] <= 100))
{
    $grade = $grade + $_POST['Quiz2'] * 0.05;
    $grade_out_of = $grade_out_of + 0.05;
}
if ($_POST['AL1'] >= 0 && ($_POST['AL1'] <= 100))
{
    $grade = $grade + $_POST['AL1'] * 0.05;
    $grade_out_of = $grade_out_of + 0.05;
}
if ($_POST['AL2'] >= 0 && ($_POST['AL2'] <= 100))
{
    $grade = $grade + $_POST['AL2'] * 0.05;
    $grade_out_of = $grade_out_of + 0.05;
}
if ($_POST['Participation'] >= 0 && ($_POST['Participation'] <= 100))
{
    $grade = $grade + $_POST['Participation'] * 0.10;
    $grade_out_of = $grade_out_of + 0.10;
}
if ($_POST['Final'] >= 0 && ($_POST['Final'] <= 100))
{
    $grade = $grade + $_POST['Final'] * 0.40;
    $grade_out_of = $grade_out_of + 0.40;
}
//Now right here, your grade looks like something out of 100
//But is is really only out of: 100 * $grade_out_of
//Therefore, your final grade is:
$grade = floatval($grade / ($grade_out_of * 100));
Menster 38 Junior Poster

Hi there,
I would use the if/else approach originally suggested without adding the full mark for an uninitialised POST variable. Additionally keep track of how much each of the tests is supposed to count (eg If you would multiply a mark by 0.05 to form part of the final mark, increment a variable, at the same time you add that variable to the grade, by that 0.05 ) So that in the end, you have your Grade Mark out of 100 and your other (counter) variable which has the ratio of completed assignments to 1. Then you can take your Grade mark and work it out as a percentage relative to 100 * counter variable.

Sorry if that seems a little convoluted, i'll try knock together a code snippet to explain it better.

Menster 38 Junior Poster

Try changing "$row" to "$row[0]" and see if you still get nothing.

Menster 38 Junior Poster

If you are happy with the answer, please mark this thread as solved :)
Thanks

Menster 38 Junior Poster

I have never worked with Tomcat, so I'm not sure (Isn't it a JSP server). Their home page should be able to guide you on this.

Menster 38 Junior Poster

Exactly, php is an interpreted language unlike the others which you mention. i.e. The pages are parsed by apache when they are requested in order to generate the required content.

Menster 38 Junior Poster

Software to run php: XAMPP (if you are on a Windows based pc)
Sofware to write php: Netbeans PHP is free (as far as I can tell) but phpEd from nuSphere is way awesomer if you're willing to buy a license.
Best Place to Learn PHP: The basics at http://www.w3schools.com
The true knowledge at http://www.php.net

Hope this helps

Menster 38 Junior Poster

Smiling is over-rated. Especially if you are staring at a computer screen, what are you trying to do? Re-assure it? I got into programming so that I wouldn't have to deal with people and by extension of that be nice to them for no reason

Menster 38 Junior Poster

Well keeping track of the time remaining is a simple issue to solve:
Just keep a time remaining variable in your session, eg:

$time = time();
      $_SESSION['time_started'] = $time;
      $_SESSION['time_remaining'] = 2700; //45 minutes
$oldtime = $_SESSION['time_started'];
      $newtime = time();
      $difference = $newtime - $oldtime;
      $_SESSION['time_remaining'] = $_SESSION['time_remaining'] - $difference;
      if ($_SESSION['time_remaining'] > 0)
      { 
          $_SESSION['time_started'] = $newtime; 
         //continue
      } else {
         //out of time
      }
Menster 38 Junior Poster

Hi there
If you just want to keep track of how long a guy was on a page simply use the following, at the top of your php page:

$time = time();
$_SESSION['time_started'] = $time;

Which stores the time (as a UNIX timestamp) that the page was loaded into the clients session. To read it out and compare it
with the time the next page is loaded, use the following:

$oldtime = $_SESSION['time_started'];
$newtime = time();
$difference = $newtime - $oldtime;

Now the variable "$difference" contains the amount of time the client spent on the first page in seconds. Then you can do what you want with it.

However, if you want to display the timer as a clock ticking down you will need to use a client-side scripting language like Javascript.

Menster 38 Junior Poster

Swt, anytime

Menster 38 Junior Poster

Try this, it seems that the $result variable is set to NULL when you try and retrieve rows from it, if you are sure that your sql is correct, are you certain that you are connecting to your database correctly? I notice that you aren't passing a username or password to your mysql_connect() statement. But if that is also fine then try this:

$query = 'SELECT * FROM `security` LIMIT 0 , 30';
$result = mysql_query($query, $conn);
if (mysql_numrows($result) == 0)
{
echo "Result set is EMPTY";
} else if (!$result) {
echo "Result set is NULL";
} else {
echo "Result set is VALID";
$row = mysql_fetch_assoc($result);
$a = array_search($user, $row);
echo $a;
}

Apart from that, I'm pretty much out of ideas, hope this helps

Menster 38 Junior Poster

Hi there,
Have you tried running your sql statement straight through your SQL command interface (like phpMyAdmin). If that returns no errors, try adding some error catching as follows and check the results:

$query = 'SELECT * FROM `security` LIMIT 0 , 30';
$result = mysql_query($query, $conn);
if (mysql_numrows($result) > 0)
{
$row = mysql_fetch_assoc($result);
$a = array_search($user, $row);
echo $a;
} else {
echo "No rows returned";
}
Menster 38 Junior Poster

As far as I know its impossible, a query will always return a result set according to certain parameters passed. So all of your results must have something in common (or something they are commonly lacking).

If you really had to do it in one statement i would recommend using UNION, eg:

$sql = $sql1." UNION ".$sql2;

where $sql1 selects your "definite" records and $sql2 selects your random records.

Menster 38 Junior Poster

But, if you leave out the anchor tag the styles you've applied won't work... but i suppose you could just change them from a:hover etc.
to div:hover.

Menster 38 Junior Poster

Hi there, give this a go:

echo "<h2>Current Items and Quantities:</h2>\n";
      echo "<table width=\"100%\" cellpadding=\"1\" border=\"1\">\n"; 
	   $query = "SELECT description, quantity from products";
      $result = mysql_query($query);
   while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
 {
	    $description = $row['description'];
            $quantity = $row['quantity']; 
	    echo "<tr><td>$description</td><td>$quantity</td></tr>\n";
}		  
      echo "</table>\n";

This construct will loop through all the result sets return by the SQL and stop automatically after it has read the last one.

Good luck

Menster 38 Junior Poster

Hi there, have you tried:

<div id="blah" onclick="window.location = 'Your reference here'">
<a href="You can leave this blank">Your text here</a>
</div>
Menster 38 Junior Poster

Sure thing, try this:

<?php
for ($i =0; $i < $ValuenumtableChildren; $i++)
{
$value = htmlentities($Valuesibling[$i]);
echo "<a href=\"viewingdetails.php?name=".$value."\"</a>";
}
?>

htmlentities() takes special characters (like < > @ # $ % etc.) and changes them to their html escape codes, for example '<' is translated into '&lt;'. This will help the browser see that the space in your link's target doesn't terminate the tag.

Menster 38 Junior Poster

It could be the spaces, run the values thru the htmlentities() function
and try again, but i can't see any reason why that link wouldn't work as it is in your last post.

Menster 38 Junior Poster

Hi there, from the past couple of posts, you guys are on the right track, it just seems that no-one remembered to close the anchor tag properly, it should be like this:

#
<?php
#
for ($i =0; $i < $ValuenumtableChildren; $i++)
#
{
#
echo '<a href="viewingdetails.php?name='.$Valuechild[$i].'">LINK TEXT GOES HERE</a>';
#
}
#
?>
Menster 38 Junior Poster

Hi there,
The problem is that you are calling javascript from inside your php which is outside of it's name space. What you gotta do is in your php file : echo "<script>fcnX('home.php')</script>"; in the middle of your head section and the function will automatically be called when the page loads.

Menster 38 Junior Poster

Have you tried this: <script> this.close() </script>