-
How important is i 6 compatibility nowadays.
I've got an old PIII PC with two old 40 Gb hard disks. Cost me little or nothing - thrown away by a friend plus a few bits and pieces from my stock of the same. I dual-boot a copy of win 2000 on each HDD with ie6 on one and ie 7 on another. Doesn't help with the specific coding issue, but at least you can see how your sites look as you work. Oh, of course I have Firefox on both disks for real work. Got to be better than logging onto some site or other each time you want to preview changes!
-
php for array value on one page to be search variable on next?
Thanks for the advice. I am quite happy with the GET procedure - it is just that I am only learning about php at the moment, so always open to advice and suggestions about the best way to do things. RJ
-
php for array value on one page to be search variable on next?
I'm open to suggestions as to a simpler or more elegant or whatever method. In a nutshell, this is what I want to do. I have a page of dogs photos displayed together with their names on, say, the "dogs for rehousing" page. These are produced via a database query when a user clicks on a link to that page. These images/names are displayed as clickable links. A person wanting to know more about a particular dog will click on that dog's image/name. This triggers a fuller search of the database for more info on the dog and it gets displayed on another page. There are no forms involved anywhere... Is that enough info? RJ
-
php for array value on one page to be search variable on next?
OK - I've cracked this problem The line for the link on my Page 1 (using my variables) should look like: echo "<a href=\"http://localhost/xampp/sosoldsite/dogfactstemplate.php?name=$name\"> <p class=\"name\">".$name."</p>\t\r"; And the GET statement on my Page 2 looks like: $name=$_GET['name']; Then the query includes this variable, so: $result = mysql_query("SELECT category, name, weight, height, age, gender, colour, breed, history, disposition, photo1, photo2 FROM sosanimals WHERE type= 'dog' AND name='$name' ") or die(mysql_error()); This seems to work fine. Many thanks to Elite for the generic code - just took a while to figure out how to translate it
-
php for array value on one page to be search variable on next?
Hi Elite. Well, the problem with only half understanding your advice is I get zero output. The problem is with trying to change your code to fit my variables. Perhaps if I give a bit more detail you could help contextualise your code for my situation? On my "Page1" I have the line: echo "<a href=\"http://localhost/xampp/sosoldsite/dogfactstemplate.php\"> <p class=\"name\">".$name."</p>\t\r"; Clicking the name will take the user to a page where I want to display more information about a particular dog. The variable I want to carry over to the next page is the one created by the line: $name = $results_array["name"]; name is the field name in my table for the dog's name and is the variable I want to carry over to Page 2 and search with the line: $result = mysql_query("SELECT category, name, weight, height, age, gender, colour, breed, history, disposition, photo1, photo2 FROM sosanimals WHERE type= 'dog' ") or die(mysql_error()); I'll carry on trying to change these lines to produce the right output, but if you have a moment to help convert your code to my variables I would be very grateful Cheers
-
php for array value on one page to be search variable on next?
Hey - thanks Elite for the quick response. I am a bit of a noob at php (OK with html and css) so it may take me a bit to understand exactly what has to go where. But give it a go I will
-
php for array value on one page to be search variable on next?
Hi all, I am helping an animal charity to redesign their website and to move to a database-driven set-up. I have a database with details on 170 dogs the charity is trying to get rehoused. Thanks to help from snowyswebsolutions and dddougal in this forum I have got to a position where I can display the name and photo of each dog as a clickable link on a page. The idea is for the visitor to click on a dog they like and be taken to a second page where they get all the facts and figures on that dog. Obviously, I don't want to have 170 html pages each with data on a different dog. What I need is a way for the name of a dog (or the name of its photo) stored in an array on page 1 to become one of the search criteria in a database search on page 2. Page 2 is just a template with a table set up up to echo that dog's full information. The relevant bit of code on Page 1 is: // sending query $results = mysql_query("SELECT * FROM $table WHERE type= 'dog' AND category = 'small' ORDER BY name"); if (!$results) { die("Query to show fields from table failed"); } while($results_array = mysql_fetch_array($results)) { $id = $results_array["id"]; $image = $results_array["photo1"]; $name = $results_array["name"]; echo "<div class=\"dog_box\">\r"; echo "\n"; echo "<p class=\"name\">".$name."</p>\t\r"; echo "\n"; echo "<a href=\"http://localhost/xampp/sosoldsite/dogfactstemplate.php\"> <p class=\"dog_img\"> ". $image ." </p></a>\t\r"; echo "\n\t"; echo "</div>"; } echo "<div class=\"clear\"></div>"; Thus, clicking on any of the photos takes the user to a page called dogfactstemplate.php. At the moment, on that page I have the following php - really just to make sure a search and table all work. The query is not correct, because it echoes ALL the dogs in the relevant category, not just the one the viewer wants to see: // sending query $result = mysql_query("SELECT category, name, weight, height, age, gender, colour, breed, history, disposition, photo1, photo2 FROM sosanimals WHERE type= 'dog' AND category='small' ") or die(mysql_error()); $fields_num = mysql_num_fields($result); echo "<table width='500px' background-color:transparent; cellpadding=5 > <tr>"; echo "<td width='200px' align=left <font color=#000000 size=3> Basics</font></td>"; echo "<td width='100px' align=left <font color=#000000 size=3> History</font></td>"; echo "<td width='200px' align=center <font color=#000000 size=3> </font></td>"; echo "</tr>\n"; // printing table rows $id = "id"; $category = "category"; $name = "name"; $weight = "weight"; $height = "height"; $age = "age"; $gender = "gender"; $colour = "colour"; $breed = "breed"; $history = "history"; $disposition = "disposition"; $photo1 = "photo1"; $photo2 = "photo2"; while($row = mysql_fetch_array($result)) { echo "<td align=left valign=top> Size: $row[$category]<br><br> Weight: $row[$weight]<br><br> Height: $row[$height]<br><br> Age: $row[$age]<br><br> Gender: $row[$gender]<br><br> Colour: $row[$colour]<br><br> Breed: $row[$breed]<br></td>"; echo "<td align=left valign=top> $row[$history] <br><br> $row[$disposition] <br> "; echo "<td align=left valign=top> $row[$photo1] </td>"; echo "</tr>"; } mysql_free_result($result); ?> </table> Can anyone help me to amend the query on the second page so that, for example, if the viewer clicks on an image called "pluto.jpg" on the first page, that becomes one of the search criteria to bring up Pluto's facts on page 2? TIA for any help. RJ
-
help plse to echo table in html from database
Thanks for the detailed explanation - I reckon I got it now I did look up lightbox. I found it interesting but had to park it as something to be read up on when I have a moment. I am learning so much new stuff at the moment, it is a bit of a struggle to understand everything. I removed the lightbox content to see if I could simplify the line in order to find the syntax error - that's all. It will go back in, now dddougal helped me find the error. Thanks to you for the original code. RJ
-
help plse to echo table in html from database
Thanks so much - that did it
-
help plse to echo table in html from database
Just for the sake of completeness the relevant bit of code looks like this: // sending query $results = mysql_query("SELECT * FROM $table WHERE type= 'dog' AND category = 'small' ORDER BY name"); if (!$results) { die("Query to show fields from table failed"); } while($results_array = mysql_fetch_array($results)) { $id = $results_array["id"]; $image = $results_array["photo1"]; $name = $results_array["name"]; $weight = $results_array["weight"]; $dog_type = $results_array["category"]; echo "<div class=\"dog_box\">\r"; echo "\n"; echo " <p class=\"name\">".$name."</p>\t\r"; echo "\n"; echo " <p class=\"dog_type\">".$dog_type."</p>\t\r"; echo "\n\t"; echo " <p class=\"weight\">".$weight."</p>\t\r"; echo "\n\t"; echo "<a href=\"http://localhost/xampp/sosoldsite/dogfactspage.php\" ><img src=\".$image.\" ></a>\t\r"; echo "\n\t"; echo "</div>"; } echo "<div class=\"clear\"></div>";
-
help plse to echo table in html from database
snowswebsolutions First, sincere apologies for not replying sooner. For some strange reason, I only get a notification of a reply by email about one in three of my posts. I saw no email so just checked back on the off-chance and there was your superb reply. So, second, many thanks for the code you supplied. I am a bit of a newbie at php, so it took a while to figure out what you had set out (I like to know why something is coded the way it is, rather than copying it blindly). I have got everything to work - obviously changing a few field-names along the way. I am pretty ok at css so no probs there. I must admit, I have struggled to understand the purpose of all the bits of the line: echo "<a href=\"images/for_web/dogs/large/".$name.".jpg\" rel=\"lightbox\" title=\"Name: ".$name." | Weight: ".$weight."\"><img src=\"".$image."\" width=\"200\" height=\"149\" class=\"dog_img\" ></a>\t\r"; The backslashes for each double quote get very confusing. The images are stored in my database in this way: <img src="http://localhost/xampp/sosoldsite/smalldogsphotos/marlene.jpg" height=90" width="93"> (I am still running things on a local server during design). So I tried replacing your line with the simple: echo " $image "; and that comes out fine in the sense that I can now get 5 pictures across the available space on my page, each one headed by whatever field data I want - brilliant!! Of course this does not make the images clickable links which is obviously the purpose of your line of code. However, is there a syntax error in your line? It prints the content of the end of the line rather than an image - something like: . I have tried reducing the complexity of your line by removing the references to lightbox etc. This leaves: echo "<a href=\"http://localhost/xampp/sosoldsite/dogfactspage.php\" ><img src=\".$image.\" ></a>\t\r"; but this still produces an error, printing instead of any images. I can't for the life of me see what it is but perhaps another pair of eyes could help here? Thanks again for all your help. RJ
-
help plse to echo table in html from database
Hi all, I am helping an animal charity to redesign their website and to move to a database-driven set-up. I have a database with details on 170 dogs the charity is trying to get rehoused. If a visitor clicks on a page about dogs available to be rehoused, the page should display all the dogs in that category (e.g. small, medium, or large) I have got the DB set up ok and can display details of the animals but not in the layout I want. For example, there might be 70 small dogs whose names and photos I want to have displayed on a specific page. Currently I just have a simple two-column table that echos the name and picture of each dog as a new row. This is fine except I have a very long page with 70 dogs names and pictures running down it. The code I have got together so far is: // sending query $result = mysql_query("SELECT name, photo1 FROM sosanimals WHERE type= 'dog' AND category = 'small' "); if (!$result) { die("Query to show fields from table failed"); } $fields_num = mysql_num_fields($result); // printing table rows $name = "name"; $photo1 = "photo1"; while($row = mysql_fetch_array($result)) { echo "<TABLE width=250px>"; echo "<TR> <TD width=150px>$row[$name] <br> $row[$photo1] </TD></TR>"; echo "</TABLE>"; } What I would like to do is have the page show each dog's name with its photo beneath it across the page - there is room for 4-5 photos - and then a new row of 4-5 photos/names and so on until all the dogs in that category have been exhausted. In the case above, that would be, say, about 14 rows with 5 dogs in each. Hope this is clear - can someone help me with the code for a table that would do this? Many many thanks RJ
-
php - stop echo of empty mysql cells?
Thanks for the examples everyone. I'll keep them in my files for when I get to that stage in my learning about php/mysql.
-
php - stop echo of empty mysql cells?
Avera [or SniderDK if it comes to that] Could either of you just amplify this for me ("also the code could work directly off the $row array and doesnt need to make a $address array"). I am keen to understand this area and arrays are next on the list for my studies! This is what I used in my php from your suggestion: // Build an address array. $address = array(); $address[] = $row['address1']; $address[] = $row['address2']; $address[] = $row['address3']; $address[] = $row['town']; $address[] = $row['postcode']; $address[] = $row['province']; $address[] = $row['phoneland']; $address[] = $row['phonemob']; $address[] = $row['fax']; // now we have an array with our address in it, let's do some magical stuff $addrblock = ''; foreach($address as $k=>$v) { if (isset($v) && !empty($v)) $addrblock .= trim($v) . '<br/>'; } echo "<td class='sr_number'>$addrblock", '<br>'; Note I have made the changes and removed the redundant line as per SniderDK's suggestion. Thanks to both of you. I think it is marvellous that experts like yourselves are prepared to give so generously of your time to people you don't even know and are unlikely to ever meet. Luckily I am a retired psychologist and am designing a database-driven website just as a way of teaching myself something new. Not sure I would want to do this for a living What a great forum this is.
-
php - stop echo of empty mysql cells?
Thanks for clarifying this for me. Just so I understand - how would your code look different with this new knowledge? Here is a clip of it: if(isset($row[$address2])){ echo $row[$address2].'<br>'; }else{ echo 'None'; } Cheers RJ