Easy MySQL / PHP synax question?

  • Thread starter Thread starter James G
  • Start date Start date
J

James G

Guest
This code works, but i know theres gotta be a cleaner way to write it, can somebody please point me in the right diriection =)

$description1 = mysql_query("SELECT description FROM map WHERE mapnum = 1 + $pagenum");
$description2 = mysql_query("SELECT description FROM map WHERE mapnum = 2 + $pagenum");
$description3 = mysql_query("SELECT description FROM map WHERE mapnum = 3 + $pagenum");
$description4 = mysql_query("SELECT description FROM map WHERE mapnum = 4 + $pagenum");

$descriptionrow1 = mysql_fetch_row($description1);
$descriptionrow2 = mysql_fetch_row($description2);
$descriptionrow3 = mysql_fetch_row($description3);
$descriptionrow4 = mysql_fetch_row($description4);
im trying to find out if theres a way to shorten this so its less mysql requests to the server,

I need all the results just trying to fetch all the results at once
 
Yeah theres a lot better ways to write that heres one.

$description1 = mysql_query("SELECT description FROM map WHERE (mapnum = 1 + $pagenum) OR (mapnum = 2 + $pagenum) OR (mapnum = 3 + $pagenum) OR (mapnum = 4 + $pagenum");
$descriptionrow1 = mysql_fetch_row($description1);
 
Back
Top