Jump to content

MDanz

Members
  • Posts

    728
  • Joined

  • Last visited

Posts posted by MDanz

  1. the form is made up of text fields, with a button to add more textfields done with javascript.  So i need the onclick='history.go(-1)', to have the newly added textfields displayed when the user goes back.

     

    the onclick='history.go(-1)' is needed so if the user has went above the word count they can go back and change the values and re-submit, then the values are inserted into a database.

     

     

  2. i have a form on submit.php, with method post to the same page($PHP_SELF).  If i made a mistake i want to be able to go back to the previous page(same page) and have the values in their textfields.

    if(isset($_POST['new'])) {
    <a href='#' onClick='history.go(-1)'>Go Back</a>
    }
    else {
    // code
    
    }
    

     

    The problem is.. it goes back to the page as planned and then it changes page to submit.php#.  the previous page was submit.php?search=test. 

     

  3. the variable in the WHERE clause is the result of that WHERE clause. if that sounds confusing. basically the next result in the query is dependent on the previous result.  If i used a while loop then i would have to keep on repeating the while loop for every result.  With function recursion it repeats it for me.

     

    unless you know a better way than function recursion to loop the below so the result($number) of the query is inputted back into the WHERE clause and repeated.

    $get =  mysql_query("SELECT * FROM block WHERE sid='$number'",$this->connect);
    
    while($row = mysql_fetch_assoc($get)) {
    
    
    $number = $row['id'];
    }

  4. the function keeps returning 1. if i echo $i within the function then it counts up to six.  the function should return 6, because there are 6 results from the mysql_query, so $i iterates upto 6.  please any help solving this?

     

    $i=0;
    
    $thewidth = $database->width($theid, $i);
    
    echo $thewidth;
    

     

    function width($theid,$i)
    {
    $get =  mysql_query("SELECT * FROM block WHERE sid='$theid'",$this->connect);
    
    $i++;		
    
    while($row = mysql_fetch_assoc($get)) {
    
    
    $number = $row['id'];
    
    $this->width($number, $i);
    
    return $i;	 
    
    	}  
    
    
    }

  5. how do i set the scrolll width of the page in the iframe, so i can scroll horizontally in the iframe?

     

    <Iframe src="test.php?search=<?php echo $search; ?>" width="900px" height="600px"></Iframe>

     

    this sets the iframe perimeter size, but i want the inner size to be much bigger.

     

    maybe a better question is how to increase page size of test.php

  6. i want box 1 and box 2 horizontally next to each other.  I want the parent div if the content overflows to scroll and box1 and box2 horizontally next to each other.

     

    i tried below but box2 keeps going underneath box1.  the scroll is necessary.

    <div id='parent'>
    <div id='box1'></div>
    <div id='box2'></div>
    </div>
    
    #parent {
    overflow:scroll;
    width:100%;
    }
    
    #box1 {
    float:left;
    width:100px;
    height:100px;
    }
    
    #box2 {
    float:left;
    }
    
    

  7. Use a JOIN query instead of nested loops.

     

    SELECT b1.* 
    FROM block b1
      JOIN block b2 ON b1.sid = b2.sid
    WHERE b2.sid = {$id}
    ORDER BY b1.`id` DESC

    -Dan

     

    thanks but this only queries two results, when there is up to 10. when i do mysql_num_rows it only returns two results.

     

    e.g. 4 results

    id  name sid
    1   test1 0
    45 test2 1
    32 test3 45
    12 test4 32
    

     

     

  8. $getrest =  mysql_query("SELECT * FROM block WHERE sid='$id' ORDER BY `id` DESC",$this->connect);
    
    while($row1 = mysql_fetch_assoc($getrest)) {
    
    $idz = $row1['id'];
    
    $getmore =  mysql_query("SELECT * FROM block WHERE sid='$idz' ORDER BY `id` DESC",$this->connect);					
    						 while ($row2 = mysql_fetch_assoc($getmore)) {
    
    }
    
    }
    

     

    you see i'm using the result from the first query in the where clause of the second query.  This isn't good practice as what i'm trying to accomplish could lead me doing this up to ten times.  what would be a better way to do this than while loops inside of while loops?

     

     

    example?

  9. [id=239] [id=456,boxid=239][id=123,boxid=456]

     

    how would you go about doing this? instead of multiple while loops inside each other.

     

    i've been doing mysql_query select boxid='$previousid' and then doing while loop inside while loop per box.  there must be a better way.

  10. i've been doing while loops for this problem .. i dont think its the right way though.

     

    i have a set of boxes each with a boxid(apart from the first), which is the id(mysql) of the previous box. 

     

    e.g.

    box 1 has id 1

    box 2 has id 2 and boxid 1,

    box 3 has id 3 and boxid 2 etc

     

    you see the boxid is the same as the previous id.

     

    i want 10 boxes to display , when i'm trying to loop this i am using a while loop, but i keep on having to use another while loop inside, just to match the boxid with previous id, to get the next box to display. so i would have to do 10 while loops inside one another, which isn't good practice.

     

    is there a better way to do this? for loop? 

     

    another example

     

    e.g.

    box 1 has id 239

    box 2 has id 456 and boxid 239,

    box 3 has id 123 and boxid 456 etc

     

  11. i'm having trouble getting my function to return back variables to the page that called it.

     

    in the function i have variables $student1, $student2 $student3 in a function called getstudent.

     

    the code below on page student.php calls the function, if i return $student3 on page student.php if i echo $student3 it is blank. 

     

     

    any ideas?.. i don't want to echo it within the function.

     

    $thedatabase = new Database();
    $thedatabase->opendb();
    
    $input = $thedatabase->getstudent($student);
    
    return $student3;
    
    

  12. it should display the image but nothing appears. what have i done wrong?

     

    echo "<img src=\"photo.php?id=$studentid\" alt='photo' />";

     

    photo.php

    <?php
    
    $id= $_GET['id'];
    
    $getphoto= mysql_query("SELECT photo FROM Student WHERE SID=$id LIMIT 1");
    
    $row5 = mysql_fetch_assoc($getphoto);
    
    $photogot = $row5['PHOTO'];
    header("Content-type: image/gif");
    
       print $photogot;
    
    
    
    ?> 

×
×
  • 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.