Re: Display records on form

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 







first of all , let me apologize for the top post, second let me apologize for 
not giving more detail.  The main problem is basically "pagination" , i have 
failed to add pagination code to my own code simply because it is not as 
simple as i thought.  Considering i am a begginer in PHP , i must give myself 
some credit for reaching where i am ,  as for code snippet here goes,


[snip]




<html>
<title>IP Addresses</title>
<body>

<?php


  // Get the search variable from URL

  $var = @$_GET['q'] ;
  $trimmed = trim($var); //trim whitespace from the stored variable

// check for an empty string and display a message.
if ($trimmed == "")
  {
  echo "<p>Please enter a search...</p>";
  exit;
  }

// check for a search parameter
if (!isset($var))
  {
  echo "<p>We dont seem to have a search parameter!</p>";
  exit;
  }




$link = mysql_connect("localhost", "me","me2");
mysql_select_db("ip", $link);
$qry = mysql_query("SELECT * FROM IP_Addresses where free like '%".
$_GET['q']."%'", $link);

?>
<table border="1" width="100%"><tr><?php

if (mysql_num_rows($qry)==0 ) {

print " Oops No records found ";
?>
<br>
<a href="http://localhost/ipsearch2.html";>Back</a>
</br>
<?
exit();
}
if (mysql_num_rows($qry) > 0) {
   for ($i = 0; $i<mysql_num_fields($qry); $i++) {
           echo "<td align=center><strong>" . mysql_field_name($qry, $i) . 
"</td>";
}
}

?>

</tr><?php

if (mysql_num_rows($qry) > 0) {
   for ($j = 0; $j<mysql_num_rows($qry); $j++) {

       ?><tr><?php

       for ($k = 0; $k<mysql_num_fields($qry); $k++) {
           echo "<td align=center>" . mysql_result($qry,$j, $k) . "</td>";
       }

       ?></tr><?php

   }
}

?>
</table>
<br>
<br>
<a href="http://localhost/index.html";>Main Page</a>
<br>
<br>
<a href="http://localhost/ipsearch2.html";>IP Address Search</a></br></br>
</br>
</br>
</body>
</html>


[/snip]


i had posted some time back that i have problems with pagination and got alot 
of help , but the problem is i have never known how to put the code together 
with what i have .. any help is appreciated...


cheers





















On Tuesday 04 January 2005 04:17, Jochem Maas wrote:
> David Ziggy Lubowa wrote:
> > On Tuesday 04 January 2005 10:10, David Ziggy Lubowa wrote:
> >>Hey guys ,
> >>
> >> I was wondering , i have 16 records within a table in my Database , i
> >> have managed to have a form which can add and modify the records. My
> >> only problem is how i can display on a form when i search. Can someone
> >> give me heads up on how i can code this in php, to display the records
> >> in a tabular manner when i search.
>
> how does somebody manage to create a working script to insert/update
> data in a table and not be able to figure out how to output a simple
> HTML table listing the current records?????
> I mean, do you want us to teach you how to write PHP? (My rate is
> 40euros/hour)
>
> --
> Sorry David but your email shows little to no effort on your part to:
>
> a, define you problem succinctly
> b, show context (e.g. code,SQL snippets)
> c, show that you have made a decent effort to work the problem.
>
> given those facts you can consider yourself lucky to recieve any replies
> at all.
>
> ANYWAY... seeing as I'm bitchin' at ya I might as well give you a small
> clue....
>
> the process, roughly speaking is:
>
> 1. do a SQL select query. (e.g. SELECT id,name FROM mytable)
> 2. loop thru the result, for each row output some HTML for a table row
> 	e.g.
>
> 	echo '
> 	<tr>
> 		<td><a href="/edit.php?id='.$row['id'].'">edit</td>
> 		<td>'.$row['id'].'</td>
> 		<td>'.$row['name'].'</td>
> 	</tr>'
> 3. don't forget to add begin- and ending TABLE tags.
>
>
> try googling 'display a MYSQL result set with PHP':
> I came up with:
> http://juicystudio.com/tutorial/php/mysql.asp
> (which is pretty funny cos the guy wrote a tutorial on mysql/php on an
> ASP based site!!)
>
> > sorry i meant 16 fields  not records : )
>
> whether you tables has 16 rows or fields seems to me to be completely
> irrelevant.
>
> >>Any help is highly appreciated.
> >>
> >>
> >>cheers
> >>
> >>-Z

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux