Jump to content

sasa

Staff Alumni
  • Posts

    2,804
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by sasa

  1. In line 9 in word doesn't -> ' means end of string. Look, color is not red after.
    Try[code]<?php
    $pages = array(
      'main'  => '
        include "../inc/config.php";
    $query = "SELECT * FROM `thumbs` ORDER BY id DESC";
    $result = mysql_query( $query );

    if ( !$result ) {
      // replace this with your own error code -- one that does not display the query
      die($query."<br />".mysql_error());
    }

    echo "<table border=\"0\" width=\"100%\" id=\"table1\"><tr>";
                   
    // Build Table
    while( $row = mysql_fetch_assoc( $result ) ) {


    $i++;

      echo "<h2><td width=\"33%\" valign=\"top\" height=\"65\">";
      echo "<a href=\"?p=\"" . $row["tid"] ."\"><img border=\"0\" src=\"images/thumbs/" . $row["tid"] .".jpg\"></img><br /></a>Title: <a href=\"?p=\"" . $row["tid"] . "\">".$row["title"]."</a><br />Published: ".$row["published"];
      echo "</td>";
     
      if ( $i == 2 ) {
    echo "</tr><tr>";
    $i = NULL;
    }
    }

    echo "</tr></table>";  // main page

    if (isset($_GET["p"]) && isset($pages[$_GET["p"]]))
                  {
                        include($pages[$_GET["p"]]);
    // Include Main Page
                      } else if(($p == "main") or ($p =="")) {
                            include($pages["main"]);

    } else { include($pages["error"]);}'
    );
    ?>[/code]
  2. You can add some binary representation of tools
    tool1 - 1
    tool2 - 2
    tool3 - 4
    ...
    tooln - 2^(n-1)
    try[code]<?php
    echo "<form  method=\"POST\" action=\"\">";
    if ($_POST['submit']) $a=array_sum($_POST['tool']);
    for ($i=1;$i<7;$i++) {
    $b=pow(2,$i-1);
    $c= ($a & $b) ? "checked=\"checked\"" :"";
    echo "<input type=\"checkbox\" name=\"tool[]\" value=\"$b\" $c>tool$i</input><br />\n";
    }
    echo "<input type=\"submit\" name=\"submit\"></form>";

    if ($_POST['submit']) {
    $a=array_sum($_POST['tool']);
    echo "<hr />Put in database number $a.<hr />
    When you read this number :<br />";
    for ($i=1;$i<7;$i++){
    $b= pow(2,$i-1);
    $c= ($a & $b) ? true : false;
    echo "tool$i - $c <br />\n";
    }
    }
    ?>[/code]
  3. [!--quoteo(post=370741:date=May 3 2006, 01:11 AM:name=ichversuchte)--][div class=\'quotetop\']QUOTE(ichversuchte @ May 3 2006, 01:11 AM) [snapback]370741[/snapback][/div][div class=\'quotemain\'][!--quotec--]
    When i used that code, it did the same thing. only filled one combobox....
    [/quote]
    I edit previous post
  4. try[code]<?php
    include_once('Scripts/conn/cid.php');

    $sql = "SELECT ra_name FROM staff_elkin";

    $result = mysql_query($sql)
              or die('Query failed. ' . mysql_error());

    if (mysql_num_rows($result) > 0)
    {
        echo '<select name="raname" id="raname">';
    while ($row = mysql_fetch_array($result))
        {    
        $title = $row['ra_name'];
        echo("<option value='$title'>$title</option>");
        }

        echo '</select>';

        
    }

        include_once('Scripts/close/end.php');
    ?>[/code]
  5. [!--quoteo(post=370721:date=May 3 2006, 12:49 AM:name=ichversuchte)--][div class=\'quotetop\']QUOTE(ichversuchte @ May 3 2006, 12:49 AM) [snapback]370721[/snapback][/div][div class=\'quotemain\'][!--quotec--]
    Ok...i changed that and it filled the combo box, but it create a combobox for everyname. It didn't put them all in one and that is what i wanted?

    i appreciate your help...
    [/quote]
    move line [code]<select name="raname" id="raname">[/code]before and line[code]</select>[/code]after while loop
  6. [!--quoteo(post=370708:date=May 2 2006, 11:39 PM:name=ichversuchte)--][div class=\'quotetop\']QUOTE(ichversuchte @ May 2 2006, 11:39 PM) [snapback]370708[/snapback][/div][div class=\'quotemain\'][!--quotec--]
    This fixed the problem with showing output, I can now see combo box but its printing out two of them with nothing in them.
    I have the page here - [a href=\"http://ohrl.forthestudentsbookstore.com/Elkin/upload.php\" target=\"_blank\"]http://ohrl.forthestudentsbookstore.com/Elkin/upload.php[/a]

    I wrote this sql state to make sure there is something there...which you can there is something there

    here the code revised....half of it is the test query
    [code]
    <?php
    include_once('Scripts/conn/cid.php');

    $sql = "SELECT ra_name FROM staff_elkin";

    $result = mysql_query($sql)
              or die('Query failed. ' . mysql_error());

    if (mysql_num_rows($result) > 0)
    {
        while ($row = mysql_fetch_array($result))
        {        
        $title = $row['title'];
        ?>
        <select name="raname" id="raname">
        <?php echo("<option value='$title'>$title</option>"); ?>
        </select>
        <?php
        }
    }

        include_once('Scripts/close/end.php');
    ?>
    //THIS IS THE QUERY CODE TO TEST THE DATABASE
    <?php
    include_once('Scripts/conn/conn.php');


    $rowsPerPage = 300;

    $pageNum = 1;

    if(isset($_GET['page']))
    {
    $pageNum = $_GET['page'];
    }

    $offset = ($pageNum - 1) * $rowsPerPage;

    $query = "SELECT ra_name FROM staff_elkin";
    $result = mysql_query($query) or die('Error, query failed');
    echo '<table border="0">';
    while(list($raname) = mysql_fetch_array($result))
    {
    echo "<tr><td>$raname <em>made the request:</em></td></tr>";
    }

    echo '</table>';
    echo '<br>';
    include_once('Scripts/close/end.php');
    ?>

    [/code]
    [/quote]
    in your sql you select column 'ra_name' and in line [code]$title = $row['title'];[/code]you look in column 'title'. Take look at this.
  7. change lines
    [code]
    $num = count($dp);
    ...
    $q = "INSERT INTO driverPoints (rp_race, rp_driver, rp_points) VALUES ('$rp_race', '$rp_driver', '$rp_points')";[/code]
    to
    [code]
    $num = count($rp_driver);
    ...
    $q = "INSERT INTO driverPoints (rp_race, rp_driver, rp_points) VALUES ('$rp_race', '$dp_driver', '$dp_points')";[/code]
  8. [!--quoteo(post=370590:date=May 2 2006, 05:44 PM:name=BoofBoof)--][div class=\'quotetop\']QUOTE(BoofBoof @ May 2 2006, 05:44 PM) [snapback]370590[/snapback][/div][div class=\'quotemain\'][!--quotec--]
    Alright, that is very true, I changed that so that it would connect and echoed it out to make sure it was connecting, but I still get no results back, let alone the basic table headers that I know works on other scripts. Any other suggestions??
    [/quote]
    line[code]while(list($val) = mysql_fetch_array($result))[/code]must be[code]while($row = mysql_fetch_array($result))[/code]
  9. [!--quoteo(post=366729:date=Apr 20 2006, 10:05 AM:name=Xeon-YK)--][div class=\'quotetop\']QUOTE(Xeon-YK @ Apr 20 2006, 10:05 AM) [snapback]366729[/snapback][/div][div class=\'quotemain\'][!--quotec--]
    i have 2 php file, tes and tes2.

    tes :

    <form name="form1" method="post" action="tes2.php">

    <?

    if( !isset($msg))
    {
    echo "tes";
    }
    else
    echo "tes1";

    ?>

    <input type="text" name="textfield">
    <input type="submit" name="Submit" value="Submit">
    </form>
    <?

    ?>

    tes2 :

    <?
    header( "location: tes.php?msg=1" ) ;
    ?>

    when i click on submit button, it will go to tes2.php and tes2.php will redirect back to tes.php and set msg=1
    but when i try in my computer $msg always zero. why???
    i try this in two computer, first computer work and second computer didn't work.
    may be i must setting php.ini file, but i don't know to set it???

    how can i solve this problem... thank....
    [/quote]
    change line[code]if( !isset($msg))[/code]to[code]if( !isset($_GET['msg']))[/code]
  10. [!--quoteo(post=366722:date=Apr 20 2006, 08:39 AM:name=twome)--][div class=\'quotetop\']QUOTE(twome @ Apr 20 2006, 08:39 AM) [snapback]366722[/snapback][/div][div class=\'quotemain\'][!--quotec--]
    I have a huge FORM with mostly checkboxes. How can I get the number (count) of checkboxes per group. I'm guessing I would have to using something like count($_POST).

    So how can I determine the number of checkboxes in the group "TypeN" and then for the group "relationN", etc.

    For example:
    <input name="Type1" type="checkbox" id="Type1" value="checked" />
    <input name="Type2" type="checkbox" id="Type2" value="checked" />
    <input name="Type3" type="checkbox" id="Type3" value="checked" />
    <input name="Type4" type="checkbox" id="Type4" value="checked" />

    <input name="relation1" type="checkbox" id="relation1" value="checked" />
    <input name="relation2" type="checkbox" id="relation2" value="checked" />
    <input name="relation3" type="checkbox" id="relation3" value="checked" />
    <input name="relation4" type="checkbox" id="relation4" value="checked" />
    <input name="relation5" type="checkbox" id="relation5" value="checked" />
    [/quote]
    try[code]<form action="" method="POST">
    Type <br />
    <input name="Type[]" type="checkbox" id="Type1" value="1" />
    <input name="Type[]" type="checkbox" id="Type2" value="2" />
    <input name="Type[]" type="checkbox" id="Type3" value="3" />
    <input name="Type[]" type="checkbox" id="Type4" value="4" />
    <br />relation<br />
    <input name="relation[]" type="checkbox" id="relation1" value="1" />
    <input name="relation[]" type="checkbox" id="relation2" value="2" />
    <input name="relation[]" type="checkbox" id="relation3" value="3" />
    <input name="relation[]" type="checkbox" id="relation4" value="4" />
    <input name="relation[]" type="checkbox" id="relation5" value="5" />
    <br />
    <input type="submit" name="submit">
    </form>

    <?php
    if (isset($_POST['submit'])){
        echo "<pre>";
        print_r($_POST);
        echo "</pre>";
        $t = isset($_POST['Type']) ? count($_POST['Type']) : 0;
        $r = isset($_POST['relation']) ? count($_POST['relation']) : 0;
        echo "User select $t Type ";
            if ($t>0){
            echo "(";
            foreach ($_POST['Type'] as $a) echo "Type$a ";
            echo ") ";
        }
        echo "and $r relation checkbox.";
        if ($r>0){
            echo"(";
            foreach ($_POST['relation'] as $a) echo "relation$a ";
            echo ") ";
        }
        
    }
    ?>[/code]
  11. [!--quoteo(post=362844:date=Apr 8 2006, 09:28 PM:name=Gingechilla)--][div class=\'quotetop\']QUOTE(Gingechilla @ Apr 8 2006, 09:28 PM) [snapback]362844[/snapback][/div][div class=\'quotemain\'][!--quotec--]
    I am trying to get something like this to work:

    [code]    $sql = "DELETE FROM youritems WHERE User = 0 OR User = 4";
        $sql2 = "DELETE FROM userinfo WHERE ID = 0 OR 4";
        $result = mysql_query($sql);
        $result = mysql_query($sql2);
        echo "Accounts Reseted!";[/code]

    I want to delete accounts who have not been active for more than 200 days (via a strtotime), I put the above together to see if I could delete records with either the values in, however when the script is runs it deletes all of the records in the database, does anyone know how I can fix this?
    (I put 0 and 4 as a test, I hope to later replace it with a variable e.g. $userstodelete, and $userstodelete will push in some search results)
    [/quote]
    the logical expresion [code]ID = 0 OR 4[/code]is always true. It's same with exspresion [code](ID = 0) OR TRUE[/code]use[code]ID = 0 OR ID = 4[/code]or[code]ID in (1,4)[/code]
  12. [!--quoteo(post=356577:date=Mar 20 2006, 05:36 AM:name=nawtwrong)--][div class=\'quotetop\']QUOTE(nawtwrong @ Mar 20 2006, 05:36 AM) [snapback]356577[/snapback][/div][div class=\'quotemain\'][!--quotec--]
    I've got the code working how I need it to, but there's just one problem:

    "Fatal error: Cannot redeclare my_round_down()"

    I'm excecuting this code using [code]include("../code.php");[/code] inside a while loop which is what's causing the error. However, I've tried using require_once, this clears the error message, but causes the function to do the same thing to [i]all[/i] the values that need rounding in the while loop.

    Is there a way round this? The my_round_down() function (exactly as above) needs to run for each number in a while loop and round each number individually.

    Thanks
    [/quote]
    move declaration of function(s) oueside loop. something like this[code]//start of file
    include('../code.php');

    // some code

    $pre=Array(1000,2000 and so on); // if this array is constant you can defined it in code.php

    my_round_down(1234,$pre); // use this where you want, in or out the loop

    [/code]
  13. [!--quoteo(post=356334:date=Mar 19 2006, 05:22 AM:name=nawtwrong)--][div class=\'quotetop\']QUOTE(nawtwrong @ Mar 19 2006, 05:22 AM) [snapback]356334[/snapback][/div][div class=\'quotemain\'][!--quotec--]
    I have a list of pre determined numbers set as variables, I need a way of rounding these numbers to the nearest high or lower match in that list, to a number that a visitor will type in:

    For example there will be a form with an input box for a number that the user types in. This will be submitted to a script where each of the pre-determined numbers in the list mentioned above will be stored as variables:

    $number_1 = 1000 $number_2 = 2000 $number_3 = 3000 $number_4 = 4000 $number_5 = 10,000 etc

    The user might type in a number like 2921, so the script would need to round this [b]up[/b] to 3000 ($number_3) the next highest in the list above.

    I also want another script that would round the number [b]down[/b] so 9999 would be rounded down to 4000 ($number_4) the next lowest in the list above.

    Is there a nice, simple way of doing this? I was thinking the numbers for the list could be stored in an array and maybe I could use the round() function, but I've no idea where to start.

    Any advive or suggestions greatly appreciated.
    [/quote]
    something like this[code]<?php
    function my_round($n,$a) {
        sort($a);
        $out=$a[0];
        $p=abs($n-$out);
        for ($i=1;$i<count($a);$i++) {
            if (abs($a[$i]-$n)<=$p) {
                $out=$a[$i];
                $p=abs($n-$out);
            }
        }
        return $out;
    }

    function my_round_down($n,$a){
        sort($a);
        $out=$a[0];
        for ($i=0;$i<count($a);$i++) {
            if ($a[$i]<$n){
                $out=$a[$i];
            }
        }
        return $out;
    }

    $pre=array(1000,2000,3000,4000,10000);
    $number=9999;

    echo "for number ".$number."<br />\n";
    echo "my_round is: ".my_round($number,$pre)."<br />\n";
    echo "my_round_down is: ".my_round_down($number,$pre)."\n";
    ?>[/code]
  14. [!--quoteo(post=355591:date=Mar 16 2006, 06:19 PM:name=gmd06)--][div class=\'quotetop\']QUOTE(gmd06 @ Mar 16 2006, 06:19 PM) [snapback]355591[/snapback][/div][div class=\'quotemain\'][!--quotec--]
    When i put in the print_r i get:

    [code]
    Array
    (
           [ints] => a:10:{i:0;s:2:
           [submit] => Pass it
    )
    [/code]

    The Error at offset is still there too. I added the stripslashes and it stayed the same.
    [/quote]
    Change line [code]<input type="hidden" name="ints" value="<?=$passedValue1?>"/>[/code] in form to[code]<input type="hidden" name="ints" value='<?=$passedValue1?>'/>[/code] " -> '
    and [code]$ints = unserialize($_POST['ints']);[/code] to [code]$ints = unserialize(stripslashes($_POST['ints']));[/code]
  15. [!--quoteo(post=353947:date=Mar 11 2006, 05:37 PM:name=swatisonee)--][div class=\'quotetop\']QUOTE(swatisonee @ Mar 11 2006, 05:37 PM) [snapback]353947[/snapback][/div][div class=\'quotemain\'][!--quotec--]
    hi,

    a. I have 2 Tables: Table A and Table B

    b. I have to select all records from Table A that donot appear in Table B . 1 field in both is common .

    c. I dont have a problem selecting data that appears in both tables where the same field is in common but
    the reverse is getting caught in a loop and i'm not able to figure out what the error is.

    d. The error is that the else statement gets executed.

    Would appreciate some guidance pleas.e . Thanks.Swati

    [code]$sqlb= "SELECT * FROM `Enq` WHERE  Category`!= 'D' && `Category`!= 'A' && fid='$fid'";
    $resultb=mysql_query($sqlb);
    if ($myrowb=mysql_fetch_array($resultb))
    {
    do
    {
    $enqid=$myrowb["Enqid"];

    $sqlc="SELECT * FROM `order` WHERE `Enqid`= $enqid ";
    if ( !@mysql_query($resultc) ) // <-- look this line
    {

    do {

         printf("<tr><td><input type=\"radio\" name=\"choice\" value=%d><td>
         <font size=2 face=Tahoma color=blue>%d<td>
         <font size=2 face=Tahoma color=blue>%s<td>
         <font size=2 face=Tahoma color=blue>%s<td>
    </tr>",
      $myrowb["Enqid"],
       $myrowb["fid"],
      $myrowb["Company"],
      calculatedate($myrowb["Date"]) );

    }
    while ($myrowc = mysql_fetch_array($resultc));
    }

    }
    while ($myrowb= mysql_fetch_array($resultb));
    }

    else {
        echo "Sorry, no records were found!";
    }[/code]
    [/quote]
    look lin 9 change '$resultc' to '$sqlc'
  16. [!--quoteo(post=353234:date=Mar 9 2006, 02:37 PM:name=fohanlon)--][div class=\'quotetop\']QUOTE(fohanlon @ Mar 9 2006, 02:37 PM) [snapback]353234[/snapback][/div][div class=\'quotemain\'][!--quotec--]
    Hi

    Does any one have any ideas how to create varaibles from a for loop that will be accessible on this page and can be posted to other pages

    Heres what I have

    for($i = 0; $i < 6; $i++)
    {
    $g = "gender".$i;
    $d = "day".$i;
    $m = "month".$i;
    $y = "year".$i;
    $e= "education".$i;

    $gender."$i" = $_POST[$g];
    $day."$i" = $_POST[$d];
    $month."$i" = $_POST[$m];
    $year."$i" = $_POST[$y];

    $today = date("Y-m-d");
    $t = explode("-", $today);

    $person_age = calculate_age($day, $month, $year);
    $education = $_POST[$e];

    echo "Gender: " . $gender."$i" . " Day: " . $day."$i" . " Month: " . $month."$i" . " Year: " . $year."$i" . " Education: " . $education."$i" . '<br>';
    }

    I want to be able to create 6 sets of varaibles for gender, age, month, year, education and be able to access them on the page as separate variables.

    many thanks,

    Fergal.
    [/quote]
    look this[code]<?php
    $test1="one";
    $a="test";
    $b=1;
    $c=2;
    $d=3;
    ${$a.$c}="two"; //$test2='two'
    ${"test".$d}="ten"; //$test3='ten'
    $e="test4";
    $test4="xyz";
    echo ${$a.$b}."</ br>\n";
    echo ${"test".$c}."</ br>\n";
    echo ${$a.$d}."</ br>\n";
    echo $$e."</ br>\n";
    $$e="abc"; // $test4='abc'
    echo $test4;
    ?>[/code]
×
×
  • 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.