MDanz
-
Posts
728 -
Joined
-
Last visited
Posts posted by MDanz
-
-
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.
-
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.
-
nvm i solved it using sessions.
-
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']; }
-
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; } }
-
now the page is blank
<?php $newdb = new Database(); $newdb->one; class Database { function one() { $id = $this->two(); echo $id; } function two() { $id = 9; return $id; } } ?>
-
i tried this and get this error.... Parse error: syntax error, unexpected T_RETURN in...
<?php $newdb = new Database(); class Database { function one() { $id = $this->two(); echo $id; } function two() { $id = 9 return $id; } } ?>
-
i have two functions. In function two it has $id=9. how do i get function one to echo $id?
how do i adjust the below example to accomplish this?
$newdb = new Database(); class Database { function one() { $newdb->two(); echo $id; } function two() { $id = 9 return $id; } }
-
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
-
function width2($noid) { $getwidth = mysql_query("SELECT * FROM block WHERE sid='$theid'",$this->connect); while($row1 = mysql_fetch_assoc($getwidth)) { $this->width2($noid); } }
how do i count how many times the function loops?
-
how do i make the overflow:scroll horizontal rather than vertical in the example below
http://www.w3schools.com/css/tryit.asp?filename=trycss_overflow
-
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; }
-
can you do that with php?
Database2() { function test($id) { $newdb = new Database2(); $newdb->test($id); } }
-
i tried that.. it still only displays 2 results... when there are 10. i thought this would be pretty easy but i was wrong. would an array be easier?
-
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
-
yes.
you see the next results 'sid' is the same as the previous results id.
e.g.
[id=5][id=95,sid=5][id=59,sid=95] etc
i was thinking of doing a self-join but i'm not sure how to implement it
-
$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?
-
[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.
-
the id comes from mysql.
when i add a new box, the boxid is the id of the previous box and so on.
-
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
-
nvm
-
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;
-
i get this error
<b>Fatal error</b>: Using $this when not in object context in .. on line 5.
line 5 is the query on photo.php
-
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; ?>
mysql select query help
in MySQL Help
Posted
a column in mysql has "test, a1, a2, a3".. in the select query how do i select a column that has "test" in it?