wats roang in here ..

  1. <?php
  2. ini_set('display_errors', 1);
  3. //connecting to database
  4. $error = "nu am putut sa ma conectez :(";
  5. mysql_connect('localhost','root','')or die ($error);
  6. mysql_select_db('dan') or die ($error);
  7. //max display pet page
  8. $per_page = 2;
  9. //get start variabel
  10. $start = $_GET ;
  11. //cont record
  12. $record_count = mysql_num_rows( mysql_query("SELECT *FROM news"));
  13. //numara numarul maximal a paginilor
  14. $max_pages = $record_count / $per_pages;
  15. if (!$start)
  16. $start = 0 ;
  17. $get =$record_count = mysql_query("SELECT *FROM news LIMIT $start,$per_page");
  18. while($row = mysql_fetch_assoc($get))
  19. {
  20. //get data
  21. $id=$row;
  22. $title = $row;
  23. $body = $row;
  24. $date = $row;
  25. echo"
  26. <hr><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='pagina 11,2,3.php?start='>$title</a> $date</b><hr>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$body<br/>
  27. ";
  28. }
  29. $prev = $start - $per_page;
  30. $next = $start + $per_page;
  31. if (!($start<=0))
  32. echo"<a href='pagina 11,2,3.php?start=$prev'>Prev</a> ";
  33. //show page
  34. //set variable of first page
  35. $i = 1;
  36. for ($x=0;$x<$record_count;$x=$x+$per_page)
  37. {
  38. if ($start!= $x)
  39. echo "<a href='pagina 11,2,3.php?start=$x'>$i</a> ";
  40. else
  41. echo "<a href='pagina 11,2,3.php?start=$x'><b>$i</b></a> ";
  42. $i++;
  43. }
  44. //show buton
  45. if (!($start>=$record_count-$per_page))
  46. echo "<a href='pagina 11,2,3.php?start=$next'>next</a> ";
  47. ?>

thx 4 help

Hey.

There is nothing wrong with the syntax itself.

How is this supposed to be working?
And how is it actually working?

Are you getting any errors? (We like error messages! ;-])
What have you tried to do to fix this?

We can only work with what you give us.

P.S.
Try code-tags next time, rather than (list) :-)

wel it gives error in line 14 [Warning: Division by zero in D:\Dan\web\bundle\xampp\xampp\htdocs\test\pagina 11,2,3.php on line 17]

and this is a scrrip theat show toy your news and he is duing pages exempel [Prev 1 2 3 4 next ]
but i have this error and if i dont fix this ,the line 45 will not work
sory for my englesh , i'm learning just 3 ears
... i like this blog :)

Ok, on line #14, the problem is that you use a variable named $per_pages , which doesn't exist.
You have a variable on line #8 $per_page . Perhaps you meant to use that one?

oo deam i dident sea this sry

thx but i dont now why my page cheanger dont work i have 17 news but i 1 page i put : 2 news and i have just 2 pages ,it sean theat the lin 12 don't work .. or i dont now :9

[Please do not ask me to help you in a PM. Use the forums.]
i dont understand wat you mean PM

Ok, try this.
On line #17, you have this code:

$get =$record_count = mysql_query("SELECT *FROM news LIMIT $start,$per_page");

Remove the $record_count from there:

$get = mysql_query("SELECT *FROM news LIMIT $start,$per_page");

Also, just a heads up:
Line #12 of your code:

$record_count = mysql_num_rows( mysql_query("SELECT *FROM news"));

.
This is by far the most wasteful thing you can do.
You essentially fetch the ENTIRE table; every single piece of data in it, just so you can count how many rows there are.

A much MUCH better way to do this is to use the COUNT() function in the SQL query and read the results of that:

$countResult = mysql_query("SELECT COUNT(*) FROM news") or die(mysql_error());
$countRow = mysql_fetch_row($countResult);
$record_count = $countRow[0];

[Please do not ask me to help you in a PM. Use the forums.]
i dont understand wat you mean PM

PM = Private Message.
It's just my signature. Don't worry about that ;-)

:):):D:) thx thery much
and if you can lock here

im new at php and im duing this by a algorithm and i read much ,but it gives errors

<?php

if($_Post['title'])
{
//get data
$title = $_POST ['title'];
$body = $_POST ['body'];

//chceck for existance

if($title&&$body)
{
mysql_connect("localhost","root","")or die(mysql_error());
mysql_select_db("dan")or die (mysql_error());

$data ("Y-m-d");
//insert data
$insert = mysql_query("INSERT INTO news VALUES('','$title','$body','$data')")or die (mysql_error());
die("Anuntul a fost adugat");
}
else
  echo "pune info<p>";
}
?>
<Form action="" method='post'>
      Title:<br>
      <input type='text' name='title' id="title"><p>
      Body:<br>
      <textarea rows="6"cols='35' name = 'body' id="body" ></textarea>
      <p>
      <input type="submit" name='submit' value='Adauga' >
      <hr>
      <input tipe='text' name='photo'>

it gives i error in [Parse error: syntax error, unexpected T_VARIABLE in D:\Dan\web\bundle\xampp\xampp\htdocs\news\post.php on line 18]
this is a script theat put info in mysql data ... is like addinfo .

it gives i error in [Parse error: syntax error, unexpected T_VARIABLE in D:\Dan\web\bundle\xampp\xampp\htdocs\news\post.php on line 18]
this is a script theat put info in mysql data ... is like addinfo .

Lines #16 and #19 are missing the semi-colon to end the line. (The ; char)

Also, please use code tags around your code. Makes it so much easier to read.

thx it works :) thx thery much
do you have a messanger

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.