jaylearning Posted January 30, 2007 Share Posted January 30, 2007 hi! sorry im new to this and thanks in advance for looking.i wanted to have to 10 image display in a line and then start on a new line or new row how can i achive that please help....[code]<?php // Get the search variable from URL $var = @$_GET['q'] ; $trimmed = trim($var); //trim whitespace from the stored variable// rows to return$limit=800; // check for an empty string and display a message.if ($trimmed == "") { echo "<p>Please enter a search...</p>"; exit; }// check for a search parameterif (!isset($var)) { echo "<p>We dont seem to have a search parameter!</p>"; exit; }//connect to your database ** EDIT REQUIRED HERE **mysql_connect("localhost","",""); //(host, username, password)//specify database ** EDIT REQUIRED HERE **mysql_select_db("") or die("Unable to select database"); //select which database we're using// Build SQL Query $query = "select * from italk where cat like \"%$trimmed%\" order by id desc"; // EDIT HERE and specify your table and field names for the SQL query $numresults=mysql_query($query); $numrows=mysql_num_rows($numresults);// If we have no results, offer a google search as an alternativeif ($numrows == 0) {include('sorry.html'); }// next determine if s has been passed to script, if not use 0 if (empty($s)) { $s=0; }// get results $query .= " limit $s,$limit"; $result = mysql_query($query) or die("Couldn't execute query");// display what the person searched for// echo "<p>You searched for: "" . $var . ""</p>";// begin to show results setinclude('css.html');echo "";$count = 1 + $s ;// now you can display the results returned while ($row= mysql_fetch_array($result)) { $title = "<a alt=\"".$row['name']."\" OnClick=parent.myframeitalk.location=\"/iTalkPlayerz".$row['video'].".php?access=".$row['access']."&url=".$row['url']."\"><img hspace=\"5\" vspace=\"5\" width=\"88\" height=\"47\" src=\"".$row['img']."\" border=\"0\" class=\"borderimage\" onClick=\"borderit(this,'black')\" onMouseover=\"borderit(this,'#cef2ff'); ddrivetip('<font face=verdana size=1 color=black><b>".$row['name']."</b><br>Access: ".$row['access']. "', 100)\" onMouseout=\"borderit(this,'#009cff'); hideddrivetip()\"></a></font>";// $count.) echo "$title" ; $count++ ; }$currPage = (($s/$limit) + 1); echo "<br>" ; // next we need to do the links to other results if ($s>=1) { // bypass PREV link if s is 0 $prevs=($s-$limit); print " <a style=\"cursor: hand\" OnClick=location=\"$PHP_SELF?s=$prevs&q=$var\"><< Prev 10</a> - "; }// calculate number of pages needing links $pages=intval($numrows/$limit);// $pages now contains int of pages needed unless there is a remainder from division if ($numrows%$limit) { // has remainder so add one page $pages++; }// check to see if last page if (!((($s+$limit)/$limit)==$pages) && $pages!=1) { // not last page so give NEXT link $news=$s+$limit; echo " <a style=\"cursor: hand\" OnClick=location=\"$PHP_SELF?s=$news&q=$var\">Next 10 >></a>"; }$a = $s + ($limit) ; if ($a > $numrows) { $a = $numrows ; } $b = $s + 1 ; include('css2.html'); echo "<center>Serving help $numrows"; include('css3.html');?>[/code] Link to comment https://forums.phpfreaks.com/topic/36401-php-mysql-display-help-needed-please-help/ Share on other sites More sharing options...
JasonLewis Posted February 1, 2007 Share Posted February 1, 2007 i am guessing that the below is the loop, so i have added in the new line, you can do it with rows as well. just edit it a bit.[code=php:0]$count = 1;while ($row= mysql_fetch_array($result)) {$title = "<a alt=\"".$row['name']."\" onClick=parent.myframeitalk.location=\"/iTalkPlayerz".$row['video'].".php?access=".$row['access']."&url=".$row['url']."\"><img hspace=\"5\" vspace=\"5\" width=\"88\" height=\"47\" src=\"".$row['img']."\" border=\"0\" class=\"borderimage\" onClick=\"borderit(this,'black')\" onMouseover=\"borderit(this,'#cef2ff'); ddrivetip('<font face=verdana size=1 color=black><b>".$row['name']."</b><br>Access: ".$row['access']. "', 100)\" onMouseout=\"borderit(this,'#009cff'); hideddrivetip()\"></a></font>";echo "$title";$count++;if($count == 10){$count = 0;echo "<br>";}}[/code]simple. hope thats what your after. Link to comment https://forums.phpfreaks.com/topic/36401-php-mysql-display-help-needed-please-help/#findComment-174359 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.